forked from AuroraMiddleware/gtk
appchooserbutton: Drop the Private struct
This commit is contained in:
parent
9194b7388f
commit
8ff540eb4c
@ -110,18 +110,7 @@ typedef struct _GtkAppChooserButtonClass GtkAppChooserButtonClass;
|
||||
|
||||
struct _GtkAppChooserButton {
|
||||
GtkWidget parent_instance;
|
||||
};
|
||||
|
||||
struct _GtkAppChooserButtonClass {
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* changed) (GtkAppChooserButton *self);
|
||||
void (* custom_item_activated) (GtkAppChooserButton *self,
|
||||
const gchar *item_name);
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *combobox;
|
||||
GtkListStore *store;
|
||||
|
||||
@ -133,10 +122,17 @@ typedef struct
|
||||
gboolean modal;
|
||||
|
||||
GHashTable *custom_item_names;
|
||||
} GtkAppChooserButtonPrivate;
|
||||
};
|
||||
|
||||
struct _GtkAppChooserButtonClass {
|
||||
GtkWidgetClass parent_class;
|
||||
|
||||
void (* changed) (GtkAppChooserButton *self);
|
||||
void (* custom_item_activated) (GtkAppChooserButton *self,
|
||||
const gchar *item_name);
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserButton, gtk_app_chooser_button, GTK_TYPE_WIDGET,
|
||||
G_ADD_PRIVATE (GtkAppChooserButton)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
|
||||
app_chooser_iface_init));
|
||||
|
||||
@ -195,7 +191,6 @@ select_application_func_cb (GtkTreeModel *model,
|
||||
{
|
||||
SelectAppData *data = user_data;
|
||||
GtkAppChooserButton *self = data->self;
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GAppInfo *app_to_match = data->info;
|
||||
GAppInfo *app = NULL;
|
||||
gboolean custom;
|
||||
@ -213,7 +208,7 @@ select_application_func_cb (GtkTreeModel *model,
|
||||
result = TRUE;
|
||||
else if (g_app_info_equal (app, app_to_match))
|
||||
{
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->combobox), iter);
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->combobox), iter);
|
||||
result = TRUE;
|
||||
}
|
||||
else
|
||||
@ -228,14 +223,13 @@ static void
|
||||
gtk_app_chooser_button_select_application (GtkAppChooserButton *self,
|
||||
GAppInfo *info)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
SelectAppData *data;
|
||||
|
||||
data = g_slice_new0 (SelectAppData);
|
||||
data->self = g_object_ref (self);
|
||||
data->info = g_object_ref (info);
|
||||
|
||||
gtk_tree_model_foreach (GTK_TREE_MODEL (priv->store),
|
||||
gtk_tree_model_foreach (GTK_TREE_MODEL (self->store),
|
||||
select_application_func_cb, data);
|
||||
|
||||
select_app_data_free (data);
|
||||
@ -247,7 +241,6 @@ other_application_dialog_response_cb (GtkDialog *dialog,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserButton *self = user_data;
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GAppInfo *info;
|
||||
|
||||
if (response_id != GTK_RESPONSE_OK)
|
||||
@ -255,7 +248,7 @@ other_application_dialog_response_cb (GtkDialog *dialog,
|
||||
/* reset the active item, otherwise we are stuck on
|
||||
* 'Other application…'
|
||||
*/
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox), priv->last_active);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (self->combobox), self->last_active);
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
return;
|
||||
}
|
||||
@ -274,16 +267,15 @@ other_application_dialog_response_cb (GtkDialog *dialog,
|
||||
static void
|
||||
other_application_item_activated_cb (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkWidget *dialog, *widget;
|
||||
GtkRoot *root;
|
||||
|
||||
root = gtk_widget_get_root (GTK_WIDGET (self));
|
||||
dialog = gtk_app_chooser_dialog_new_for_content_type (GTK_WINDOW (root),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
priv->content_type);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), priv->modal | gtk_window_get_modal (GTK_WINDOW (root)));
|
||||
gtk_app_chooser_dialog_set_heading (GTK_APP_CHOOSER_DIALOG (dialog), priv->heading);
|
||||
self->content_type);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), self->modal | gtk_window_get_modal (GTK_WINDOW (root)));
|
||||
gtk_app_chooser_dialog_set_heading (GTK_APP_CHOOSER_DIALOG (dialog), self->heading);
|
||||
|
||||
widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (dialog));
|
||||
g_object_set (widget,
|
||||
@ -300,21 +292,20 @@ static void
|
||||
gtk_app_chooser_button_ensure_dialog_item (GtkAppChooserButton *self,
|
||||
GtkTreeIter *prev_iter)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter, iter2;
|
||||
|
||||
if (!priv->show_dialog_item || !priv->content_type)
|
||||
if (!self->show_dialog_item || !self->content_type)
|
||||
return;
|
||||
|
||||
if (prev_iter == NULL)
|
||||
gtk_list_store_append (priv->store, &iter);
|
||||
gtk_list_store_append (self->store, &iter);
|
||||
else
|
||||
gtk_list_store_insert_after (priv->store, &iter, prev_iter);
|
||||
gtk_list_store_insert_after (self->store, &iter, prev_iter);
|
||||
|
||||
real_insert_separator (self, FALSE, &iter);
|
||||
iter2 = iter;
|
||||
|
||||
gtk_list_store_insert_after (priv->store, &iter, &iter2);
|
||||
gtk_list_store_insert_after (self->store, &iter, &iter2);
|
||||
real_insert_custom_item (self, CUSTOM_ITEM_OTHER_APP,
|
||||
_("Other application…"), NULL,
|
||||
FALSE, &iter);
|
||||
@ -325,7 +316,6 @@ insert_one_application (GtkAppChooserButton *self,
|
||||
GAppInfo *app,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GIcon *icon;
|
||||
|
||||
icon = g_app_info_get_icon (app);
|
||||
@ -335,7 +325,7 @@ insert_one_application (GtkAppChooserButton *self,
|
||||
else
|
||||
g_object_ref (icon);
|
||||
|
||||
gtk_list_store_set (priv->store, iter,
|
||||
gtk_list_store_set (self->store, iter,
|
||||
COLUMN_APP_INFO, app,
|
||||
COLUMN_LABEL, g_app_info_get_name (app),
|
||||
COLUMN_ICON, icon,
|
||||
@ -348,26 +338,25 @@ insert_one_application (GtkAppChooserButton *self,
|
||||
static void
|
||||
gtk_app_chooser_button_populate (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GList *recommended_apps = NULL, *l;
|
||||
GAppInfo *app, *default_app = NULL;
|
||||
GtkTreeIter iter, iter2;
|
||||
gboolean cycled_recommended;
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
if (priv->content_type)
|
||||
recommended_apps = g_app_info_get_recommended_for_type (priv->content_type);
|
||||
if (self->content_type)
|
||||
recommended_apps = g_app_info_get_recommended_for_type (self->content_type);
|
||||
#endif
|
||||
cycled_recommended = FALSE;
|
||||
|
||||
if (priv->show_default_item)
|
||||
if (self->show_default_item)
|
||||
{
|
||||
if (priv->content_type)
|
||||
default_app = g_app_info_get_default_for_type (priv->content_type, FALSE);
|
||||
if (self->content_type)
|
||||
default_app = g_app_info_get_default_for_type (self->content_type, FALSE);
|
||||
|
||||
if (default_app != NULL)
|
||||
{
|
||||
get_first_iter (priv->store, &iter);
|
||||
get_first_iter (self->store, &iter);
|
||||
cycled_recommended = TRUE;
|
||||
|
||||
insert_one_application (self, default_app, &iter);
|
||||
@ -385,12 +374,12 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
|
||||
|
||||
if (cycled_recommended)
|
||||
{
|
||||
gtk_list_store_insert_after (priv->store, &iter2, &iter);
|
||||
gtk_list_store_insert_after (self->store, &iter2, &iter);
|
||||
iter = iter2;
|
||||
}
|
||||
else
|
||||
{
|
||||
get_first_iter (priv->store, &iter);
|
||||
get_first_iter (self->store, &iter);
|
||||
cycled_recommended = TRUE;
|
||||
}
|
||||
|
||||
@ -405,22 +394,21 @@ gtk_app_chooser_button_populate (GtkAppChooserButton *self)
|
||||
else
|
||||
gtk_app_chooser_button_ensure_dialog_item (self, &iter);
|
||||
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->combobox), 0);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (self->combobox), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkCellRenderer *cell;
|
||||
GtkCellArea *area;
|
||||
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (priv->combobox),
|
||||
GTK_TREE_MODEL (priv->store));
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (self->combobox),
|
||||
GTK_TREE_MODEL (self->store));
|
||||
|
||||
area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (priv->combobox));
|
||||
area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (self->combobox));
|
||||
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (priv->combobox),
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self->combobox),
|
||||
row_separator_func, NULL, NULL);
|
||||
|
||||
cell = gtk_cell_renderer_pixbuf_new ();
|
||||
@ -429,7 +417,7 @@ gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
|
||||
"expand", FALSE,
|
||||
"fixed-size", FALSE,
|
||||
NULL);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->combobox), cell,
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self->combobox), cell,
|
||||
"gicon", COLUMN_ICON,
|
||||
NULL);
|
||||
|
||||
@ -438,7 +426,7 @@ gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
|
||||
"align", FALSE,
|
||||
"expand", TRUE,
|
||||
NULL);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->combobox), cell,
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self->combobox), cell,
|
||||
"text", COLUMN_LABEL,
|
||||
NULL);
|
||||
|
||||
@ -448,12 +436,11 @@ gtk_app_chooser_button_build_ui (GtkAppChooserButton *self)
|
||||
static void
|
||||
gtk_app_chooser_button_remove_non_custom (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gboolean custom, res;
|
||||
|
||||
model = GTK_TREE_MODEL (priv->store);
|
||||
model = GTK_TREE_MODEL (self->store);
|
||||
|
||||
if (!gtk_tree_model_get_iter_first (model, &iter))
|
||||
return;
|
||||
@ -474,7 +461,6 @@ gtk_app_chooser_button_changed (GtkComboBox *object,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserButton *self = user_data;
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
gchar *name = NULL;
|
||||
gboolean custom;
|
||||
@ -483,7 +469,7 @@ gtk_app_chooser_button_changed (GtkComboBox *object,
|
||||
if (!gtk_combo_box_get_active_iter (object, &iter))
|
||||
return;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (self->store), &iter,
|
||||
COLUMN_NAME, &name,
|
||||
COLUMN_CUSTOM, &custom,
|
||||
-1);
|
||||
@ -494,7 +480,7 @@ gtk_app_chooser_button_changed (GtkComboBox *object,
|
||||
{
|
||||
name_quark = g_quark_from_string (name);
|
||||
g_signal_emit (self, signals[SIGNAL_CUSTOM_ITEM_ACTIVATED], name_quark, name);
|
||||
priv->last_active = gtk_combo_box_get_active (object);
|
||||
self->last_active = gtk_combo_box_get_active (object);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -505,7 +491,7 @@ gtk_app_chooser_button_changed (GtkComboBox *object,
|
||||
g_free (name);
|
||||
}
|
||||
else
|
||||
priv->last_active = gtk_combo_box_get_active (object);
|
||||
self->last_active = gtk_combo_box_get_active (object);
|
||||
|
||||
g_signal_emit (self, signals[SIGNAL_CHANGED], 0);
|
||||
}
|
||||
@ -523,14 +509,13 @@ static GAppInfo *
|
||||
gtk_app_chooser_button_get_app_info (GtkAppChooser *object)
|
||||
{
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (object);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
GAppInfo *info;
|
||||
|
||||
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->combobox), &iter))
|
||||
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (self->combobox), &iter))
|
||||
return NULL;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (self->store), &iter,
|
||||
COLUMN_APP_INFO, &info,
|
||||
-1);
|
||||
|
||||
@ -555,12 +540,11 @@ gtk_app_chooser_button_set_property (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CONTENT_TYPE:
|
||||
priv->content_type = g_value_dup_string (value);
|
||||
self->content_type = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_SHOW_DIALOG_ITEM:
|
||||
gtk_app_chooser_button_set_show_dialog_item (self, g_value_get_boolean (value));
|
||||
@ -587,24 +571,23 @@ gtk_app_chooser_button_get_property (GObject *obj,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CONTENT_TYPE:
|
||||
g_value_set_string (value, priv->content_type);
|
||||
g_value_set_string (value, self->content_type);
|
||||
break;
|
||||
case PROP_SHOW_DIALOG_ITEM:
|
||||
g_value_set_boolean (value, priv->show_dialog_item);
|
||||
g_value_set_boolean (value, self->show_dialog_item);
|
||||
break;
|
||||
case PROP_SHOW_DEFAULT_ITEM:
|
||||
g_value_set_boolean (value, priv->show_default_item);
|
||||
g_value_set_boolean (value, self->show_default_item);
|
||||
break;
|
||||
case PROP_HEADING:
|
||||
g_value_set_string (value, priv->heading);
|
||||
g_value_set_string (value, self->heading);
|
||||
break;
|
||||
case PROP_MODAL:
|
||||
g_value_set_boolean (value, priv->modal);
|
||||
g_value_set_boolean (value, self->modal);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
|
||||
@ -616,13 +599,12 @@ static void
|
||||
gtk_app_chooser_button_finalize (GObject *obj)
|
||||
{
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (obj);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_hash_table_destroy (priv->custom_item_names);
|
||||
g_free (priv->content_type);
|
||||
g_free (priv->heading);
|
||||
g_object_unref (priv->store);
|
||||
gtk_widget_unparent (priv->combobox);
|
||||
g_hash_table_destroy (self->custom_item_names);
|
||||
g_free (self->content_type);
|
||||
g_free (self->heading);
|
||||
g_object_unref (self->store);
|
||||
gtk_widget_unparent (self->combobox);
|
||||
|
||||
G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->finalize (obj);
|
||||
}
|
||||
@ -636,10 +618,9 @@ gtk_app_chooser_button_measure (GtkWidget *widget,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
GtkAppChooserButton *button = GTK_APP_CHOOSER_BUTTON (widget);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (button);
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (widget);
|
||||
|
||||
gtk_widget_measure (priv->combobox, orientation, for_size,
|
||||
gtk_widget_measure (self->combobox, orientation, for_size,
|
||||
minimum, natural,
|
||||
minimum_baseline, natural_baseline);
|
||||
}
|
||||
@ -650,10 +631,9 @@ gtk_app_chooser_button_size_allocate (GtkWidget *widget,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
GtkAppChooserButton *button = GTK_APP_CHOOSER_BUTTON (widget);
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (button);
|
||||
GtkAppChooserButton *self = GTK_APP_CHOOSER_BUTTON (widget);
|
||||
|
||||
gtk_widget_size_allocate (priv->combobox, &(GtkAllocation){0, 0, width, height}, baseline);
|
||||
gtk_widget_size_allocate (self->combobox, &(GtkAllocation){0, 0, width, height}, baseline);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -765,22 +745,20 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
|
||||
static void
|
||||
gtk_app_chooser_button_init (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
self->modal = TRUE;
|
||||
|
||||
priv->modal = TRUE;
|
||||
|
||||
priv->custom_item_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
priv->store = gtk_list_store_new (NUM_COLUMNS,
|
||||
self->custom_item_names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
self->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 */
|
||||
priv->combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->store));
|
||||
gtk_widget_set_parent (priv->combobox, GTK_WIDGET (self));
|
||||
self->combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (self->store));
|
||||
gtk_widget_set_parent (self->combobox, GTK_WIDGET (self));
|
||||
|
||||
g_signal_connect (priv->combobox, "changed",
|
||||
g_signal_connect (self->combobox, "changed",
|
||||
G_CALLBACK (gtk_app_chooser_button_changed), self);
|
||||
}
|
||||
|
||||
@ -789,15 +767,14 @@ app_chooser_button_iter_from_custom_name (GtkAppChooserButton *self,
|
||||
const gchar *name,
|
||||
GtkTreeIter *set_me)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
gchar *custom_name = NULL;
|
||||
|
||||
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->store), &iter))
|
||||
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->store), &iter))
|
||||
return FALSE;
|
||||
|
||||
do {
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (self->store), &iter,
|
||||
COLUMN_NAME, &custom_name,
|
||||
-1);
|
||||
|
||||
@ -810,7 +787,7 @@ app_chooser_button_iter_from_custom_name (GtkAppChooserButton *self,
|
||||
}
|
||||
|
||||
g_free (custom_name);
|
||||
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->store), &iter));
|
||||
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (self->store), &iter));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -823,21 +800,20 @@ real_insert_custom_item (GtkAppChooserButton *self,
|
||||
gboolean custom,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
if (custom)
|
||||
{
|
||||
if (g_hash_table_lookup (priv->custom_item_names, name) != NULL)
|
||||
if (g_hash_table_lookup (self->custom_item_names, name) != NULL)
|
||||
{
|
||||
g_warning ("Attempting to add custom item %s to GtkAppChooserButton, "
|
||||
"when there's already an item with the same name", name);
|
||||
return;
|
||||
}
|
||||
|
||||
g_hash_table_insert (priv->custom_item_names,
|
||||
g_hash_table_insert (self->custom_item_names,
|
||||
g_strdup (name), GINT_TO_POINTER (1));
|
||||
}
|
||||
|
||||
gtk_list_store_set (priv->store, iter,
|
||||
gtk_list_store_set (self->store, iter,
|
||||
COLUMN_NAME, name,
|
||||
COLUMN_LABEL, label,
|
||||
COLUMN_ICON, icon,
|
||||
@ -851,9 +827,7 @@ real_insert_separator (GtkAppChooserButton *self,
|
||||
gboolean custom,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
gtk_list_store_set (priv->store, iter,
|
||||
gtk_list_store_set (self->store, iter,
|
||||
COLUMN_CUSTOM, custom,
|
||||
COLUMN_SEPARATOR, TRUE,
|
||||
-1);
|
||||
@ -888,12 +862,11 @@ gtk_app_chooser_button_new (const gchar *content_type)
|
||||
void
|
||||
gtk_app_chooser_button_append_separator (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
|
||||
gtk_list_store_append (priv->store, &iter);
|
||||
gtk_list_store_append (self->store, &iter);
|
||||
real_insert_separator (self, TRUE, &iter);
|
||||
}
|
||||
|
||||
@ -917,13 +890,12 @@ gtk_app_chooser_button_append_custom_item (GtkAppChooserButton *self,
|
||||
const gchar *label,
|
||||
GIcon *icon)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
gtk_list_store_append (priv->store, &iter);
|
||||
gtk_list_store_append (self->store, &iter);
|
||||
real_insert_custom_item (self, name, label, icon, TRUE, &iter);
|
||||
}
|
||||
|
||||
@ -942,20 +914,19 @@ void
|
||||
gtk_app_chooser_button_set_active_custom_item (GtkAppChooserButton *self,
|
||||
const gchar *name)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
GtkTreeIter iter;
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
g_return_if_fail (name != NULL);
|
||||
|
||||
if (!g_hash_table_contains (priv->custom_item_names, name) ||
|
||||
if (!g_hash_table_contains (self->custom_item_names, name) ||
|
||||
!app_chooser_button_iter_from_custom_name (self, name, &iter))
|
||||
{
|
||||
g_warning ("Can't find the item named %s in the app chooser.", name);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->combobox), &iter);
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->combobox), &iter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -970,11 +941,9 @@ gtk_app_chooser_button_set_active_custom_item (GtkAppChooserButton *self,
|
||||
gboolean
|
||||
gtk_app_chooser_button_get_show_dialog_item (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), FALSE);
|
||||
|
||||
return priv->show_dialog_item;
|
||||
return self->show_dialog_item;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -989,10 +958,9 @@ void
|
||||
gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self,
|
||||
gboolean setting)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
if (priv->show_dialog_item != setting)
|
||||
if (self->show_dialog_item != setting)
|
||||
{
|
||||
priv->show_dialog_item = setting;
|
||||
self->show_dialog_item = setting;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_DIALOG_ITEM]);
|
||||
|
||||
@ -1012,11 +980,9 @@ gtk_app_chooser_button_set_show_dialog_item (GtkAppChooserButton *self,
|
||||
gboolean
|
||||
gtk_app_chooser_button_get_show_default_item (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), FALSE);
|
||||
|
||||
return priv->show_default_item;
|
||||
return self->show_default_item;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1031,13 +997,11 @@ void
|
||||
gtk_app_chooser_button_set_show_default_item (GtkAppChooserButton *self,
|
||||
gboolean setting)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
|
||||
if (priv->show_default_item != setting)
|
||||
if (self->show_default_item != setting)
|
||||
{
|
||||
priv->show_default_item = setting;
|
||||
self->show_default_item = setting;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_DEFAULT_ITEM]);
|
||||
|
||||
@ -1057,12 +1021,10 @@ void
|
||||
gtk_app_chooser_button_set_heading (GtkAppChooserButton *self,
|
||||
const gchar *heading)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
|
||||
g_free (priv->heading);
|
||||
priv->heading = g_strdup (heading);
|
||||
g_free (self->heading);
|
||||
self->heading = g_strdup (heading);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_HEADING]);
|
||||
}
|
||||
@ -1079,11 +1041,9 @@ gtk_app_chooser_button_set_heading (GtkAppChooserButton *self,
|
||||
const gchar *
|
||||
gtk_app_chooser_button_get_heading (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), NULL);
|
||||
|
||||
return priv->heading;
|
||||
return self->heading;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1097,14 +1057,12 @@ void
|
||||
gtk_app_chooser_button_set_modal (GtkAppChooserButton *self,
|
||||
gboolean modal)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||
|
||||
if (priv->modal == modal)
|
||||
if (self->modal == modal)
|
||||
return;
|
||||
|
||||
priv->modal = modal;
|
||||
self->modal = modal;
|
||||
|
||||
g_object_notify (G_OBJECT (self), "modal");
|
||||
}
|
||||
@ -1120,10 +1078,8 @@ gtk_app_chooser_button_set_modal (GtkAppChooserButton *self,
|
||||
gboolean
|
||||
gtk_app_chooser_button_get_modal (GtkAppChooserButton *self)
|
||||
{
|
||||
GtkAppChooserButtonPrivate *priv = gtk_app_chooser_button_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self), FALSE);
|
||||
|
||||
return priv->modal;
|
||||
return self->modal;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user