summaryrefslogtreecommitdiff
path: root/gtk/gtkappchooserbutton.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2011-03-01 19:41:15 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2011-03-01 19:41:15 +0900
commitc844a24ae6209b916e8aaa0559f1c45643a255d2 (patch)
tree279dbb03b624cf91ca02fd26fdabb445bdc9bc7e /gtk/gtkappchooserbutton.c
parent0e608f1b1f9003d2d53baad38a816bb4651859f2 (diff)
downloadgtk+-c844a24ae6209b916e8aaa0559f1c45643a255d2.tar.gz
Allow GtkAppChooser classes to be instantiated with content-type=NULL.
Mostly for corner cases such as Glade that treats objects generically and needs to have an object that doesnt crash out of g_object_new().
Diffstat (limited to 'gtk/gtkappchooserbutton.c')
-rw-r--r--gtk/gtkappchooserbutton.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/gtk/gtkappchooserbutton.c b/gtk/gtkappchooserbutton.c
index 34cc573b35..706ce13257 100644
--- a/gtk/gtkappchooserbutton.c
+++ b/gtk/gtkappchooserbutton.c
@@ -248,7 +248,7 @@ gtk_app_chooser_button_ensure_dialog_item (GtkAppChooserButton *self,
{
GtkTreeIter iter, iter2;
- if (!self->priv->show_dialog_item)
+ if (!self->priv->show_dialog_item || !self->priv->content_type)
return;
if (prev_iter == NULL)
@@ -275,7 +275,8 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
gboolean cycled_recommended;
#ifndef G_OS_WIN32
- recommended_apps = g_app_info_get_recommended_for_type (self->priv->content_type);
+ if (self->priv->content_type)
+ recommended_apps = g_app_info_get_recommended_for_type (self->priv->content_type);
#endif
cycled_recommended = FALSE;
@@ -325,14 +326,6 @@ gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
GtkCellRenderer *cell;
GtkCellArea *area;
- self->priv->store = gtk_list_store_new (NUM_COLUMNS,
- G_TYPE_APP_INFO,
- G_TYPE_STRING, /* name */
- G_TYPE_STRING, /* label */
- G_TYPE_ICON,
- G_TYPE_BOOLEAN, /* separator */
- G_TYPE_BOOLEAN); /* custom */
-
gtk_combo_box_set_model (GTK_COMBO_BOX (self),
GTK_TREE_MODEL (self->priv->store));
@@ -457,8 +450,6 @@ gtk_app_chooser_button_constructed (GObject *obj)
if (G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->constructed != NULL)
G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->constructed (obj);
- g_assert (self->priv->content_type != NULL);
-
gtk_app_chooser_button_build_ui (self);
}
@@ -521,6 +512,8 @@ gtk_app_chooser_button_finalize (GObject *obj)
g_free (self->priv->content_type);
g_free (self->priv->heading);
+ g_object_unref (self->priv->store);
+
G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->finalize (obj);
}
@@ -605,6 +598,14 @@ gtk_app_chooser_button_init (GtkAppChooserButton *self)
self->priv->custom_item_names =
g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
+
+ self->priv->store = gtk_list_store_new (NUM_COLUMNS,
+ G_TYPE_APP_INFO,
+ G_TYPE_STRING, /* name */
+ G_TYPE_STRING, /* label */
+ G_TYPE_ICON,
+ G_TYPE_BOOLEAN, /* separator */
+ G_TYPE_BOOLEAN); /* custom */
}
static gboolean