Use document name when exporting to PDF

master
Yevgen Muntyan 2007-07-18 06:29:40 -05:00
parent 96d18e3d9e
commit 3f108d0576
5 changed files with 34 additions and 8 deletions

View File

@ -1672,20 +1672,39 @@ action_print_preview (MooEditWindow *window)
static void
action_print_pdf (MooEditWindow *window)
{
char *start_name;
const char *doc_name, *dot;
const char *filename;
gpointer doc = moo_edit_window_get_active_doc (window);
doc_name = doc ? moo_edit_get_display_basename (doc) : "output";
dot = strrchr (doc_name, '.');
if (dot && dot != doc_name)
{
start_name = g_new (char, (dot - doc_name) + 5);
memcpy (start_name, doc_name, dot - doc_name);
memcpy (start_name + (dot - doc_name), ".pdf", 5);
}
else
{
start_name = g_strdup_printf ("%s.pdf", doc_name);
}
doc = moo_edit_window_get_active_doc (window);
g_return_if_fail (doc != NULL);
filename = moo_file_dialogp (GTK_WIDGET (window),
MOO_FILE_DIALOG_SAVE,
start_name,
"Export as PDF",
moo_edit_setting (MOO_EDIT_PREFS_PDF_LAST_DIR),
NULL);
if (filename)
_moo_edit_export_pdf (doc, filename);
g_free (start_name);
}
#endif

View File

@ -2378,6 +2378,7 @@
(parameters
'("GtkWidget*" "parent" (null-ok) (default "NULL"))
'("MooFileDialogType" "type")
'("const-char*" "start_name" (null-ok) (default "NULL"))
'("const-char*" "title" (null-ok) (default "NULL"))
'("const-char*" "prefs_key")
'("const-char*" "alternate_prefs_key" (null-ok) (default "NULL"))

View File

@ -704,16 +704,18 @@ override moo_file_dialog kwargs
static PyObject *
_wrap_moo_file_dialog (G_GNUC_UNUSED PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "type", "parent", "title", "start_dir", NULL };
static char *kwlist[] = { "type", "parent", "start_name", "title", "start_dir", NULL };
PyObject *py_type = NULL;
int type;
char *title = NULL, *start_dir = NULL;
const gchar *ret;
const char *title = NULL;
const char *start_dir = NULL;
const char *start_name = NULL;
const char *ret;
GtkWidget *parent = NULL;
PyGObject *py_parent = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Ozz:file_dialog", kwlist,
&py_type, &py_parent, &title, &start_dir))
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Ozzz:file_dialog", kwlist,
&py_type, &py_parent, &start_name, &title, &start_dir))
return NULL;
if (pyg_enum_get_value (MOO_TYPE_FILE_DIALOG_TYPE, py_type, &type))
@ -733,7 +735,7 @@ _wrap_moo_file_dialog (G_GNUC_UNUSED PyObject *self, PyObject *args, PyObject *k
return NULL;
}
ret = moo_file_dialog (parent, type, title, start_dir);
ret = moo_file_dialog (parent, type, start_name, title, start_dir);
if (ret)
return PyString_FromString(ret);

View File

@ -351,13 +351,14 @@ GtkWidget *file_chooser_dialog_new (const char *title,
const char *
moo_file_dialog (GtkWidget *parent,
MooFileDialogType type,
const char *start_name,
const char *title,
const char *start_dir)
{
static char *filename;
MooFileDialog *dialog;
dialog = moo_file_dialog_new (type, parent, FALSE, title, start_dir, NULL);
dialog = moo_file_dialog_new (type, parent, FALSE, title, start_dir, start_name);
g_return_val_if_fail (dialog != NULL, NULL);
moo_file_dialog_run (dialog);
@ -670,6 +671,7 @@ moo_file_dialog_get_encoding (MooFileDialog *dialog)
const char *
moo_file_dialogp (GtkWidget *parent,
MooFileDialogType type,
const char *start_name,
const char *title,
const char *prefs_key,
const char *alternate_prefs_key)
@ -692,7 +694,7 @@ moo_file_dialogp (GtkWidget *parent,
start = moo_prefs_get_string (alternate_prefs_key);
}
filename = moo_file_dialog (parent, type, title, start);
filename = moo_file_dialog (parent, type, start_name, title, start);
if (filename && prefs_key)
{

View File

@ -81,10 +81,12 @@ const char *moo_file_dialog_get_encoding (MooFileDialog *dialog);
const char *moo_file_dialog (GtkWidget *parent,
MooFileDialogType type,
const char *basename_utf8,
const char *title,
const char *start_dir);
const char *moo_file_dialogp (GtkWidget *parent,
MooFileDialogType type,
const char *basename_utf8,
const char *title,
const char *prefs_key,
const char *alternate_prefs_key);