summaryrefslogtreecommitdiffstats
path: root/src/ege-select-one-action.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ege-select-one-action.cpp')
-rw-r--r--src/ege-select-one-action.cpp87
1 files changed, 25 insertions, 62 deletions
diff --git a/src/ege-select-one-action.cpp b/src/ege-select-one-action.cpp
index 42f2fafce..3facf7242 100644
--- a/src/ege-select-one-action.cpp
+++ b/src/ege-select-one-action.cpp
@@ -49,9 +49,6 @@ enum {
CHANGED = 0,
LAST_SIGNAL};
-
-static void ege_select_one_action_class_init( EgeSelectOneActionClass* klass );
-static void ege_select_one_action_init( EgeSelectOneAction* action );
static void ege_select_one_action_finalize( GObject* action );
static void ege_select_one_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec );
static void ege_select_one_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec );
@@ -73,7 +70,6 @@ static void disconnect_proxy( GtkAction *action, GtkWidget *proxy );
static int scan_max_width( GtkTreeModel *model, gint labelColumn );
-static GtkActionClass* gParentClass = 0;
static guint signals[LAST_SIGNAL] = {0};
static GQuark gDataName = 0;
@@ -126,28 +122,7 @@ enum {
PROP_SELECTION
};
-GType ege_select_one_action_get_type( void )
-{
- static GType myType = 0;
- if ( !myType ) {
- static const GTypeInfo myInfo = {
- sizeof( EgeSelectOneActionClass ),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc)ege_select_one_action_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof( EgeSelectOneAction ),
- 0, /* n_preallocs */
- (GInstanceInitFunc)ege_select_one_action_init,
- NULL
- };
-
- myType = g_type_register_static( GTK_TYPE_ACTION, "EgeSelectOneAction", &myInfo, (GTypeFlags)0 );
- }
-
- return myType;
-}
+G_DEFINE_TYPE(EgeSelectOneAction, ege_select_one_action, GTK_TYPE_ACTION);
GtkTreeModel *ege_select_one_action_get_model(EgeSelectOneAction* action ){
return GTK_TREE_MODEL(action->private_data->model);
@@ -155,7 +130,6 @@ GtkTreeModel *ege_select_one_action_get_model(EgeSelectOneAction* action ){
void ege_select_one_action_class_init( EgeSelectOneActionClass* klass )
{
if ( klass ) {
- gParentClass = GTK_ACTION_CLASS( g_type_class_peek_parent( klass ) );
GObjectClass* objClass = G_OBJECT_CLASS( klass );
gDataName = g_quark_from_string("ege-select1-action");
@@ -292,8 +266,8 @@ void ege_select_one_action_finalize( GObject* object )
g_free( action->private_data->appearance );
g_free( action->private_data->selection );
- if ( G_OBJECT_CLASS(gParentClass)->finalize ) {
- (*G_OBJECT_CLASS(gParentClass)->finalize)(object);
+ if ( G_OBJECT_CLASS(ege_select_one_action_parent_class)->finalize ) {
+ (*G_OBJECT_CLASS(ege_select_one_action_parent_class)->finalize)(object);
}
}
@@ -593,7 +567,6 @@ GtkWidget* create_menu_item( GtkAction* action )
if ( IS_EGE_SELECT_ONE_ACTION(action) ) {
EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION( action );
gchar* sss = 0;
- gboolean valid = FALSE;
gint index = 0;
GtkTreeIter iter;
GSList* group = 0;
@@ -603,7 +576,7 @@ GtkWidget* create_menu_item( GtkAction* action )
item = gtk_menu_item_new_with_label( sss );
- valid = gtk_tree_model_get_iter_first( act->private_data->model, &iter );
+ gboolean valid = gtk_tree_model_get_iter_first( act->private_data->model, &iter );
while ( valid ) {
gchar* str = 0;
gtk_tree_model_get( act->private_data->model, &iter,
@@ -631,7 +604,7 @@ GtkWidget* create_menu_item( GtkAction* action )
g_free(sss);
} else {
- item = gParentClass->create_menu_item( action );
+ item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_menu_item( action );
}
return item;
@@ -659,10 +632,14 @@ GtkWidget* create_tool_item( GtkAction* action )
item = GTK_WIDGET( gtk_tool_item_new() );
if ( act->private_data->appearanceMode == APPEARANCE_FULL ) {
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_set_homogeneous(GTK_BOX(holder), FALSE);
+#else
GtkWidget* holder = gtk_hbox_new( FALSE, 0 );
+#endif
GtkRadioAction* ract = 0;
- GtkWidget* sub = 0;
GSList* group = 0;
GtkTreeIter iter;
gboolean valid = FALSE;
@@ -749,7 +726,7 @@ GtkWidget* create_tool_item( GtkAction* action )
}
g_signal_connect( G_OBJECT(ract), "changed", G_CALLBACK( proxy_action_chagned_cb ), act );
- sub = gtk_action_create_tool_item( GTK_ACTION(ract) );
+ GtkWidget* sub = gtk_action_create_tool_item( GTK_ACTION(ract) );
gtk_activatable_set_related_action( GTK_ACTIVATABLE (sub), GTK_ACTION(ract) );
gtk_tool_item_set_tooltip_text( GTK_TOOL_ITEM(sub), tip );
@@ -767,21 +744,19 @@ GtkWidget* create_tool_item( GtkAction* action )
gtk_container_add( GTK_CONTAINER(item), holder );
} else {
- GtkCellRenderer * renderer = 0;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
+ gtk_box_set_homogeneous(GTK_BOX(holder), FALSE);
+#else
GtkWidget *holder = gtk_hbox_new( FALSE, 4 );
+#endif
+
GtkEntry *entry = 0;
GtkWidget *normal;
if (act->private_data->selectionMode == SELECTION_OPEN) {
-
-// Backward-compatibility: GtkComboBoxEntry is deprecated in GTK+ >= 2.24
-// and gtk_combo_box_set_entry_text_column is unavailable in earlier versions.
-#if GTK_CHECK_VERSION (2, 24, 0)
- normal = gtk_combo_box_new_with_model_and_entry (act->private_data->model);
- gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (normal), act->private_data->labelColumn);
-#else
- normal = gtk_combo_box_entry_new_with_model (act->private_data->model, act->private_data->labelColumn);
-#endif
+ normal = gtk_combo_box_new_with_model_and_entry (act->private_data->model);
+ gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (normal), act->private_data->labelColumn);
GtkWidget *child = gtk_bin_get_child( GTK_BIN(normal) );
if (GTK_IS_ENTRY(child)) {
@@ -804,6 +779,7 @@ GtkWidget* create_tool_item( GtkAction* action )
}
}
else {
+ GtkCellRenderer * renderer = NULL;
normal = gtk_combo_box_new_with_model( act->private_data->model );
if ( act->private_data->iconColumn >= 0 ) {
renderer = gtk_cell_renderer_pixbuf_new();
@@ -850,7 +826,7 @@ GtkWidget* create_tool_item( GtkAction* action )
gtk_widget_show_all( item );
} else {
- item = gParentClass->create_tool_item( action );
+ item = GTK_ACTION_CLASS(ege_select_one_action_parent_class)->create_tool_item( action );
}
return item;
@@ -859,12 +835,12 @@ GtkWidget* create_tool_item( GtkAction* action )
void connect_proxy( GtkAction *action, GtkWidget *proxy )
{
- gParentClass->connect_proxy( action, proxy );
+ GTK_ACTION_CLASS(ege_select_one_action_parent_class)->connect_proxy( action, proxy );
}
void disconnect_proxy( GtkAction *action, GtkWidget *proxy )
{
- gParentClass->disconnect_proxy( action, proxy );
+ GTK_ACTION_CLASS(ege_select_one_action_parent_class)->disconnect_proxy( action, proxy );
}
@@ -885,18 +861,12 @@ void resync_active( EgeSelectOneAction* act, gint active, gboolean override )
}
if ( GTK_IS_COMBO_BOX(combodata) ) {
GtkComboBox* combo = GTK_COMBO_BOX(combodata);
-// Backward-compatibility: GtkComboBoxEntry is deprecated in GTK+ >= 2.24
-// gtk_combo_box_get_has_entry is unavailable in earlier versions
-#if GTK_CHECK_VERSION (2, 24, 0)
if ((active == -1) && (gtk_combo_box_get_has_entry(combo))) {
-#else
- if ((active == -1) && (GTK_IS_COMBO_BOX_ENTRY(combo))) {
-#endif
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo))), act->private_data->activeText);
} else if ( gtk_combo_box_get_active(combo) != active ) {
gtk_combo_box_set_active( combo, active );
}
- } else if ( GTK_IS_HBOX(children->data) ) {
+ } else if ( GTK_IS_BOX(children->data) ) {
gpointer data = g_object_get_data( G_OBJECT(children->data), "ege-proxy_action-group" );
if ( data ) {
GSList* group = (GSList*)data;
@@ -951,7 +921,7 @@ void resync_sensitive( EgeSelectOneAction* act )
}
if ( GTK_IS_COMBO_BOX(combodata) ) {
/* Not implemented */
- } else if ( GTK_IS_HBOX(children->data) ) {
+ } else if ( GTK_IS_BOX(children->data) ) {
gpointer data = g_object_get_data( G_OBJECT(children->data), "ege-proxy_action-group" );
if ( data ) {
GSList* group = (GSList*)data;
@@ -1007,10 +977,6 @@ void combo_changed_cb( GtkComboBox* widget, gpointer user_data )
GtkComboBox *cb = GTK_COMBO_BOX (widget);
gint newActive = gtk_combo_box_get_active(widget);
-// Backward-compatibility: gtk_combo_box_get_active_text is deprecated in
-// GTK+ >= 2.24. gtk_combo_box_get_has_entry is unavailable in earlier
-// versions.
-#if GTK_CHECK_VERSION (2, 24, 0)
if (gtk_combo_box_get_has_entry (cb)) {
GtkBin *bin = GTK_BIN (cb);
GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (bin));
@@ -1026,9 +992,6 @@ void combo_changed_cb( GtkComboBox* widget, gpointer user_data )
gtk_tree_model_get (model, &iter, 0, &text, -1);
}
}
-#else
- text = gtk_combo_box_get_active_text (cb);
-#endif
if (!text) {
/* User probably deleted the data in the model */