SF.net SVN: geany:[3428] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Sun Dec 28 17:25:09 UTC 2008


Revision: 3428
          http://geany.svn.sourceforge.net/geany/?rev=3428&view=rev
Author:   ntrel
Date:     2008-12-28 17:25:09 +0000 (Sun, 28 Dec 2008)

Log Message:
-----------
Add ui_hookup_widget() macro to the API.
Make saving Stash string settings NULL-safe.
Move fif_extra_options search setting code to search.c.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/keyfile.c
    trunk/src/plugindata.h
    trunk/src/search.c
    trunk/src/search.h
    trunk/src/stash.c
    trunk/src/ui_utils.c
    trunk/src/ui_utils.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-12-28 16:20:52 UTC (rev 3427)
+++ trunk/ChangeLog	2008-12-28 17:25:09 UTC (rev 3428)
@@ -9,6 +9,11 @@
    Add stash_group_add_string_vector().
  * src/main.c:
    Fix creating a new configuration directory (oops).
+ * src/ui_utils.h, src/plugindata.h, src/stash.c, src/keyfile.c,
+   src/search.c, src/search.h, src/ui_utils.c:
+   Add ui_hookup_widget() macro to the API.
+   Make saving Stash string settings NULL-safe.
+   Move fif_extra_options search setting code to search.c.
 
 
 2008-12-27  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2008-12-28 16:20:52 UTC (rev 3427)
+++ trunk/src/keyfile.c	2008-12-28 17:25:09 UTC (rev 3428)
@@ -479,9 +479,6 @@
 		g_key_file_set_string_list(config, PACKAGE, "custom_commands",
 				(const gchar**) ui_prefs.custom_commands, g_strv_length(ui_prefs.custom_commands));
 	}
-
-	/* search */
-	g_key_file_set_string(config, "search", "fif_extra_options", search_prefs.fif_extra_options ? search_prefs.fif_extra_options : "");
 }
 
 
@@ -815,9 +812,6 @@
 				(GEANY_MSGWIN_HEIGHT + GEANY_WINDOW_DEFAULT_HEIGHT - 440));
 
 	g_free(geo);
-
-	/* search */
-	search_prefs.fif_extra_options = utils_get_setting_string(config, "search", "fif_extra_options", "");
 }
 
 

Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h	2008-12-28 16:20:52 UTC (rev 3427)
+++ trunk/src/plugindata.h	2008-12-28 17:25:09 UTC (rev 3428)
@@ -45,13 +45,13 @@
 enum {
 	/** The Application Programming Interface (API) version, incremented
 	 * whenever any plugin data types are modified or appended to. */
-	GEANY_API_VERSION = 121,
+	GEANY_API_VERSION = 122,
 
 	/** The Application Binary Interface (ABI) version, incremented whenever
 	 * existing fields in the plugin data types have to be changed or reordered. */
 	/* This should usually stay the same if fields are only appended, assuming only pointers to
 	 * structs and not structs themselves are declared by plugins. */
-	GEANY_ABI_VERSION = 54
+	GEANY_ABI_VERSION = 55
 };
 
 /** Check the plugin can be loaded by Geany.

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2008-12-28 16:20:52 UTC (rev 3427)
+++ trunk/src/search.c	2008-12-28 17:25:09 UTC (rev 3428)
@@ -82,10 +82,11 @@
 static struct
 {
 	gint fif_mode;
+	gchar *fif_extra_options;
 }
-settings;
+settings = {0, NULL};
 
-GeanyPrefGroup *fif_prefs = NULL;
+static GeanyPrefGroup *fif_prefs = NULL;
 
 
 static struct
@@ -101,9 +102,8 @@
 	GtkWidget *dir_combo;
 	GtkWidget *search_combo;
 	GtkWidget *encoding_combo;
-	GtkWidget *extra_entry;
 }
-find_in_files = {NULL, NULL, NULL, NULL};
+find_in_files = {NULL, NULL, NULL};
 
 
 static gboolean search_read_io(GIOChannel *source, GIOCondition condition, gpointer data);
@@ -157,6 +157,8 @@
 		"radio_grep", FIF_GREP,
 		"radio_egrep", FIF_EGREP,
 		NULL);
+	stash_group_add_entry(group, &settings.fif_extra_options,
+		"fif_extra_options", "", "entry_extra");
 }
 
 
@@ -744,11 +746,9 @@
 	gtk_button_set_focus_on_click(GTK_BUTTON(check_extra), FALSE);
 
 	entry_extra = gtk_entry_new();
-	if (search_prefs.fif_extra_options)
-		gtk_entry_set_text(GTK_ENTRY(entry_extra), search_prefs.fif_extra_options);
 	gtk_widget_set_sensitive(entry_extra, FALSE);
 	ui_widget_set_tooltip_text(entry_extra, _("Other options to pass to Grep"));
-	find_in_files.extra_entry = entry_extra;
+	ui_hookup_widget(widgets.find_in_files_dialog, entry_extra, "entry_extra");
 
 	/* enable entry_extra when check_extra is checked */
 	g_signal_connect(check_extra, "toggled",
@@ -1192,15 +1192,13 @@
 
 	if (extra)
 	{
-		gchar *text = g_strdup(gtk_entry_get_text(GTK_ENTRY(find_in_files.extra_entry)));
+		g_strstrip(settings.fif_extra_options);
 
-		text = g_strstrip(text);
-		if (*text != 0)
+		if (*settings.fif_extra_options != 0)
 		{
 			g_string_append_c(gstr, ' ');
-			g_string_append(gstr, text);
+			g_string_append(gstr, settings.fif_extra_options);
 		}
-		g_free(text);
 	}
 	return gstr;
 }
