Add default startup directory option (closes #1704988).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1561 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2007-05-23 13:44:25 +00:00
parent 2f7fc48bf4
commit c1f109bc13
7 changed files with 159 additions and 15 deletions

View File

@ -1,6 +1,8 @@
2007-05-23 Enrico Tröger <enrico.troeger@uvena.de>
* src/vte.c: Added popup menu item: Change current working directory.
* src/vte.c: Add popup menu item: Change current working directory.
* geany.glade, src/dialogs.c, src/geany.h, src/interface.c, src/main.c,
src/prefs.c: Add default startup directory option (closes #1704988).
2007-05-23 Nick Treleaven <nick.treleaven@btinternet.com>

View File

@ -3365,7 +3365,7 @@
<child>
<widget class="GtkTable" id="table11">
<property name="visible">True</property>
<property name="n_rows">1</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
@ -3374,7 +3374,7 @@
<child>
<widget class="GtkLabel" id="label191">
<property name="visible">True</property>
<property name="label" translatable="yes">Project files:</property>
<property name="label" translatable="yes">Startup path:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@ -3400,9 +3400,9 @@
</child>
<child>
<widget class="GtkEntry" id="project_file_path_entry">
<widget class="GtkEntry" id="startup_path_entry">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Path to start in when opening project files</property>
<property name="tooltip" translatable="yes">Path to start when opening or saving files. Must be an absolute path. Leave blank to use the current working directory.</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
@ -3422,7 +3422,7 @@
</child>
<child>
<widget class="GtkButton" id="project_file_path_button">
<widget class="GtkButton" id="startup_path_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
@ -3449,6 +3449,85 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label192">
<property name="visible">True</property>
<property name="label" translatable="yes">Project files:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">6</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="project_file_path_entry">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Path to start in when opening project files</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="project_file_path_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image1775">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -156,6 +156,14 @@ void dialogs_show_open_file ()
g_free(initdir);
g_free(locale_filename);
}
// use default startup directory(if set) if no files are open
/// TODO should it only be used when initally open the dialog and not on every show?
else if (app->default_open_path != NULL && *app->default_open_path != '\0')
{
if (g_path_is_absolute(app->default_open_path))
gtk_file_chooser_set_current_folder(
GTK_FILE_CHOOSER(app->open_filesel), app->default_open_path);
}
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(app->open_filesel));
gtk_widget_show(app->open_filesel);
@ -309,6 +317,14 @@ gboolean dialogs_show_save_as()
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(app->save_filesel));
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(app->save_filesel), fname);
// use default startup directory(if set) if no files are open
if (app->default_open_path != NULL && *app->default_open_path != '\0')
{
if (g_path_is_absolute(app->default_open_path))
gtk_file_chooser_set_current_folder(
GTK_FILE_CHOOSER(app->save_filesel), app->default_open_path);
}
g_free(fname);
}

View File

@ -156,6 +156,7 @@ typedef struct MyApp
gchar *configdir;
gchar *datadir;
gchar *docdir;
gchar *default_open_path;
gchar *custom_date_format;
gchar **custom_commands;
gchar *tools_browser_cmd;

View File

