139
164
switch ( propId ) {
140
165
case PROP_INK_ID:
142
// gchar* tmp = action->private_data->iconId;
143
// action->private_data->iconId = g_value_dup_string( value );
167
gchar* tmp = action->private_data->iconId;
168
action->private_data->iconId = g_value_dup_string( value );
148
173
case PROP_INK_SIZE:
150
// action->private_data->iconSize = g_value_get_( value );
175
action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
155
181
G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
186
#include <gtk/gtkstock.h>
159
188
static GtkWidget* ink_action_create_menu_item( GtkAction* action )
190
InkAction* act = INK_ACTION( action );
161
191
GtkWidget* item = 0;
162
g_message("INK ACTION CREATE MENU ITEM");
163
item = gInkActionParentClass->create_menu_item( action );
193
if ( act->private_data->iconId ) {
195
g_object_get( G_OBJECT(act), "label", &label, NULL );
197
item = gtk_image_menu_item_new_with_mnemonic( label );
198
GtkWidget* child = sp_icon_new( Inkscape::ICON_SIZE_MENU, act->private_data->iconId );
199
// TODO this work-around is until SPIcon will live properly inside of a popup menu
200
if ( SP_IS_ICON(child) ) {
201
SPIcon* icon = SP_ICON(child);
202
sp_icon_fetch_pixbuf( icon );
203
GdkPixbuf* target = gtk_action_is_sensitive(action) ? icon->pb : icon->pb_faded;
205
child = gtk_image_new_from_pixbuf( target );
206
gtk_widget_destroy( GTK_WIDGET(icon) );
209
gtk_widget_show_all( child );
210
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), child );
215
item = gInkActionParentClass->create_menu_item( action );
167
221
static GtkWidget* ink_action_create_tool_item( GtkAction* action )
170
g_message("INK ACTION CREATE TOOL ITEM");
173
//item = gInkActionParentClass->create_tool_item( action );
174
GtkTooltips *tt = gtk_tooltips_new();
175
GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION,
176
SP_BUTTON_TYPE_NORMAL,
179
_("Use the pressure of the input device to alter the width of the pen"),
181
//g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (sp_ddc_pressure_state_changed), NULL);
182
//gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("tools.calligraphic", "usepressure", 1));
183
item = GTK_WIDGET(gtk_tool_item_new());
184
gtk_container_add( GTK_CONTAINER(item), button );
223
InkAction* act = INK_ACTION( action );
224
GtkWidget* item = gInkActionParentClass->create_tool_item(action);
226
if ( act->private_data->iconId ) {
227
if ( GTK_IS_TOOL_BUTTON(item) ) {
228
GtkToolButton* button = GTK_TOOL_BUTTON(item);
230
GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
231
gtk_tool_button_set_icon_widget( button, child );
233
// For now trigger a warning but don't do anything else
234
GtkToolButton* button = GTK_TOOL_BUTTON(item);
239
// TODO investigate if needed
186
240
gtk_widget_show_all( item );
369
427
static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action )
371
429
InkToggleAction* act = INK_TOGGLE_ACTION( action );
372
431
GtkWidget* item = gInkToggleActionParentClass->parent_class.create_tool_item(action);
432
if ( GTK_IS_TOOL_BUTTON(item) ) {
433
GtkToolButton* button = GTK_TOOL_BUTTON(item);
434
if ( act->private_data->iconId ) {
435
GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
436
gtk_tool_button_set_icon_widget( button, child );
439
g_object_get (G_OBJECT(action), "short_label", &label, NULL);
440
gtk_tool_button_set_label( button, label );
443
// For now trigger a warning but don't do anything else
444
GtkToolButton* button = GTK_TOOL_BUTTON(item);
447
gtk_widget_show_all( item );
453
static void ink_toggle_action_update_icon( InkToggleAction* action )
456
GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) );
458
if ( GTK_IS_TOOL_ITEM(proxies->data) ) {
459
if ( GTK_IS_TOOL_BUTTON(proxies->data) ) {
460
GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);
462
GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );
463
gtk_widget_show_all( child );
464
gtk_tool_button_set_icon_widget( button, child );
468
proxies = g_slist_next( proxies );
474
/* --------------------------------------------------------------- */
475
/* --------------------------------------------------------------- */
476
/* --------------------------------------------------------------- */
477
/* --------------------------------------------------------------- */
480
static void ink_radio_action_class_init( InkRadioActionClass* klass );
481
static void ink_radio_action_init( InkRadioAction* action );
482
static void ink_radio_action_finalize( GObject* obj );
483
static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
484
static void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec );
486
static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action );
487
static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action );
489
static GtkRadioActionClass* gInkRadioActionParentClass = 0;
491
struct _InkRadioActionPrivate
494
Inkscape::IconSize iconSize;
497
#define INK_RADIO_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_RADIO_ACTION_TYPE, InkRadioActionPrivate ) )
499
GType ink_radio_action_get_type( void )
501
static GType myType = 0;
503
static const GTypeInfo myInfo = {
504
sizeof( InkRadioActionClass ),
505
NULL, /* base_init */
506
NULL, /* base_finalize */
507
(GClassInitFunc)ink_radio_action_class_init,
508
NULL, /* class_finalize */
509
NULL, /* class_data */
510
sizeof( InkRadioAction ),
512
(GInstanceInitFunc)ink_radio_action_init,
516
myType = g_type_register_static( GTK_TYPE_RADIO_ACTION, "InkRadioAction", &myInfo, (GTypeFlags)0 );
523
static void ink_radio_action_class_init( InkRadioActionClass* klass )
526
gInkRadioActionParentClass = GTK_RADIO_ACTION_CLASS( g_type_class_peek_parent( klass ) );
527
GObjectClass * objClass = G_OBJECT_CLASS( klass );
529
objClass->finalize = ink_radio_action_finalize;
530
objClass->get_property = ink_radio_action_get_property;
531
objClass->set_property = ink_radio_action_set_property;
533
klass->parent_class.parent_class.parent_class.create_menu_item = ink_radio_action_create_menu_item;
534
klass->parent_class.parent_class.parent_class.create_tool_item = ink_radio_action_create_tool_item;
535
/*klass->parent_class.connect_proxy = connect_proxy;*/
536
/*klass->parent_class.disconnect_proxy = disconnect_proxy;*/
538
g_object_class_install_property( objClass,
540
g_param_spec_string( "iconId",
542
"The id for the icon",
544
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
546
g_object_class_install_property( objClass,
548
g_param_spec_int( "iconSize",
551
(int)Inkscape::ICON_SIZE_MENU,
552
(int)Inkscape::ICON_SIZE_DECORATION,
553
(int)Inkscape::ICON_SIZE_SMALL_TOOLBAR,
554
(GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
556
g_type_class_add_private( klass, sizeof(InkRadioActionClass) );
560
static void ink_radio_action_init( InkRadioAction* action )
562
action->private_data = INK_RADIO_ACTION_GET_PRIVATE( action );
563
action->private_data->iconId = 0;
564
action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR;
567
static void ink_radio_action_finalize( GObject* obj )
569
InkRadioAction* action = INK_RADIO_ACTION( obj );
571
g_free( action->private_data->iconId );
572
g_free( action->private_data );
576
InkRadioAction* ink_radio_action_new( const gchar *name,
578
const gchar *tooltip,
580
Inkscape::IconSize size )
582
GObject* obj = (GObject*)g_object_new( INK_RADIO_ACTION_TYPE,
590
InkRadioAction* action = INK_RADIO_ACTION( obj );
595
static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec )
597
InkRadioAction* action = INK_RADIO_ACTION( obj );
602
g_value_set_string( value, action->private_data->iconId );
608
g_value_set_int( value, action->private_data->iconSize );
613
G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
617
void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec )
619
InkRadioAction* action = INK_RADIO_ACTION( obj );
624
gchar* tmp = action->private_data->iconId;
625
action->private_data->iconId = g_value_dup_string( value );
632
action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value );
638
G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec );
643
static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action )
645
GtkWidget* item = gInkRadioActionParentClass->parent_class.parent_class.create_menu_item(action);
650
static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action )
652
InkRadioAction* act = INK_RADIO_ACTION( action );
653
GtkWidget* item = gInkRadioActionParentClass->parent_class.parent_class.create_tool_item(action);
374
655
if ( act->private_data->iconId ) {
375
656
if ( GTK_IS_TOOL_BUTTON(item) ) {
376
657
GtkToolButton* button = GTK_TOOL_BUTTON(item);
378
GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
379
gtk_tool_button_set_icon_widget( button, child );
659
GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );
660
gtk_tool_button_set_icon_widget( button, child );
381
662
// For now trigger a warning but don't do anything else
382
GtkToolButton* button = GTK_TOOL_BUTTON(item);
663
GtkToolButton* button = GTK_TOOL_BUTTON(item);
387
668
// TODO investigate if needed