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.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1903 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2007-09-25 16:21:35 +00:00
parent b078c1647d
commit db980f3f83
4 changed files with 56 additions and 7 deletions

View File

@ -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>

View File

@ -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 @@ PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."),
#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 @@ static void write_data(const gchar *filename, const gchar *data)
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);

View File

@ -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 @@ typedef struct UIUtilsFuncs
{
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 @@ SupportFuncs;
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);
}

View File

@ -134,9 +134,28 @@ static UtilsFuncs utils_funcs = {
&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 @@ static SupportFuncs support_funcs = {
&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
};