SF.net SVN: geany: [1903] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Sep 25 16:21:35 UTC 2007


Revision: 1903
          http://geany.svn.sourceforge.net/geany/?rev=1903&view=rev
Author:   ntrel
Date:     2007-09-25 09:21:35 -0700 (Tue, 25 Sep 2007)

Log Message:
-----------
Add ui->set_statusbar() to the plugin API.
Make plugin function msgwin->status_add() not set the statusbar - but
ui->set_statusbar() can now be used to do both with the log argument.
After Geany 0.12 this is how the core versions of those functions
will work, so the status window can be set independently.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/plugins/export.c
    trunk/src/plugindata.h
    trunk/src/plugins.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-09-25 15:19:47 UTC (rev 1902)
+++ trunk/ChangeLog	2007-09-25 16:21:35 UTC (rev 1903)
@@ -9,6 +9,12 @@
  * TODO:
    Updated for project and plugins improvements, and others.
    Added wishlist items (which are unlikely to be worked on).
+ * plugins/export.c, src/plugindata.h, src/plugins.c:
+   Add ui->set_statusbar() to the plugin API.
+   Make plugin function msgwin->status_add() not set the statusbar - but
+   ui->set_statusbar() can now be used to do both with the log argument.
+   After Geany 0.12 this is how the core versions of those functions
+   will work, so the status window can be set independently.
 
 
 2007-09-24  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/plugins/export.c
===================================================================
--- trunk/plugins/export.c	2007-09-25 15:19:47 UTC (rev 1902)
+++ trunk/plugins/export.c	2007-09-25 16:21:35 UTC (rev 1903)
@@ -37,7 +37,7 @@
 PluginFields	*plugin_fields;
 GeanyData		*geany_data;
 
-VERSION_CHECK(12)
+VERSION_CHECK(20)
 PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."), "0.1")
 
 #define doc_array	geany_data->doc_array
@@ -45,7 +45,7 @@
 #define utils		geany_data->utils
 #define support		geany_data->support
 #define dialogs		geany_data->dialogs
-#define msgwin		geany_data->msgwindow
+#define ui			geany_data->ui
 
 #define ROTATE_RGB(color) \
 	(((color) & 0xFF0000) >> 16) + ((color) & 0x00FF00) + (((color) & 0x0000FF) << 16)
@@ -266,9 +266,9 @@
 	gchar *utf8_filename = utils->get_utf8_from_locale(filename);
 
 	if (error_nr == 0)
-		msgwin->status_add(_("Document successfully exported as '%s'."), utf8_filename);
+		ui->set_statusbar(TRUE, _("Document successfully exported as '%s'."), utf8_filename);
 	else
-		msgwin->status_add(_("File '%s' could not be written (%s)."),
+		ui->set_statusbar(TRUE, _("File '%s' could not be written (%s)."),
 			utf8_filename, g_strerror(error_nr));
 
 	g_free(utf8_filename);

Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h	2007-09-25 15:19:47 UTC (rev 1902)
+++ trunk/src/plugindata.h	2007-09-25 16:21:35 UTC (rev 1903)
@@ -71,7 +71,7 @@
 
 /* The API version should be incremented whenever any plugin data types below are
  * modified. */
-static const gint api_version = 19;
+static const gint api_version = 20;
 
 /* The ABI version should be incremented whenever existing fields in the plugin
  * data types below have to be changed or reordered. It should stay the same if fields
@@ -248,6 +248,9 @@
 {
 	GtkWidget*	(*dialog_vbox_new) (GtkDialog *dialog);
 	GtkWidget*	(*frame_new_with_alignment) (const gchar *label_text, GtkWidget **alignment);
+
+	/* set_statusbar() also appends to the message window status tab if log is TRUE. */
+	void		(*set_statusbar) (gboolean log, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
 }
 UIUtilsFuncs;
 
@@ -267,6 +270,7 @@
 
 typedef struct MsgWinFuncs
 {
+	/* status_add() does not set the status bar - use ui->set_statusbar() instead. */
 	void		(*status_add) (const gchar *format, ...);
 	void		(*compiler_add) (gint msg_color, const gchar *format, ...) G_GNUC_PRINTF (2, 3);
 }

Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c	2007-09-25 15:19:47 UTC (rev 1902)
+++ trunk/src/plugins.c	2007-09-25 16:21:35 UTC (rev 1903)
@@ -134,9 +134,28 @@
 	&utils_remove_ext_from_filename
 };
 
+
+/* This is a temporary function for the plugin API for Geany 0.12.
+ * In future, ui_set_statusbar() will act like this. */
+static void plugin_ui_set_statusbar(gboolean log, const gchar *format, ...)
+{
+	gchar string[512];
+	va_list args;
+
+	va_start(args, format);
+	g_vsnprintf(string, 512, format, args);
+	va_end(args);
+
+	if (log)
+		msgwin_status_add("%s", string);	// currently does both
+	else
+		ui_set_statusbar("%s", string);
+}
+
 static UIUtilsFuncs uiutils_funcs = {
 	&ui_dialog_vbox_new,
-	&ui_frame_new_with_alignment
+	&ui_frame_new_with_alignment,
+	&plugin_ui_set_statusbar
 };
 
 static DialogFuncs dialog_funcs = {
@@ -148,8 +167,28 @@
 	&lookup_widget
 };
 
+
+/* This is a temporary function for the plugin API for Geany 0.12.
+ * In future, msgwin_status_add() will act like this. */
+static void plugin_msgwin_status_add(const gchar *format, ...)
+{
+	gchar string[512];
+	va_list args;
+	gboolean suppress;
+
+	va_start(args, format);
+	g_vsnprintf(string, 512, format, args);
+	va_end(args);
+
+	// hack to prevent setting the status bar
+	suppress = prefs.suppress_status_messages;
+	prefs.suppress_status_messages = TRUE;
+	msgwin_status_add("%s", string);
+	prefs.suppress_status_messages = suppress;
+}
+
 static MsgWinFuncs msgwin_funcs = {
-	&msgwin_status_add,
+	&plugin_msgwin_status_add,
 	&msgwin_compiler_add_fmt
 };
 


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