Revision: 1964 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1964&view=re... Author: codebrainz Date: 2011-03-08 09:12:58 +0000 (Tue, 08 Mar 2011)
Log Message: ----------- Fix bug in update_editor_menu callback.
Callback for update_editor_menu signal was adding the entire selection of text into the GtkMenuItem label. Fix ellipsizes selections/tags which are longer than DHPLUG_MAX_LABEL_TAG for display in the editor context menu.
Make context menu string translatable.
Modified Paths: -------------- trunk/geany-plugins/devhelp/src/devhelpplugin.c trunk/geany-plugins/devhelp/src/devhelpplugin.h
Modified: trunk/geany-plugins/devhelp/src/devhelpplugin.c =================================================================== --- trunk/geany-plugins/devhelp/src/devhelpplugin.c 2011-03-08 03:32:28 UTC (rev 1963) +++ trunk/geany-plugins/devhelp/src/devhelpplugin.c 2011-03-08 09:12:58 UTC (rev 1964) @@ -122,19 +122,31 @@ */ static void on_editor_menu_popup(GtkWidget *widget, gpointer user_data) { + gchar *label_tag = NULL; gchar *curword = NULL; gchar *new_label = NULL; DevhelpPlugin *dhplug = user_data; curword = devhelp_plugin_get_current_tag(); + if (curword == NULL) gtk_widget_set_sensitive(dhplug->editor_menu_item, FALSE); else { - gtk_widget_set_sensitive(dhplug->editor_menu_item, TRUE); - new_label = g_strdup_printf("Search Devhelp for '%s'", curword); + if (strlen(curword) > DHPLUG_MAX_LABEL_TAG) { + label_tag = g_strndup(curword, DHPLUG_MAX_LABEL_TAG-3); + new_label = g_strdup_printf(_("Search Devhelp for: %s..."), + g_strstrip(label_tag)); + } + else { + label_tag = g_strndup(curword, DHPLUG_MAX_LABEL_TAG); + new_label = g_strdup_printf(_("Search Devhelp for %s"), + g_strstrip(label_tag)); + } gtk_menu_item_set_label(GTK_MENU_ITEM(dhplug->editor_menu_item), new_label); g_free(new_label); + g_free(label_tag); + gtk_widget_set_sensitive(dhplug->editor_menu_item, TRUE); } g_free(curword);
Modified: trunk/geany-plugins/devhelp/src/devhelpplugin.h =================================================================== --- trunk/geany-plugins/devhelp/src/devhelpplugin.h 2011-03-08 03:32:28 UTC (rev 1963) +++ trunk/geany-plugins/devhelp/src/devhelpplugin.h 2011-03-08 09:12:58 UTC (rev 1964) @@ -33,6 +33,8 @@
#define DHPLUG_WEBVIEW_HOME_FILE DHPLUG_DATA_DIR"/home.html"
+#define DHPLUG_MAX_LABEL_TAG 30 + #define DEVHELP_TYPE_PLUGIN (devhelp_plugin_get_type()) #define DEVHELP_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\ DEVHELP_TYPE_PLUGIN, DevhelpPlugin))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.