diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2012-01-05 20:22:09 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2012-01-05 20:22:09 +0000 |
| commit | 5f739493fd73a6ae099e3929e8934bb8d3fe87cd (patch) | |
| tree | 3256109cd5af8e5acadd35e4f8cbb2ee75b4b297 /src | |
| parent | GTK 2.20 compat for interface.cpp (diff) | |
| download | inkscape-5f739493fd73a6ae099e3929e8934bb8d3fe87cd.tar.gz inkscape-5f739493fd73a6ae099e3929e8934bb8d3fe87cd.zip | |
add toolbutton menu action type. now the add extremum node buttons are somewhat subbuttons of the insert node button...
(bzr r10849)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ink-action.cpp | 71 | ||||
| -rw-r--r-- | src/ink-action.h | 37 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 29 |
3 files changed, 126 insertions, 11 deletions
diff --git a/src/ink-action.cpp b/src/ink-action.cpp index d26b038f8..becf5971a 100644 --- a/src/ink-action.cpp +++ b/src/ink-action.cpp @@ -675,3 +675,74 @@ static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ) return item; } + + +/* --------------------------------------------------------------- */ +/* --------------------------------------------------------------- */ +/* --------------------------------------------------------------- */ +/* --------------------------------------------------------------- */ + +// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 + +static void ink_tool_menu_action_init (InkToolMenuAction *tma); +static void ink_tool_menu_action_class_init (InkToolMenuActionClass *klass); + +GType +ink_tool_menu_action_get_type (void) +{ + static GType myType = 0; + if (! myType) + { + static const GTypeInfo myInfo = + { + sizeof (InkToolMenuActionClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ink_tool_menu_action_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (InkToolMenuAction), + 0, /* n_preallocs */ + (GInstanceInitFunc) ink_tool_menu_action_init, + NULL + }; + + myType = g_type_register_static( INK_ACTION_TYPE, "InkToolMenuAction", &myInfo, (GTypeFlags)0 ); + } + + return myType; +} + +static void +ink_tool_menu_action_class_init (InkToolMenuActionClass *klass) +{ + GtkActionClass *action_class = GTK_ACTION_CLASS (klass); + action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON; +} + +static void +ink_tool_menu_action_init (InkToolMenuAction* /*tma*/) +{ +} + +InkToolMenuAction * +ink_tool_menu_action_new (const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *inkId, + Inkscape::IconSize size ) +{ + g_return_val_if_fail (name != NULL, NULL); + + GObject* obj = (GObject*)g_object_new( INK_TOOL_MENU_ACTION_TYPE, + "name", name, + "label", label, + "tooltip", tooltip, + "iconId", inkId, + "iconSize", size, + NULL ); + + InkToolMenuAction* action = INK_TOOL_MENU_ACTION( obj ); + + return action; +} diff --git a/src/ink-action.h b/src/ink-action.h index c957f0f5c..1d4106681 100644 --- a/src/ink-action.h +++ b/src/ink-action.h @@ -118,6 +118,43 @@ InkRadioAction* ink_radio_action_new( const gchar *name, Inkscape::IconSize size ); +/* --------------------------------------------------------------- */ +/* --------------------------------------------------------------- */ +/* --------------------------------------------------------------- */ +/* --------------------------------------------------------------- */ + +// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 + +#define INK_TOOL_MENU_ACTION_TYPE ( ink_tool_menu_action_get_type() ) +#define INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuAction) ) +#define INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) ) +#define IS_INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOOL_MENU_ACTION_TYPE) ) +#define IS_INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOOL_MENU_ACTION_TYPE) ) +#define INK_TOOL_MENU_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) ) + +typedef struct _InkToolMenuAction InkToolMenuAction; +typedef struct _InkToolMenuActionClass InkToolMenuActionClass; +typedef struct _InkToolMenuActionPrivate InkToolMenuActionPrivate; + +struct _InkToolMenuAction +{ + InkAction action; +}; + +struct _InkToolMenuActionClass +{ + InkActionClass parent_class; +}; + +GType ink_tool_menu_action_get_type( void ); + +InkToolMenuAction* ink_tool_menu_action_new( const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *inkId, + Inkscape::IconSize size ); + + G_END_DECLS diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 3960f2349..b6e8df259 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -285,11 +285,14 @@ static gchar const * ui_descr = " <toolbar name='NodeToolbar'>" " <separator />" - " <toolitem action='NodeInsertAction' />" - " <toolitem action='NodeInsertActionMinX' />" - " <toolitem action='NodeInsertActionMaxX' />" - " <toolitem action='NodeInsertActionMinY' />" - " <toolitem action='NodeInsertActionMaxY' />" + " <toolitem action='NodeInsertAction'>" + " <menu action='NodeInsertActionMenu'>" + " <menuitem action='NodeInsertActionMinX' />" + " <menuitem action='NodeInsertActionMaxX' />" + " <menuitem action='NodeInsertActionMinY' />" + " <menuitem action='NodeInsertActionMaxY' />" + " </menu>" + " </toolitem>" " <toolitem action='NodeDeleteAction' />" " <separator />" " <toolitem action='NodeJoinAction' />" @@ -1408,14 +1411,18 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); { - InkAction* inky = ink_action_new( "NodeInsertAction", - _("Insert node"), - _("Insert new nodes into selected segments"), - INKSCAPE_ICON("node-add"), - secondarySize ); - g_object_set( inky, "short_label", _("Insert"), NULL ); + InkToolMenuAction* inky = ink_tool_menu_action_new( "NodeInsertAction", + _("Insert node"), + _("Insert new nodes into selected segments"), + INKSCAPE_ICON("node-add"), + secondarySize ); + g_object_set( INK_ACTION(inky), "short_label", _("Insert"), NULL ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add), 0 ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + GtkToolItem *menu_tool_button = gtk_menu_tool_button_new (NULL, NULL); + gtk_activatable_set_related_action (GTK_ACTIVATABLE (menu_tool_button), GTK_ACTION(inky)); + // also create dummy menu action: + gtk_action_group_add_action( mainActions, gtk_action_new("NodeInsertActionMenu", NULL, NULL, NULL) ); } { |
