Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / ege-select-one-action.cpp
index 0a1a6435d240e3cfb51198e84e48c60628b32f51..6de22495d0fe0c2f0902f2b2ae8130a353944435 100644 (file)
@@ -44,7 +44,7 @@
 #include <gtk/gtkhbox.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtktoolitem.h>
-#include <gtk/gtkcombobox.h>
+#include <gtk/gtk.h>
 #include <gtk/gtkcellrenderertext.h>
 #include <gtk/gtkcellrendererpixbuf.h>
 #include <gtk/gtkcelllayout.h>
@@ -94,6 +94,7 @@ struct _EgeSelectOneActionPrivate
     gint iconColumn;
     gint tooltipColumn;
     gint appearanceMode;
+    gint iconSize;
     GType radioActionType;
     GtkTreeModel* model;
     gchar* iconProperty;
@@ -109,6 +110,7 @@ enum {
     PROP_ICON_COLUMN,
     PROP_TOOLTIP_COLUMN,
     PROP_ICON_PROP,
+    PROP_ICON_SIZE,
     PROP_APPEARANCE
 };
 
@@ -202,6 +204,14 @@ void ege_select_one_action_class_init( EgeSelectOneActionClass* klass )
                                                               "",
                                                               (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
 
+        g_object_class_install_property( objClass,
+                                         PROP_ICON_SIZE,
+                                         g_param_spec_int( "icon-size",
+                                                           "Icon Size",
+                                                          "Target icon size",
+                                                           -1, 20, -1,
+                                                           (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) );
+
         g_object_class_install_property( objClass,
                                          PROP_APPEARANCE,
                                          g_param_spec_string( "appearance",
@@ -234,6 +244,7 @@ void ege_select_one_action_init( EgeSelectOneAction* action )
     action->private_data->radioActionType = 0;
     action->private_data->model = 0;
     action->private_data->iconProperty = g_strdup("stock-id");
+    action->private_data->iconSize = -1;
     action->private_data->appearance = 0;
 
 /*     g_signal_connect( action, "notify", G_CALLBACK( fixup_labels ), NULL ); */
@@ -294,6 +305,17 @@ void ege_select_one_action_set_icon_column( EgeSelectOneAction* action, gint col
     g_object_set( G_OBJECT(action), "icon-column", col, NULL );
 }
 
+gint ege_select_one_action_get_icon_size( EgeSelectOneAction* action )
+{
+    g_return_val_if_fail( IS_EGE_SELECT_ONE_ACTION(action), 0 );
+    return action->private_data->iconSize;
+}
+
+void ege_select_one_action_set_icon_size( EgeSelectOneAction* action, gint size )
+{
+    g_object_set( G_OBJECT(action), "icon-size", size, NULL );
+}
+
 gint ege_select_one_action_get_tooltip_column( EgeSelectOneAction* action )
 {
     g_return_val_if_fail( IS_EGE_SELECT_ONE_ACTION(action), 0 );
@@ -338,6 +360,10 @@ void ege_select_one_action_get_property( GObject* obj, guint propId, GValue* val
             g_value_set_string( value, action->private_data->iconProperty );
             break;
 
+        case PROP_ICON_SIZE:
+            g_value_set_int( value, action->private_data->iconSize );
+            break;
+
         case PROP_APPEARANCE:
             g_value_set_string( value, action->private_data->appearance );
             break;
@@ -390,6 +416,12 @@ void ege_select_one_action_set_property( GObject* obj, guint propId, const GValu
         }
         break;
 
+        case PROP_ICON_SIZE:
+        {
+            action->private_data->iconSize = g_value_get_int( value );
+        }
+        break;
+
         case PROP_APPEARANCE:
         {
             gchar* tmp = action->private_data->appearance;
@@ -543,6 +575,13 @@ GtkWidget* create_tool_item( GtkAction* action )
                         g_object_set( G_OBJECT(obj), act->private_data->iconProperty, iconId, NULL );
                     }
 
+                    if ( act->private_data->iconProperty >= 0 ) {
+                        /* TODO get this string to be set instead of hardcoded */
+                        if ( act->private_data->iconSize >= 0 ) {
+                            g_object_set( G_OBJECT(obj), "iconSize", act->private_data->iconSize, NULL );
+                        }
+                    }
+
                     ract = GTK_RADIO_ACTION(obj);
                 } else {
                     ract = gtk_radio_action_new( "Name 1", str, tip, iconId, index );
@@ -693,7 +732,7 @@ void combo_changed_cb( GtkComboBox* widget, gpointer user_data )
 {
     EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION(user_data);
     gint newActive = gtk_combo_box_get_active(widget);
-    if (newActive != act->private_data->active) {
+    if (newActive != act->private_data->active && newActive != -1) {
         g_object_set( G_OBJECT(act), "active", newActive, NULL );
     }
 }