diff --git a/ChangeLog b/ChangeLog index d54a3cc17..d11089b84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2007-05-23 Enrico Tröger - * 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 diff --git a/geany.glade b/geany.glade index 51aa37882..ade1645c4 100644 --- a/geany.glade +++ b/geany.glade @@ -3365,7 +3365,7 @@ True - 1 + 2 3 False 0 @@ -3374,7 +3374,7 @@ True - Project files: + Startup path: False False GTK_JUSTIFY_LEFT @@ -3400,9 +3400,9 @@ - + True - Path to start in when opening project files + Path to start when opening or saving files. Must be an absolute path. Leave blank to use the current working directory. True True True @@ -3422,7 +3422,7 @@ - + True True GTK_RELIEF_NORMAL @@ -3449,6 +3449,85 @@ + + + + True + Project files: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 6 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Path to start in when opening project files + True + True + True + 0 + + True + + False + + + 1 + 2 + 1 + 2 + + + + + + + True + True + GTK_RELIEF_NORMAL + True + + + + True + gtk-open + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 2 + 3 + 1 + 2 + fill + + + diff --git a/src/dialogs.c b/src/dialogs.c index 44a46c037..aa4125a46 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -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); } diff --git a/src/geany.h b/src/geany.h index 62e67a9cb..983deb79b 100644 --- a/src/geany.h +++ b/src/geany.h @@ -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; diff --git a/src/interface.c b/src/interface.c index 675cf097b..b3a1b1419 100644 --- a/src/interface.c +++ b/src/interface.c @@ -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 (_("Paths")); 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"); diff --git a/src/main.c b/src/main.c index 8161a3a6b..5459f19c7 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/prefs.c b/src/prefs.c index 8af39daf8..0cb179a67 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -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"),