@@ -1223,11 +1221,6 @@
 		GeanyEncodingIndex enc_idx = gtk_combo_box_get_active(
 			GTK_COMBO_BOX(find_in_files.encoding_combo));
 
-		/* update extra options pref */
-		g_free(search_prefs.fif_extra_options);
-		search_prefs.fif_extra_options = g_strdup(gtk_entry_get_text(GTK_ENTRY(
-			find_in_files.extra_entry)));
-
 		if (!NZV(utf8_dir))
 			ui_set_statusbar(FALSE, _("Invalid directory for find in files."));
 		else if (NZV(search_text))

Modified: trunk/src/search.h
===================================================================
--- trunk/src/search.h	2008-12-28 16:20:52 UTC (rev 3427)
+++ trunk/src/search.h	2008-12-28 17:25:09 UTC (rev 3428)
@@ -42,7 +42,6 @@
 
 typedef struct GeanySearchPrefs
 {
-	gchar		*fif_extra_options;
 	gboolean	suppress_dialogs;
 	gboolean	use_current_word;
 	gboolean	use_current_file_dir;	/* find in files directory to use on showing dialog */

Modified: trunk/src/stash.c
===================================================================
--- trunk/src/stash.c	2008-12-28 16:20:52 UTC (rev 3427)
+++ trunk/src/stash.c	2008-12-28 17:25:09 UTC (rev 3428)
@@ -149,7 +149,8 @@
 				se->default_value);
 			break;
 		case SETTING_WRITE:
-			g_key_file_set_string(config, group->name, se->key_name, *setting);
+			g_key_file_set_string(config, group->name, se->key_name,
+				*setting ? *setting : "");
 			break;
 	}
 }

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2008-12-28 16:20:52 UTC (rev 3427)
+++ trunk/src/ui_utils.c	2008-12-28 17:25:09 UTC (rev 3428)
@@ -21,7 +21,7 @@
  * $Id$
  */
 
-/** @file ui_utils.c
+/** @file ui_utils.h
  * User Interface general utility functions.
  */
 
@@ -1726,13 +1726,14 @@
 }
 
 
-/** This function returns a widget in a component created by Glade.
+/** This function returns a widget from a name in a component, usually created by Glade.
  * Call it with the toplevel widget in the component (i.e. a window/dialog),
  * or alternatively any widget in the component, and the name of the widget
  * you want returned.
  * @param widget Widget with the @a widget_name property set.
  * @param widget_name Name to lookup.
- * @return The widget found. */
+ * @return The widget found.
+ * @see ui_hookup_widget(). */
 GtkWidget *ui_lookup_widget(GtkWidget *widget, const gchar *widget_name)
 {
 	GtkWidget *parent, *found_widget;

Modified: trunk/src/ui_utils.h
===================================================================
--- trunk/src/ui_utils.h	2008-12-28 16:20:52 UTC (rev 3427)
+++ trunk/src/ui_utils.h	2008-12-28 17:25:09 UTC (rev 3428)
@@ -24,6 +24,16 @@
 #ifndef GEANY_UI_UTILS_H
 #define GEANY_UI_UTILS_H 1
 
+/** Set a name to lookup @a widget from @a owner.
+ * @param owner Usually a @c GtkWindow.
+ * @param widget Widget.
+ * @param widget_name Name.
+ * @see ui_lookup_widget(). */
+#define ui_hookup_widget(owner, widget, widget_name) \
+	g_object_set_data_full(G_OBJECT(owner), widget_name, \
+		g_object_ref(widget), (GDestroyNotify)g_object_unref);
+
+
 typedef struct GeanyInterfacePrefs
 {
 	gboolean		sidebar_symbol_visible;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list