Code

Filter effects dialog:
[inkscape.git] / src / ege-select-one-action.cpp
index 636da6e4b684d02f6f06f50c36c29bd6af944403..0bf1a3fc91a87344381348dbc66a4acf5e5a4a54 100644 (file)
 #include <gtk/gtktoolitem.h>
 #include <gtk/gtkcombobox.h>
 #include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtkcellrendererpixbuf.h>
 #include <gtk/gtkcelllayout.h>
 #include <gtk/gtkradioaction.h>
 #include <gtk/gtkradiomenuitem.h>
+#include <gtk/gtktable.h>
 
 #include "ege-select-one-action.h"
 
@@ -562,17 +564,35 @@ GtkWidget* create_tool_item( GtkAction* action )
 
             gtk_container_add( GTK_CONTAINER(item), holder );
         } else {
+            GtkWidget* holder = gtk_table_new( 1, 3, FALSE );
             GtkWidget* normal = gtk_combo_box_new_with_model( act->private_data->model );
 
-            GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
+            GtkCellRenderer * renderer = 0;
+
+            if ( act->private_data->iconColumn >= 0 ) {
+                renderer = gtk_cell_renderer_pixbuf_new();
+                gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(normal), renderer, TRUE );
+
+                // "icon-name"
+                gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(normal), renderer, "stock-id", act->private_data->iconColumn );
+            }
+
+            renderer = gtk_cell_renderer_text_new();
             gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(normal), renderer, TRUE );
-            gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(normal), renderer, "text", act->private_data->labelColumn, (gchar*)0);
+            gtk_cell_layout_add_attribute( GTK_CELL_LAYOUT(normal), renderer, "text", act->private_data->labelColumn );
 
             gtk_combo_box_set_active( GTK_COMBO_BOX(normal), act->private_data->active );
 
             g_signal_connect( G_OBJECT(normal), "changed", G_CALLBACK(combo_changed_cb), action );
 
-            gtk_container_add( GTK_CONTAINER(item), normal );
+            g_object_set_data( G_OBJECT(holder), "ege-combo-box", normal );
+
+            GtkWidget* lbl = gtk_label_new(" ");
+            gtk_table_attach( GTK_TABLE(holder), lbl, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+            gtk_table_attach( GTK_TABLE(holder), normal, 1, 2, 0, 1, GTK_FILL, GTK_EXPAND, 0, 0 );
+            lbl = gtk_label_new(" ");
+            gtk_table_attach( GTK_TABLE(holder), lbl, 2, 3, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0 );
+            gtk_container_add( GTK_CONTAINER(item), holder );
         }
 
         gtk_widget_show_all( item );
@@ -605,8 +625,9 @@ void resync_active( EgeSelectOneAction* act, gint active )
                 /* Search for the things we built up in create_tool_item() */
                 GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) );
                 if ( children && children->data ) {
-                    if ( GTK_IS_COMBO_BOX(children->data) ) {
-                        GtkComboBox* combo = GTK_COMBO_BOX(children->data);
+                    gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" );
+                    if ( GTK_IS_COMBO_BOX(combodata) ) {
+                        GtkComboBox* combo = GTK_COMBO_BOX(combodata);
                         if ( gtk_combo_box_get_active(combo) != active ) {
                             gtk_combo_box_set_active( combo, active );
                         }