Revision: 4436 http://geany.svn.sourceforge.net/geany/?rev=4436&view=rev Author: eht16 Date: 2009-11-22 18:25:09 +0000 (Sun, 22 Nov 2009)
Log Message: ----------- Use separate tooltips for toolbar menu buttons and their attached drop-down arrows.
Modified Paths: -------------- trunk/ChangeLog trunk/src/geanymenubuttonaction.c trunk/src/geanymenubuttonaction.h trunk/src/toolbar.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-11-19 18:11:56 UTC (rev 4435) +++ trunk/ChangeLog 2009-11-22 18:25:09 UTC (rev 4436) @@ -1,3 +1,11 @@ +2009-11-22 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * src/toolbar.c, src/geanymenubuttonaction.c, + src/geanymenubuttonaction.h: + Use separate tooltips for toolbar menu buttons and their attached + drop-down arrows. + + 2009-11-19 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/geanymenubuttonaction.c:
Modified: trunk/src/geanymenubuttonaction.c =================================================================== --- trunk/src/geanymenubuttonaction.c 2009-11-19 18:11:56 UTC (rev 4435) +++ trunk/src/geanymenubuttonaction.c 2009-11-22 18:25:09 UTC (rev 4436) @@ -39,10 +39,18 @@ struct _GeanyMenubuttonActionPrivate { GtkWidget *menu; + + gchar *tooltip_arrow; };
enum { + PROP_0, + PROP_TOOLTIP_ARROW +}; + +enum +{ BUTTON_CLICKED, LAST_SIGNAL }; @@ -57,6 +65,7 @@ GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(object);
g_object_unref(priv->menu); + g_free(priv->tooltip_arrow);
(* G_OBJECT_CLASS(geany_menu_button_action_parent_class)->finalize)(object); } @@ -68,18 +77,75 @@ }
+static void set_arrow_tooltip(GtkMenuToolButton *button, const gchar *tooltip) +{ +#if GTK_CHECK_VERSION(2, 12, 0) + gtk_menu_tool_button_set_arrow_tooltip_text(button, tooltip); +#else + static GtkTooltips *tooltips = NULL; + + if (G_UNLIKELY(tooltips == NULL)) + tooltips = gtk_tooltips_new(); + + gtk_menu_tool_button_set_arrow_tooltip(button, tooltips, tooltip, NULL); +#endif +} + + +static void geany_menu_button_action_set_property(GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + switch (prop_id) + { + case PROP_TOOLTIP_ARROW: + { + GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(object); + g_free(priv->tooltip_arrow); + priv->tooltip_arrow = g_value_dup_string(value); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static GtkWidget *geany_menu_button_action_create_tool_item(GtkAction *action) +{ + GtkWidget *toolitem; + GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action); + + toolitem = g_object_new(GTK_TYPE_MENU_TOOL_BUTTON, NULL); + set_arrow_tooltip(GTK_MENU_TOOL_BUTTON(toolitem), priv->tooltip_arrow); + + return toolitem; +} + + static void geany_menu_button_action_class_init(GeanyMenubuttonActionClass *klass) { GtkActionClass *action_class = GTK_ACTION_CLASS(klass); GObjectClass *g_object_class = G_OBJECT_CLASS(klass);
g_object_class->finalize = geany_menu_button_action_finalize; + g_object_class->set_property = geany_menu_button_action_set_property;
action_class->activate = delegate_button_activated; + action_class->create_tool_item = geany_menu_button_action_create_tool_item; action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
g_type_class_add_private(klass, sizeof(GeanyMenubuttonActionPrivate));
+ g_object_class_install_property(g_object_class, + PROP_TOOLTIP_ARROW, + g_param_spec_string( + "tooltip-arrow", + "Arrow tooltip", + "A special tooltip for the arrow button", + "", + G_PARAM_WRITABLE)); + signals[BUTTON_CLICKED] = g_signal_new("button-clicked", G_TYPE_FROM_CLASS(klass), (GSignalFlags) 0, @@ -93,19 +159,23 @@
static void geany_menu_button_action_init(GeanyMenubuttonAction *action) { - /* nothing to do */ + GeanyMenubuttonActionPrivate *priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action); + priv->tooltip_arrow = NULL; + priv->menu = NULL; }
GtkAction *geany_menu_button_action_new(const gchar *name, const gchar *label, const gchar *tooltip, + const gchar *tooltip_arrow, const gchar *stock_id) { GtkAction *action = g_object_new(GEANY_MENU_BUTTON_ACTION_TYPE, "name", name, "label", label, "tooltip", tooltip, + "tooltip-arrow", tooltip_arrow, "stock-id", stock_id, NULL);
Modified: trunk/src/geanymenubuttonaction.h =================================================================== --- trunk/src/geanymenubuttonaction.h 2009-11-19 18:11:56 UTC (rev 4435) +++ trunk/src/geanymenubuttonaction.h 2009-11-22 18:25:09 UTC (rev 4436) @@ -52,6 +52,7 @@ GtkAction* geany_menu_button_action_new (const gchar *name, const gchar *label, const gchar *tooltip, + const gchar *tooltip_arrow, const gchar *stock_id); GtkWidget* geany_menu_button_action_get_menu (GeanyMenubuttonAction *action);
Modified: trunk/src/toolbar.c =================================================================== --- trunk/src/toolbar.c 2009-11-19 18:11:56 UTC (rev 4435) +++ trunk/src/toolbar.c 2009-11-22 18:25:09 UTC (rev 4436) @@ -331,17 +331,27 @@ gtk_action_group_add_actions(group, ui_entries, ui_entries_n, NULL);
/* Create our custom actions */ - action_new = geany_menu_button_action_new("New", NULL, _("Create a new file"), GTK_STOCK_NEW); + action_new = geany_menu_button_action_new( + "New", NULL, + _("Create a new file"), + _("Create a new file from a template"), + GTK_STOCK_NEW); g_signal_connect(action_new, "button-clicked", G_CALLBACK(on_toolbutton_new_clicked), NULL); gtk_action_group_add_action(group, action_new);
action_open = geany_menu_button_action_new( - "Open", NULL, _("Open an existing file"), GTK_STOCK_OPEN); + "Open", NULL, + _("Open an existing file"), + _("Open a recent file"), + GTK_STOCK_OPEN); g_signal_connect(action_open, "button-clicked", G_CALLBACK(on_toolbutton_open_clicked), NULL); gtk_action_group_add_action(group, action_open);
action_build = geany_menu_button_action_new( - "Build", NULL, _("Build the current file"), GEANY_STOCK_BUILD); + "Build", NULL, + _("Build the current file"), + _("Choose more build actions"), + GEANY_STOCK_BUILD); g_signal_connect(action_build, "button-clicked", G_CALLBACK(build_toolbutton_build_clicked), NULL); gtk_action_group_add_action(group, action_build);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.