Revision: 1486 http://svn.sourceforge.net/geany/?rev=1486&view=rev Author: ntrel Date: 2007-04-29 09:36:42 -0700 (Sun, 29 Apr 2007)
Log Message: ----------- Add project file path preferences option in General tab.
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/src/interface.c trunk/src/prefs.c trunk/src/project.c trunk/src/project.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-04-29 12:03:25 UTC (rev 1485) +++ trunk/ChangeLog 2007-04-29 16:36:42 UTC (rev 1486) @@ -8,6 +8,9 @@ Add ui_setup_open_button_callback() for setting up a button callback that behaves like the open button in ui_path_box_new(). Use ui_path_box_new() in FIF dialog setup. + * src/interface.c, src/project.c, src/project.h, src/prefs.c, + geany.glade: + Add project file path preferences option in General tab.
2007-04-29 Enrico Tröger enrico.troeger@uvena.de
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2007-04-29 12:03:25 UTC (rev 1485) +++ trunk/geany.glade 2007-04-29 16:36:42 UTC (rev 1486) @@ -3274,7 +3274,7 @@ <property name="angle">0</property> </widget> <packing> - <property name="padding">0</property> + <property name="padding">6</property> <property name="expand">False</property> <property name="fill">False</property> </packing> @@ -3333,6 +3333,147 @@ <property name="fill">True</property> </packing> </child> + + <child> + <widget class="GtkFrame" id="frame25"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + + <child> + <widget class="GtkAlignment" id="alignment28"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkTable" id="table11"> + <property name="visible">True</property> + <property name="n_rows">1</property> + <property name="n_columns">3</property> + <property name="homogeneous">False</property> + <property name="row_spacing">0</property> + <property name="column_spacing">6</property> + + <child> + <widget class="GtkLabel" id="label191"> + <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">0</property> + <property name="bottom_attach">1</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">0</property> + <property name="bottom_attach">1</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="image1741"> + <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">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label190"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Paths</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</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="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> </widget> <packing> <property name="tab_expand">False</property>
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2007-04-29 12:03:25 UTC (rev 1485) +++ trunk/src/interface.c 2007-04-29 16:36:42 UTC (rev 1486) @@ -2366,6 +2366,14 @@ GtkWidget *label189; GtkWidget *entry_contextaction; GtkWidget *label188; + GtkWidget *frame25; + GtkWidget *alignment28; + GtkWidget *table11; + GtkWidget *label191; + GtkWidget *project_file_path_entry; + GtkWidget *project_file_path_button; + GtkWidget *image1741; + GtkWidget *label190; GtkWidget *label94; GtkWidget *vbox14; GtkWidget *frame7; @@ -2697,7 +2705,7 @@
label189 = gtk_label_new (_("Context Action command:")); gtk_widget_show (label189); - gtk_box_pack_start (GTK_BOX (hbox8), label189, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox8), label189, FALSE, FALSE, 6);
entry_contextaction = gtk_entry_new (); gtk_widget_show (entry_contextaction); @@ -2710,6 +2718,52 @@ gtk_frame_set_label_widget (GTK_FRAME (frame24), label188); gtk_label_set_use_markup (GTK_LABEL (label188), TRUE);
+ frame25 = gtk_frame_new (NULL); + gtk_widget_show (frame25); + gtk_box_pack_start (GTK_BOX (vbox20), frame25, TRUE, TRUE, 0); + gtk_frame_set_shadow_type (GTK_FRAME (frame25), GTK_SHADOW_NONE); + + alignment28 = gtk_alignment_new (0.5, 0.5, 1, 1); + gtk_widget_show (alignment28); + 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); + 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:")); + gtk_widget_show (label191); + gtk_table_attach (GTK_TABLE (table11), label191, 0, 1, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label191), 0, 0.5); + gtk_misc_set_padding (GTK_MISC (label191), 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, + (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); + gtk_entry_set_invisible_char (GTK_ENTRY (project_file_path_entry), 8226); + + 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, + (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); + + label190 = gtk_label_new (_("<b>Paths</b>")); + gtk_widget_show (label190); + gtk_frame_set_label_widget (GTK_FRAME (frame25), label190); + gtk_label_set_use_markup (GTK_LABEL (label190), TRUE); + label94 = gtk_label_new (_("General")); gtk_widget_show (label94); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 0), label94); @@ -3903,6 +3957,14 @@ GLADE_HOOKUP_OBJECT (prefs_dialog, label189, "label189"); GLADE_HOOKUP_OBJECT (prefs_dialog, entry_contextaction, "entry_contextaction"); GLADE_HOOKUP_OBJECT (prefs_dialog, label188, "label188"); + GLADE_HOOKUP_OBJECT (prefs_dialog, frame25, "frame25"); + 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, 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, label190, "label190"); GLADE_HOOKUP_OBJECT (prefs_dialog, label94, "label94"); GLADE_HOOKUP_OBJECT (prefs_dialog, vbox14, "vbox14"); GLADE_HOOKUP_OBJECT (prefs_dialog, frame7, "frame7");
Modified: trunk/src/prefs.c =================================================================== --- trunk/src/prefs.c 2007-04-29 12:03:25 UTC (rev 1485) +++ trunk/src/prefs.c 2007-04-29 16:36:42 UTC (rev 1486) @@ -42,6 +42,7 @@ #include "keybindings.h" #include "interface.h" #include "encodings.h" +#include "project.h"
#ifdef HAVE_VTE # include "vte.h" @@ -100,22 +101,12 @@ widget = lookup_widget(app->prefs_dialog, "check_ask_suppress_search_dialogs"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_main_suppress_search_dialogs);
- widget = lookup_widget(app->prefs_dialog, "check_show_notebook_tabs"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->show_notebook_tabs); - // disable following setting if notebook tabs are hidden - on_show_notebook_tabs_toggled(GTK_TOGGLE_BUTTON( - lookup_widget(app->prefs_dialog, "check_show_notebook_tabs")), NULL); - - if (app->tab_order_ltr) - widget = lookup_widget(app->prefs_dialog, "radio_tab_right"); - else - widget = lookup_widget(app->prefs_dialog, "radio_tab_left"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); - widget = lookup_widget(app->prefs_dialog, "entry_contextaction"); gtk_entry_set_text(GTK_ENTRY(widget), app->context_action_cmd);
+ project_setup_prefs(); // project files path
+ // Interface settings widget = lookup_widget(app->prefs_dialog, "check_list_symbol"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->sidebar_symbol_visible); @@ -149,6 +140,12 @@ gtk_color_button_set_color(GTK_COLOR_BUTTON(widget), color); g_free(color);
+ widget = lookup_widget(app->prefs_dialog, "check_show_notebook_tabs"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->show_notebook_tabs); + // disable following setting if notebook tabs are hidden + on_show_notebook_tabs_toggled(GTK_TOGGLE_BUTTON( + lookup_widget(app->prefs_dialog, "check_show_notebook_tabs")), NULL); + widget = lookup_widget(app->prefs_dialog, "combo_tab_editor"); gtk_combo_box_set_active(GTK_COMBO_BOX(widget), app->tab_pos_editor);
@@ -212,6 +209,14 @@ lookup_widget(app->prefs_dialog, "check_toolbar_show")), NULL);
+ // Files settings + if (app->tab_order_ltr) + widget = lookup_widget(app->prefs_dialog, "radio_tab_right"); + else + widget = lookup_widget(app->prefs_dialog, "radio_tab_left"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); + + // Editor settings widget = lookup_widget(app->prefs_dialog, "spin_tab_width"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), app->pref_editor_tab_width); @@ -436,17 +441,13 @@ widget = lookup_widget(app->prefs_dialog, "check_switch_pages"); app->switch_msgwin_pages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- widget = lookup_widget(app->prefs_dialog, "radio_tab_right"); - app->tab_order_ltr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - - widget = lookup_widget(app->prefs_dialog, "check_show_notebook_tabs"); - app->show_notebook_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - widget = lookup_widget(app->prefs_dialog, "entry_contextaction"); g_free(app->context_action_cmd); app->context_action_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
+ project_apply_prefs(); // project file path
+ // Interface settings widget = lookup_widget(app->prefs_dialog, "check_list_symbol"); app->sidebar_symbol_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); @@ -467,6 +468,9 @@ } if (app->long_line_column == 0) app->long_line_type = 2;
+ widget = lookup_widget(app->prefs_dialog, "check_show_notebook_tabs"); + app->show_notebook_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + widget = lookup_widget(app->prefs_dialog, "combo_tab_editor"); app->tab_pos_editor = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
@@ -528,6 +532,11 @@ app->toolbar_icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
+ // Files settings + widget = lookup_widget(app->prefs_dialog, "radio_tab_right"); + app->tab_order_ltr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + + // Editor settings widget = lookup_widget(app->prefs_dialog, "spin_tab_width"); app->pref_editor_tab_width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
Modified: trunk/src/project.c =================================================================== --- trunk/src/project.c 2007-04-29 12:03:25 UTC (rev 1485) +++ trunk/src/project.c 2007-04-29 16:36:42 UTC (rev 1486) @@ -43,7 +43,12 @@
ProjectPrefs project_prefs = {NULL};
+static struct +{ + gchar *project_file_path; +} local_prefs = {NULL};
+ static gboolean entries_modified;
// simple struct to keep references to the elements of the properties dialog @@ -74,7 +79,7 @@ // avoid using __VA_ARGS__ because older gcc 2.x versions probably don't support C99 #define SHOW_ERR(args...) dialogs_show_msgbox(GTK_MESSAGE_ERROR, args) #define MAX_NAME_LEN 50 -// "projects" is part of the default project base path so be carefully when translating +// "projects" is part of the default project base path so be careful when translating // please avoid special characters and spaces, look at the source for details or ask Frank #define PROJECT_DIR _("projects")
@@ -225,7 +230,7 @@
void project_open() { - gchar *dir = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, PROJECT_DIR, NULL); + const gchar *dir = local_prefs.project_file_path; #ifdef G_OS_WIN32 gchar *file; #else @@ -273,8 +278,6 @@ run_open_dialog(GTK_DIALOG(dialog)); gtk_widget_destroy(GTK_WIDGET(dialog)); #endif - - g_free(dir); }
@@ -744,6 +747,7 @@ gchar *base_path; gchar *file_name; gchar *name; + const gchar *project_dir = local_prefs.project_file_path;
if (entries_modified) return; @@ -751,21 +755,17 @@ name = gtk_editable_get_chars(editable, 0, -1); if (name != NULL && strlen(name) > 0) { - base_path = g_strconcat( - GEANY_HOME_DIR, G_DIR_SEPARATOR_S, PROJECT_DIR, G_DIR_SEPARATOR_S, + base_path = g_strconcat(project_dir, G_DIR_SEPARATOR_S, name, G_DIR_SEPARATOR_S, NULL); - file_name = g_strconcat( - GEANY_HOME_DIR, G_DIR_SEPARATOR_S, PROJECT_DIR, G_DIR_SEPARATOR_S, + file_name = g_strconcat(project_dir, G_DIR_SEPARATOR_S, name, "." GEANY_PROJECT_EXT, NULL); - g_free(name); } else { - base_path = g_strconcat( - GEANY_HOME_DIR, G_DIR_SEPARATOR_S, PROJECT_DIR, G_DIR_SEPARATOR_S, NULL); - file_name = g_strconcat( - GEANY_HOME_DIR, G_DIR_SEPARATOR_S, PROJECT_DIR, G_DIR_SEPARATOR_S, NULL); + base_path = g_strconcat(project_dir, G_DIR_SEPARATOR_S, NULL); + file_name = g_strconcat(project_dir, G_DIR_SEPARATOR_S, NULL); } + g_free(name);
gtk_entry_set_text(GTK_ENTRY(e->base_path), base_path); gtk_entry_set_text(GTK_ENTRY(e->file_name), file_name); @@ -897,6 +897,8 @@
g_key_file_set_string(config, "project", "session_file", utf8_filename); } + g_key_file_set_string(config, "project", "project_file_path", + NVL(local_prefs.project_file_path, "")); }
@@ -908,5 +910,38 @@ project_prefs.session_file = utils_get_setting_string(config, "project", "session_file", ""); } + local_prefs.project_file_path = utils_get_setting_string(config, "project", + "project_file_path", NULL); + if (local_prefs.project_file_path == NULL) + { + local_prefs.project_file_path = g_strconcat(GEANY_HOME_DIR, + G_DIR_SEPARATOR_S, PROJECT_DIR, NULL); + } }
+ +/* Initialize project-related preferences in the Preferences dialog. */ +void project_setup_prefs() +{ + GtkWidget *path_entry = lookup_widget(app->prefs_dialog, "project_file_path_entry"); + GtkWidget *path_btn = lookup_widget(app->prefs_dialog, "project_file_path_button"); + + g_return_if_fail(local_prefs.project_file_path != NULL); + gtk_entry_set_text(GTK_ENTRY(path_entry), local_prefs.project_file_path); + ui_setup_open_button_callback(path_btn, GTK_ENTRY(path_entry), + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); +} + + +/* Update project-related preferences after using the Preferences dialog. */ +void project_apply_prefs() +{ + GtkWidget *path_entry = lookup_widget(app->prefs_dialog, "project_file_path_entry"); + const gchar *str; + + str = gtk_entry_get_text(GTK_ENTRY(path_entry)); + g_free(local_prefs.project_file_path); + local_prefs.project_file_path = g_strdup(str); +} + +
Modified: trunk/src/project.h =================================================================== --- trunk/src/project.h 2007-04-29 12:03:25 UTC (rev 1485) +++ trunk/src/project.h 2007-04-29 16:36:42 UTC (rev 1486) @@ -67,4 +67,8 @@
void project_load_prefs(GKeyFile *config);
+void project_setup_prefs(); + +void project_apply_prefs(); + #endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.