Revision: 3524 http://geany.svn.sourceforge.net/geany/?rev=3524&view=rev Author: eht16 Date: 2009-01-28 19:30:18 +0000 (Wed, 28 Jan 2009)
Log Message: ----------- Rename utils_start_browser() in utils_open_browser() and add it to the plugin API. Add plugin symbol plugin_help() which is called by Geany when the plugin should show its documentation (if any). This symbol is optional, plugins can omit it if not needed. Add a Help button next to the Configure button in the plugin manager dialog to easily open a plugin's documentation if available.
Modified Paths: -------------- trunk/ChangeLog trunk/doc/pluginsymbols.c trunk/plugins/geanyfunctions.h trunk/src/about.c trunk/src/build.c trunk/src/callbacks.c trunk/src/plugindata.h trunk/src/plugins.c trunk/src/utils.c trunk/src/utils.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/ChangeLog 2009-01-28 19:30:18 UTC (rev 3524) @@ -14,6 +14,16 @@ * doc/plugins.dox, plugins/demoplugin.h: Mention necessary header includes in the plugin signal descriptions. Add missing header includes for the demoplugin. + * doc/pluginsymbols.c, plugins/geanyfunctions.h, src/about.c, + src/build.c, src/callbacks.c, src/plugindata.h, src/plugins.c, + src/utils.c, src/utils.h: + Rename utils_start_browser() in utils_open_browser() and add it to + the plugin API. + Add plugin symbol plugin_help() which is called by Geany when the + plugin should show its documentation (if any). This symbol is + optional, plugins can omit it if not needed. + Add a Help button next to the Configure button in the plugin manager + dialog to easily open a plugin's documentation if available.
2009-01-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/doc/pluginsymbols.c =================================================================== --- trunk/doc/pluginsymbols.c 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/doc/pluginsymbols.c 2009-01-28 19:30:18 UTC (rev 3524) @@ -97,3 +97,9 @@ * everything done in plugin_init() - e.g. destroy menu items, free memory. */ void plugin_cleanup();
+/** Called whenever the plugin should show its documentation (if any). This may open a dialog, + * a browser with a website or a local installed HTML help file(see utils_start_browser()) + * or something else. + * Can be omitted when not needed. */ +void plugin_help(); +
Modified: trunk/plugins/geanyfunctions.h =================================================================== --- trunk/plugins/geanyfunctions.h 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/plugins/geanyfunctions.h 2009-01-28 19:30:18 UTC (rev 3524) @@ -164,6 +164,8 @@ geany_functions->p_utils->str_casecmp #define utils_get_date_time \ geany_functions->p_utils->get_date_time +#define utils_open_browser \ + geany_functions->p_utils->open_browser #define ui_dialog_vbox_new \ geany_functions->p_ui->dialog_vbox_new #define ui_frame_new_with_alignment \
Modified: trunk/src/about.c =================================================================== --- trunk/src/about.c 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/src/about.c 2009-01-28 19:30:18 UTC (rev 3524) @@ -442,6 +442,6 @@
static void homepage_clicked(GtkButton *button, gpointer data) { - utils_start_browser(data); + utils_open_browser(data); }
Modified: trunk/src/build.c =================================================================== --- trunk/src/build.c 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/src/build.c 2009-01-28 19:30:18 UTC (rev 3524) @@ -1924,7 +1924,7 @@ if (use_builtin) { gchar *uri = g_strconcat("file:///", g_path_skip_root(doc->file_name), NULL); - utils_start_browser(uri); + utils_open_browser(uri); g_free(uri);
return TRUE;
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/src/callbacks.c 2009-01-28 19:30:18 UTC (rev 3524) @@ -1274,7 +1274,7 @@ uri = g_strconcat(GEANY_HOMEPAGE, "manual/", VERSION, "/index.html", NULL); }
- utils_start_browser(uri); + utils_open_browser(uri); g_free(uri); }
@@ -1291,7 +1291,7 @@ on_website1_activate (GtkMenuItem *menuitem, gpointer user_data) { - utils_start_browser(GEANY_HOMEPAGE); + utils_open_browser(GEANY_HOMEPAGE); }
Modified: trunk/src/plugindata.h =================================================================== --- trunk/src/plugindata.h 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/src/plugindata.h 2009-01-28 19:30:18 UTC (rev 3524) @@ -45,7 +45,7 @@ enum { /** The Application Programming Interface (API) version, incremented * whenever any plugin data types are modified or appended to. */ - GEANY_API_VERSION = 129, + GEANY_API_VERSION = 130,
/** The Application Binary Interface (ABI) version, incremented whenever * existing fields in the plugin data types have to be changed or reordered. */ @@ -353,6 +353,7 @@ GError **error); gint (*str_casecmp) (const gchar *s1, const gchar *s2); gchar* (*get_date_time) (const gchar *format, time_t *time_to_use); + void (*open_browser) (const gchar *uri); } UtilsFuncs;
Modified: trunk/src/plugins.c =================================================================== --- trunk/src/plugins.c 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/src/plugins.c 2009-01-28 19:30:18 UTC (rev 3524) @@ -91,6 +91,7 @@
void (*init) (GeanyData *data); /* Called when the plugin is enabled */ GtkWidget* (*configure) (GtkDialog *dialog); /* plugin configure dialog, optional */ + void (*help) (void); /* Called when the plugin should show some help, optional */ void (*cleanup) (void); /* Called when the plugin is disabled or when Geany exits */ } Plugin; @@ -212,7 +213,8 @@ &utils_spawn_sync, &utils_spawn_async, &utils_str_casecmp, - &utils_get_date_time + &utils_get_date_time, + &utils_open_browser };
static UIUtilsFuncs uiutils_funcs = { @@ -536,6 +538,7 @@
/* store some function pointers for later use */ g_module_symbol(plugin->module, "plugin_configure", (void *) &plugin->configure); + g_module_symbol(plugin->module, "plugin_help", (void *) &plugin->help); g_module_symbol(plugin->module, "plugin_cleanup", (void *) &plugin->cleanup); if (plugin->cleanup == NULL) { @@ -964,7 +967,9 @@ PLUGIN_COLUMN_NAME, PLUGIN_COLUMN_FILE, PLUGIN_COLUMN_PLUGIN, - PLUGIN_N_COLUMNS + PLUGIN_N_COLUMNS, + PM_BUTTON_CONFIGURE, + PM_BUTTON_HELP };
typedef struct @@ -974,6 +979,7 @@ GtkListStore *store; GtkWidget *description_label; GtkWidget *configure_button; + GtkWidget *help_button; } PluginManagerWidgets;
@@ -1005,6 +1011,8 @@
gtk_widget_set_sensitive(pm_widgets.configure_button, p->configure != NULL && g_list_find(active_plugin_list, p) != NULL); + gtk_widget_set_sensitive(pm_widgets.help_button, + p->help != NULL && g_list_find(active_plugin_list, p) != NULL); } } } @@ -1032,7 +1040,9 @@
/* unload plugin module */ if (!state) - keybindings_write_to_file(); /* save shortcuts (only need this group, but it doesn't take long) */ + /* save shortcuts (only need this group, but it doesn't take long) */ + keybindings_write_to_file(); + plugin_free(p);
/* reload plugin module and initialize it if item is checked */ @@ -1149,7 +1159,7 @@ }
-void pm_on_configure_button_clicked(GtkButton *button, gpointer user_data) +void pm_on_plugin_button_clicked(GtkButton *button, gpointer user_data) { GtkTreeModel *model; GtkTreeSelection *selection; @@ -1163,7 +1173,10 @@
if (p != NULL) { - configure_plugin(p); + if (GPOINTER_TO_INT(user_data) == PM_BUTTON_CONFIGURE) + configure_plugin(p); + else if (GPOINTER_TO_INT(user_data) == PM_BUTTON_HELP && p->help != NULL) + p->help(); } } } @@ -1228,8 +1241,13 @@ pm_widgets.configure_button = gtk_button_new_from_stock(GTK_STOCK_PREFERENCES); gtk_widget_set_sensitive(pm_widgets.configure_button, FALSE); g_signal_connect(pm_widgets.configure_button, "clicked", - G_CALLBACK(pm_on_configure_button_clicked), NULL); + G_CALLBACK(pm_on_plugin_button_clicked), GINT_TO_POINTER(PM_BUTTON_CONFIGURE));
+ pm_widgets.help_button = gtk_button_new_from_stock(GTK_STOCK_HELP); + gtk_widget_set_sensitive(pm_widgets.help_button, FALSE); + g_signal_connect(pm_widgets.help_button, "clicked", + G_CALLBACK(pm_on_plugin_button_clicked), GINT_TO_POINTER(PM_BUTTON_HELP)); + label2 = gtk_label_new(_("<b>Plugin details:</b>")); gtk_label_set_use_markup(GTK_LABEL(label2), TRUE); gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5); @@ -1243,13 +1261,14 @@
hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), label2, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox), pm_widgets.help_button, FALSE, FALSE, 4); gtk_box_pack_start(GTK_BOX(hbox), pm_widgets.configure_button, FALSE, FALSE, 0);
- label_vbox = gtk_vbox_new(FALSE, 0); + label_vbox = gtk_vbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(label_vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(label_vbox), desc_win, FALSE, FALSE, 0);
- vbox2 = gtk_vbox_new(FALSE, 6); + vbox2 = gtk_vbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 5); gtk_box_pack_start(GTK_BOX(vbox2), swin, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(vbox2), label_vbox, FALSE, FALSE, 0);
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/src/utils.c 2009-01-28 19:30:18 UTC (rev 3524) @@ -59,13 +59,26 @@ #include "utils.h"
-void utils_start_browser(const gchar *uri) +/** + * Tries to open the given URI in a browser. + * On Windows, the system's default browser is opened. + * On non-Windows systems, the browser command set in the preferences dialog is used. In case + * that fails or it is unset, @a xdg-open is used as fallback as well as some other known + * browsers. + * + * @param uri The URI to open in the web browser. + **/ +void utils_open_browser(const gchar *uri) { #ifdef G_OS_WIN32 + g_return_if_fail(uri != NULL); win32_open_browser(uri); #else - gchar *cmdline = g_strconcat(tool_prefs.browser_cmd, " ", uri, NULL); + gchar *cmdline;
+ g_return_if_fail(uri != NULL); + + cmdline = g_strconcat(tool_prefs.browser_cmd, " ", uri, NULL); if (! g_spawn_command_line_async(cmdline, NULL)) { const gchar *argv[3];
Modified: trunk/src/utils.h =================================================================== --- trunk/src/utils.h 2009-01-28 17:57:16 UTC (rev 3523) +++ trunk/src/utils.h 2009-01-28 19:30:18 UTC (rev 3524) @@ -54,7 +54,7 @@ ptr < &ptr_array->pdata[ptr_array->len]; ++ptr, item = *ptr)
-void utils_start_browser(const gchar *uri); +void utils_open_browser(const gchar *uri);
gint utils_get_line_endings(const gchar* buffer, glong size);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.