SF.net SVN: geany:[3331] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Dec 6 12:28:21 UTC 2008


Revision: 3331
          http://geany.svn.sourceforge.net/geany/?rev=3331&view=rev
Author:   eht16
Date:     2008-12-06 12:28:21 +0000 (Sat, 06 Dec 2008)

Log Message:
-----------
If the requested file in ui_add_config_file_menu_item() doesn't exist in the user's config directory, try reading it from the global data directory and use the contents for the new file.
Add a menu item to 'Tools->Configuration files' for the toolbar UI definition. 

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/toolbar.c
    trunk/src/ui_utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-12-06 12:12:00 UTC (rev 3330)
+++ trunk/ChangeLog	2008-12-06 12:28:21 UTC (rev 3331)
@@ -23,6 +23,12 @@
    Add new stock icon GEANY_STOCK_SAVE_ALL.
    Remove code to manually update the size of the 'Save All' toolbar
    icon and use the GEANY_STOCK_SAVE_ALL stock icon instead.
+ * src/ui_utils.c, src/toolbar.c:
+   If the requested file in ui_add_config_file_menu_item() doesn't exist
+   in the user's config directory, try reading it from the global
+   data directory and use the contents for the new file.
+   Add a menu item to 'Tools->Configuration files' for the toolbar UI
+   definition.
 
 
 2008-12-05  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/toolbar.c
===================================================================
--- trunk/src/toolbar.c	2008-12-06 12:12:00 UTC (rev 3330)
+++ trunk/src/toolbar.c	2008-12-06 12:28:21 UTC (rev 3331)
@@ -33,6 +33,7 @@
 #include "callbacks.h"
 #include "utils.h"
 #include "dialogs.h"
+#include "document.h"
 #include "geanyobject.h"
 #include "geanymenubuttonaction.h"
 #include "geanyentryaction.h"
@@ -138,23 +139,24 @@
 }
 
 
-/*
-static void on_document_save(G_GNUC_UNUSED GObject *object, G_GNUC_UNUSED gpointer *doc,
+static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc,
 							 G_GNUC_UNUSED gpointer data)
 {
-	dialogs_show_msgbox(GTK_MESSAGE_INFO,
+	g_return_if_fail(NZV(doc->real_path));
+
+	if (utils_str_equal(doc->real_path, utils_build_path(app->configdir, "ui_toolbar.xml", NULL)))
+	{
+		dialogs_show_msgbox(GTK_MESSAGE_INFO,
 		_("For all changes you make in this file to take effect, you need to restart Geany."));
+	}
 }
-*/
 
 
 void toolbar_add_config_file_menu_item(void)
 {
-/*
 	ui_add_config_file_menu_item(
 		utils_build_path(app->configdir, "ui_toolbar.xml", NULL), NULL, NULL);
 	g_signal_connect(geany_object, "document-save", G_CALLBACK(on_document_save), NULL);
-*/
 }
 
 

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2008-12-06 12:12:00 UTC (rev 3330)
+++ trunk/src/ui_utils.c	2008-12-06 12:28:21 UTC (rev 3331)
@@ -1519,9 +1519,17 @@
 	else
 	{
 		gchar *utf8 = utils_get_utf8_from_locale(file_name);
+		gchar *base_name = g_path_get_basename(file_name);
+		gchar *global_file = g_build_filename(app->datadir, base_name, NULL);
+		gchar *global_content = NULL;
 
-		document_new_file(utf8, NULL, NULL);
-		g_free(utf8);
+		/* if the requested file doesn't exist in the user's config dir, try loading the file
+		 * from the global data directory and use its contents for the newly created file */
+		if (g_file_test(global_file, G_FILE_TEST_EXISTS))
+			g_file_get_contents(global_file, &global_content, NULL, NULL);
+
+		document_new_file(utf8, NULL, global_content);
+		utils_free_pointers(4, utf8, base_name, global_file, global_content, NULL);
 	}
 }
 
@@ -1572,13 +1580,14 @@
 	GtkIconSet *icon_set;
 	GtkIconFactory *factory = gtk_icon_factory_new();
 	GdkPixbuf *pb;
-	gsize i;
+	gsize i, len;
 	GeanyStockItem items[] =
 	{
-		{ { GEANY_STOCK_SAVE_ALL, _("Save All"), 0, 0, GETTEXT_PACKAGE}, GEANY_IMAGE_SAVE_ALL }
+		{ { GEANY_STOCK_SAVE_ALL, _("Save All"), 0, 0, GETTEXT_PACKAGE }, GEANY_IMAGE_SAVE_ALL }
 	};
 
-	for (i = 0; i < G_N_ELEMENTS(items); i++)
+	len = G_N_ELEMENTS(items);
+	for (i = 0; i < len; i++)
 	{
 		pb = ui_new_pixbuf_from_inline(items[i].image_id, FALSE);
 		icon_set = gtk_icon_set_new_from_pixbuf(pb);
@@ -1588,7 +1597,7 @@
 		gtk_icon_set_unref(icon_set);
 		g_object_unref(pb);
 	}
-	gtk_stock_add((GtkStockItem *) items, G_N_ELEMENTS(items));
+	gtk_stock_add((GtkStockItem *) items, len);
 	gtk_icon_factory_add_default(factory);
 	g_object_unref(factory);
 }


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