New setting, open dialog shows current doc directory

This commit is contained in:
Yevgen Muntyan 2007-08-07 00:19:47 -05:00
parent 837a7c93e2
commit 3072ce788d
7 changed files with 92 additions and 14 deletions

View File

@ -1,5 +1,4 @@
# XXX it needs plugins to be built first but plugins want mooedit-enums.h
SUBDIRS = gtksourceview plugins language-specs
SUBDIRS = gtksourceview plugins language-specs .
mooedit_toolsdir = $(MOO_DATA_DIR)
mooedit_tools_DATA = context.cfg menu.cfg filters.xml

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.0.3 on Fri Jul 20 12:54:00 2007 by muntyan@munt10
<!--Generated with glade3 3.0.3 on Tue Aug 7 00:09:57 2007 by muntyan@munt10
Version: 3.0.0
Date: Fri Dec 8 17:47:39 2006
User: muntyan
@ -197,6 +197,59 @@
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="border_width">3</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="bottom_padding">3</property>
<property name="left_padding">3</property>
<property name="right_padding">3</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">1</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkCheckButton" id="checkbutton3">
<property name="visible">True</property>
<property name="label" translatable="yes">Open dialog shows current document directory</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="moo_prefs_key">open_dialog_follows_doc</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">Dialogs</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -39,18 +39,38 @@ open_dialog_created (G_GNUC_UNUSED MooFileDialog *fd,
GSList *
_moo_edit_open_dialog (GtkWidget *widget,
MooFilterMgr *mgr)
MooFilterMgr *mgr,
MooEdit *current_doc)
{
MooFileDialog *dialog;
const char *start, *encoding;
const char *start_dir = NULL;
const char *encoding;
char *new_start;
GSList *filenames, *infos = NULL, *l;
char *freeme = NULL;
GSList *filenames = NULL;
GSList *infos = NULL;
GSList *l;
moo_prefs_create_key (moo_edit_setting (MOO_EDIT_PREFS_LAST_DIR), MOO_PREFS_STATE, G_TYPE_STRING, NULL);
start = moo_prefs_get_filename (moo_edit_setting (MOO_EDIT_PREFS_LAST_DIR));
if (current_doc && moo_prefs_get_bool (moo_edit_setting (MOO_EDIT_PREFS_DIALOGS_OPEN_FOLLOWS_DOC)))
{
char *filename = moo_edit_get_filename (current_doc);
if (filename)
{
freeme = g_path_get_dirname (filename);
start_dir = freeme;
g_free (filename);
}
}
if (!start_dir)
start_dir = moo_prefs_get_filename (moo_edit_setting (MOO_EDIT_PREFS_LAST_DIR));
dialog = moo_file_dialog_new (MOO_FILE_DIALOG_OPEN, widget,
TRUE, GTK_STOCK_OPEN, start, NULL);
TRUE, GTK_STOCK_OPEN, start_dir,
NULL);
g_object_set (dialog, "enable-encodings", TRUE, NULL);
g_signal_connect (dialog, "dialog-created", G_CALLBACK (open_dialog_created), NULL);
@ -58,10 +78,7 @@ _moo_edit_open_dialog (GtkWidget *widget,
moo_file_dialog_set_filter_mgr (dialog, mgr, "MooEdit");
if (!moo_file_dialog_run (dialog))
{
g_object_unref (dialog);
return NULL;
}
goto out;
encoding = moo_file_dialog_get_encoding (dialog);
@ -79,8 +96,11 @@ _moo_edit_open_dialog (GtkWidget *widget,
moo_prefs_set_filename (moo_edit_setting (MOO_EDIT_PREFS_LAST_DIR), new_start);
g_free (new_start);
out:
g_free (freeme);
g_object_unref (dialog);
g_slist_foreach (filenames, (GFunc) g_free, NULL);
g_slist_free (filenames);
return infos;
}

View File

@ -31,7 +31,8 @@ MooEditFileInfo *_moo_edit_save_as_dialog (MooEdit *edit,
MooFilterMgr *mgr,
const char *display_basename);
GSList *_moo_edit_open_dialog (GtkWidget *widget,
MooFilterMgr *mgr);
MooFilterMgr *mgr,
MooEdit *current_doc);
MooEditDialogResponse _moo_edit_save_changes_dialog (MooEdit *edit);
MooEditDialogResponse _moo_edit_save_multiple_changes_dialog (GSList *docs,

View File

@ -1271,7 +1271,9 @@ moo_editor_open (MooEditor *editor,
if (!files)
{
files = _moo_edit_open_dialog (parent, editor->priv->filter_mgr);
MooEdit *active = window ? moo_edit_window_get_active_doc (window) : NULL;
files = _moo_edit_open_dialog (parent, editor->priv->filter_mgr, active);
if (!files)
return FALSE;

View File

@ -98,6 +98,8 @@ _moo_edit_init_prefs (void)
NEW_KEY_BOOL (MOO_EDIT_PREFS_MAKE_BACKUPS, FALSE);
NEW_KEY_BOOL (MOO_EDIT_PREFS_STRIP, FALSE);
NEW_KEY_BOOL (MOO_EDIT_PREFS_DIALOGS_OPEN_FOLLOWS_DOC, FALSE);
NEW_KEY_STRING (MOO_EDIT_PREFS_COLOR_SCHEME, "kate");
NEW_KEY_BOOL (MOO_EDIT_PREFS_SMART_HOME_END, TRUE);

View File

@ -65,6 +65,7 @@ const char *moo_edit_setting (const char *setting_name);
#define MOO_EDIT_PREFS_DIALOGS "dialogs"
#define MOO_EDIT_PREFS_DIALOG_OPEN MOO_EDIT_PREFS_DIALOGS "/open"
#define MOO_EDIT_PREFS_DIALOGS_OPEN_FOLLOWS_DOC "open_dialog_follows_doc"
#define MOO_EDIT_PREFS_QUICK_SEARCH_FLAGS "quick_search_flags"
#define MOO_EDIT_PREFS_SEARCH_FLAGS "search_flags"