index 9c4ee268919fcd3eb487d607faad69545f7bda71..7e67c3daac3d4b4c514774c4bf93fbacf2946a05 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"
enum {
APPEARANCE_UNKNOWN = -1,
APPEARANCE_NONE = 0,
- APPEARANCE_FULL,
- APPEARANCE_COMPACT,
- APPEARANCE_MINIMAL,
+ APPEARANCE_FULL, // label, then all choices represented by separate buttons
+ APPEARANCE_COMPACT, // label, then choices in a drop-down menu
+ APPEARANCE_MINIMAL, // no label, just choices in a drop-down menu
};
struct _EgeSelectOneActionPrivate
gint index = 0;
GtkTooltips* tooltips = gtk_tooltips_new();
+ gchar* sss = 0;
+ g_object_get( G_OBJECT(action), "label", &sss, NULL );
+ if (sss) {
+ GtkWidget* lbl;
+ lbl = gtk_label_new(sss);
+ gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 );
+ }
+
valid = gtk_tree_model_get_iter_first( act->private_data->model, &iter );
while ( valid ) {
gchar* str = 0;
gtk_container_add( GTK_CONTAINER(item), holder );
} else {
+ GtkWidget* holder = gtk_hbox_new( FALSE, 4 );
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 );
+
+ if (act->private_data->appearanceMode == APPEARANCE_COMPACT) {
+ gchar* sss = 0;
+ g_object_get( G_OBJECT(action), "label", &sss, NULL );
+ if (sss) {
+ GtkWidget* lbl;
+ lbl = gtk_label_new(sss);
+ gtk_box_pack_start( GTK_BOX(holder), lbl, FALSE, FALSE, 4 );
+ }
+ }
+
+ gtk_box_pack_start( GTK_BOX(holder), normal, FALSE, FALSE, 0 );
+
+ gtk_container_add( GTK_CONTAINER(item), holder );
}
gtk_widget_show_all( item );
/* 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 );
}
GtkRadioAction* oneAction = GTK_RADIO_ACTION(group->data);
gint hot = gtk_radio_action_get_current_value( oneAction );
if ( hot != active ) {
- gtk_radio_action_set_current_value( oneAction, active );
+ /*gtk_radio_action_set_current_value( oneAction, active );*/
+ gint value = 0;
+ while ( group ) {
+ GtkRadioAction* possible = GTK_RADIO_ACTION(group->data);
+ g_object_get( G_OBJECT(possible), "value", &value, NULL );
+ if ( value == active ) {
+ /* Found the group member to set active */
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(possible), TRUE );
+ break;
+ }
+
+ group = g_slist_next(group);
+ }
}
}
}