@ -2381,9 +2381,13 @@ create_prefs_dialog (void)
GtkWidget *alignment28;
GtkWidget *table11;
GtkWidget *label191;
GtkWidget *startup_path_entry;
GtkWidget *startup_path_button;
GtkWidget *image1741;
GtkWidget *label192;
GtkWidget *project_file_path_entry;
GtkWidget *project_file_path_button;
GtkWidget *image1741;
GtkWidget *image1775;
GtkWidget *label190;
GtkWidget *label94;
GtkWidget *vbox14;
@ -2739,12 +2743,12 @@ create_prefs_dialog (void)
gtk_container_add (GTK_CONTAINER (frame25), alignment28);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment28), 0, 0, 12, 0);
table11 = gtk_table_new (1, 3, FALSE);
table11 = gtk_table_new (2, 3, FALSE);
gtk_widget_show (table11);
gtk_container_add (GTK_CONTAINER (alignment28), table11);
gtk_table_set_col_spacings (GTK_TABLE (table11), 6);
label191 = gtk_label_new (_("Project files:"));
label191 = gtk_label_new (_("Startup path:"));
gtk_widget_show (label191);
gtk_table_attach (GTK_TABLE (table11), label191, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
@ -2752,9 +2756,35 @@ create_prefs_dialog (void)
gtk_misc_set_alignment (GTK_MISC (label191), 0, 0.5);
gtk_misc_set_padding (GTK_MISC (label191), 6, 0);
startup_path_entry = gtk_entry_new ();
gtk_widget_show (startup_path_entry);
gtk_table_attach (GTK_TABLE (table11), startup_path_entry, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip (tooltips, startup_path_entry, _("Path to start when opening or saving files. Must be an absolute path. Leave blank to use the current working directory."), NULL);
gtk_entry_set_invisible_char (GTK_ENTRY (startup_path_entry), 8226);
startup_path_button = gtk_button_new ();
gtk_widget_show (startup_path_button);
gtk_table_attach (GTK_TABLE (table11), startup_path_button, 2, 3, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
image1741 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image1741);
gtk_container_add (GTK_CONTAINER (startup_path_button), image1741);
label192 = gtk_label_new (_("Project files:"));
gtk_widget_show (label192);
gtk_table_attach (GTK_TABLE (table11), label192, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label192), 0, 0.5);
gtk_misc_set_padding (GTK_MISC (label192), 6, 0);
project_file_path_entry = gtk_entry_new ();
gtk_widget_show (project_file_path_entry);
gtk_table_attach (GTK_TABLE (table11), project_file_path_entry, 1, 2, 0, 1,
gtk_table_attach (GTK_TABLE (table11), project_file_path_entry, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip (tooltips, project_file_path_entry, _("Path to start in when opening project files"), NULL);
@ -2762,13 +2792,13 @@ create_prefs_dialog (void)
project_file_path_button = gtk_button_new ();
gtk_widget_show (project_file_path_button);
gtk_table_attach (GTK_TABLE (table11), project_file_path_button, 2, 3, 0, 1,
gtk_table_attach (GTK_TABLE (table11), project_file_path_button, 2, 3, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
image1741 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image1741);
gtk_container_add (GTK_CONTAINER (project_file_path_button), image1741);
image1775 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image1775);
gtk_container_add (GTK_CONTAINER (project_file_path_button), image1775);
label190 = gtk_label_new (_("<b>Paths</b>"));
gtk_widget_show (label190);
@ -3972,9 +4002,13 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment28, "alignment28");
GLADE_HOOKUP_OBJECT (prefs_dialog, table11, "table11");
GLADE_HOOKUP_OBJECT (prefs_dialog, label191, "label191");
GLADE_HOOKUP_OBJECT (prefs_dialog, startup_path_entry, "startup_path_entry");
GLADE_HOOKUP_OBJECT (prefs_dialog, startup_path_button, "startup_path_button");
GLADE_HOOKUP_OBJECT (prefs_dialog, image1741, "image1741");
GLADE_HOOKUP_OBJECT (prefs_dialog, label192, "label192");
GLADE_HOOKUP_OBJECT (prefs_dialog, project_file_path_entry, "project_file_path_entry");
GLADE_HOOKUP_OBJECT (prefs_dialog, project_file_path_button, "project_file_path_button");
GLADE_HOOKUP_OBJECT (prefs_dialog, image1741, "image1741");
GLADE_HOOKUP_OBJECT (prefs_dialog, image1775, "image1775");
GLADE_HOOKUP_OBJECT (prefs_dialog, label190, "label190");
GLADE_HOOKUP_OBJECT (prefs_dialog, label94, "label94");
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox14, "vbox14");

View File

@ -780,6 +780,7 @@ void main_quit()
g_free(app->configdir);
g_free(app->datadir);
g_free(app->docdir);
g_free(app->default_open_path);
g_free(app->custom_date_format);
g_free(app->editor_font);
g_free(app->tagbar_font);

View File

@ -104,6 +104,9 @@ void prefs_init_dialog(void)
widget = lookup_widget(app->prefs_dialog, "entry_contextaction");
gtk_entry_set_text(GTK_ENTRY(widget), app->context_action_cmd);
widget = lookup_widget(app->prefs_dialog, "startup_path_entry");
gtk_entry_set_text(GTK_ENTRY(widget), app->default_open_path);
project_setup_prefs(); // project files path
@ -445,6 +448,10 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
g_free(app->context_action_cmd);
app->context_action_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
widget = lookup_widget(app->prefs_dialog, "startup_path_entry");
g_free(app->default_open_path);
app->default_open_path = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
project_apply_prefs(); // project file path
@ -1028,6 +1035,10 @@ void prefs_show_dialog(void)
G_CALLBACK(on_prefs_button_clicked), NULL);
g_signal_connect((gpointer) app->prefs_dialog, "delete_event",
G_CALLBACK(gtk_widget_hide_on_delete), NULL);
ui_setup_open_button_callback(lookup_widget(app->prefs_dialog, "startup_path_button"), NULL,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(lookup_widget(app->prefs_dialog, "startup_path_entry")));
g_signal_connect((gpointer) lookup_widget(app->prefs_dialog, "tagbar_font"),
"font-set", G_CALLBACK(on_prefs_font_choosed), GINT_TO_POINTER(1));
g_signal_connect((gpointer) lookup_widget(app->prefs_dialog, "msgwin_font"),