Formatting fixes
This commit is contained in:
@ -1,5 +1,4 @@
|
|||||||
/*
|
/* gtkappchooserbutton.c: an app-chooser combobox
|
||||||
* gtkappchooserbutton.h: an app-chooser combobox
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010 Red Hat, Inc.
|
* Copyright (C) 2010 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
@ -86,18 +85,18 @@ enum {
|
|||||||
|
|
||||||
#define CUSTOM_ITEM_OTHER_APP "gtk-internal-item-other-app"
|
#define CUSTOM_ITEM_OTHER_APP "gtk-internal-item-other-app"
|
||||||
|
|
||||||
static void app_chooser_iface_init (GtkAppChooserIface *iface);
|
static void app_chooser_iface_init (GtkAppChooserIface *iface);
|
||||||
|
|
||||||
static void real_insert_custom_item (GtkAppChooserButton *self,
|
static void real_insert_custom_item (GtkAppChooserButton *self,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
const gchar *label,
|
const gchar *label,
|
||||||
GIcon *icon,
|
GIcon *icon,
|
||||||
gboolean custom,
|
gboolean custom,
|
||||||
GtkTreeIter *iter);
|
GtkTreeIter *iter);
|
||||||
|
|
||||||
static void real_insert_separator (GtkAppChooserButton *self,
|
static void real_insert_separator (GtkAppChooserButton *self,
|
||||||
gboolean custom,
|
gboolean custom,
|
||||||
GtkTreeIter *iter);
|
GtkTreeIter *iter);
|
||||||
|
|
||||||
static guint signals[NUM_SIGNALS] = { 0, };
|
static guint signals[NUM_SIGNALS] = { 0, };
|
||||||
|
|
||||||
@ -167,12 +166,13 @@ select_app_data_free (SelectAppData *data)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
select_application_func_cb (GtkTreeModel *model,
|
select_application_func_cb (GtkTreeModel *model,
|
||||||
GtkTreePath *path,
|
GtkTreePath *path,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
SelectAppData *data = user_data;
|
SelectAppData *data = user_data;
|
||||||
GAppInfo *app_to_match = data->info, *app = NULL;
|
GAppInfo *app_to_match = data->info;
|
||||||
|
GAppInfo *app = NULL;
|
||||||
gboolean custom;
|
gboolean custom;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ select_application_func_cb (GtkTreeModel *model,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_app_chooser_button_select_application (GtkAppChooserButton *self,
|
gtk_app_chooser_button_select_application (GtkAppChooserButton *self,
|
||||||
GAppInfo *info)
|
GAppInfo *info)
|
||||||
{
|
{
|
||||||
SelectAppData *data;
|
SelectAppData *data;
|
||||||
|
|
||||||
@ -217,8 +217,8 @@ gtk_app_chooser_button_select_application (GtkAppChooserButton *self,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
other_application_dialog_response_cb (GtkDialog *dialog,
|
other_application_dialog_response_cb (GtkDialog *dialog,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkAppChooserButton *self = user_data;
|
GtkAppChooserButton *self = user_data;
|
||||||
GAppInfo *info;
|
GAppInfo *info;
|
||||||
@ -251,7 +251,8 @@ other_application_item_activated_cb (GtkAppChooserButton *self)
|
|||||||
GtkWindow *toplevel;
|
GtkWindow *toplevel;
|
||||||
|
|
||||||
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
|
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)));
|
||||||
dialog = gtk_app_chooser_dialog_new_for_content_type (toplevel, GTK_DIALOG_DESTROY_WITH_PARENT,
|
dialog = gtk_app_chooser_dialog_new_for_content_type (toplevel,
|
||||||
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
self->priv->content_type);
|
self->priv->content_type);
|
||||||
|
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), gtk_window_get_modal (toplevel));
|
gtk_window_set_modal (GTK_WINDOW (dialog), gtk_window_get_modal (toplevel));
|
||||||
@ -271,7 +272,7 @@ other_application_item_activated_cb (GtkAppChooserButton *self)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_app_chooser_button_ensure_dialog_item (GtkAppChooserButton *self,
|
gtk_app_chooser_button_ensure_dialog_item (GtkAppChooserButton *self,
|
||||||
GtkTreeIter *prev_iter)
|
GtkTreeIter *prev_iter)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter, iter2;
|
GtkTreeIter iter, iter2;
|
||||||
|
|
||||||
@ -575,7 +576,6 @@ gtk_app_chooser_button_finalize (GObject *obj)
|
|||||||
g_hash_table_destroy (self->priv->custom_item_names);
|
g_hash_table_destroy (self->priv->custom_item_names);
|
||||||
g_free (self->priv->content_type);
|
g_free (self->priv->content_type);
|
||||||
g_free (self->priv->heading);
|
g_free (self->priv->heading);
|
||||||
|
|
||||||
g_object_unref (self->priv->store);
|
g_object_unref (self->priv->store);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->finalize (obj);
|
G_OBJECT_CLASS (gtk_app_chooser_button_parent_class)->finalize (obj);
|
||||||
@ -636,7 +636,6 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
|
|||||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||||
g_object_class_install_property (oclass, PROP_SHOW_DEFAULT_ITEM, pspec);
|
g_object_class_install_property (oclass, PROP_SHOW_DEFAULT_ITEM, pspec);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkAppChooserButton:heading:
|
* GtkAppChooserButton:heading:
|
||||||
*
|
*
|
||||||
@ -647,10 +646,9 @@ gtk_app_chooser_button_class_init (GtkAppChooserButtonClass *klass)
|
|||||||
P_("Heading"),
|
P_("Heading"),
|
||||||
P_("The text to show at the top of the dialog"),
|
P_("The text to show at the top of the dialog"),
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||||
g_object_class_install_property (oclass, PROP_HEADING, pspec);
|
g_object_class_install_property (oclass, PROP_HEADING, pspec);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkAppChooserButton::custom-item-activated:
|
* GtkAppChooserButton::custom-item-activated:
|
||||||
* @self: the object which received the signal
|
* @self: the object which received the signal
|
||||||
@ -676,9 +674,7 @@ gtk_app_chooser_button_init (GtkAppChooserButton *self)
|
|||||||
{
|
{
|
||||||
self->priv = gtk_app_chooser_button_get_instance_private (self);
|
self->priv = gtk_app_chooser_button_get_instance_private (self);
|
||||||
self->priv->custom_item_names =
|
self->priv->custom_item_names =
|
||||||
g_hash_table_new_full (g_str_hash, g_str_equal,
|
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||||
g_free, NULL);
|
|
||||||
|
|
||||||
self->priv->store = gtk_list_store_new (NUM_COLUMNS,
|
self->priv->store = gtk_list_store_new (NUM_COLUMNS,
|
||||||
G_TYPE_APP_INFO,
|
G_TYPE_APP_INFO,
|
||||||
G_TYPE_STRING, /* name */
|
G_TYPE_STRING, /* name */
|
||||||
@ -696,8 +692,7 @@ app_chooser_button_iter_from_custom_name (GtkAppChooserButton *self,
|
|||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gchar *custom_name = NULL;
|
gchar *custom_name = NULL;
|
||||||
|
|
||||||
if (!gtk_tree_model_get_iter_first
|
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->store), &iter))
|
||||||
(GTK_TREE_MODEL (self->priv->store), &iter))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -721,16 +716,15 @@ app_chooser_button_iter_from_custom_name (GtkAppChooserButton *self,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
real_insert_custom_item (GtkAppChooserButton *self,
|
real_insert_custom_item (GtkAppChooserButton *self,
|
||||||
const gchar *name,
|
const gchar *name,
|
||||||
const gchar *label,
|
const gchar *label,
|
||||||
GIcon *icon,
|
GIcon *icon,
|
||||||
gboolean custom,
|
gboolean custom,
|
||||||
GtkTreeIter *iter)
|
GtkTreeIter *iter)
|
||||||
{
|
{
|
||||||
if (custom)
|
if (custom)
|
||||||
{
|
{
|
||||||
if (g_hash_table_lookup (self->priv->custom_item_names,
|
if (g_hash_table_lookup (self->priv->custom_item_names, name) != NULL)
|
||||||
name) != NULL)
|
|
||||||
{
|
{
|
||||||
g_warning ("Attempting to add custom item %s to GtkAppChooserButton, "
|
g_warning ("Attempting to add custom item %s to GtkAppChooserButton, "
|
||||||
"when there's already an item with the same name", name);
|
"when there's already an item with the same name", name);
|
||||||
@ -752,13 +746,13 @@ real_insert_custom_item (GtkAppChooserButton *self,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
real_insert_separator (GtkAppChooserButton *self,
|
real_insert_separator (GtkAppChooserButton *self,
|
||||||
gboolean custom,
|
gboolean custom,
|
||||||
GtkTreeIter *iter)
|
GtkTreeIter *iter)
|
||||||
{
|
{
|
||||||
gtk_list_store_set (self->priv->store, iter,
|
gtk_list_store_set (self->priv->store, iter,
|
||||||
COLUMN_CUSTOM, custom,
|
COLUMN_CUSTOM, custom,
|
||||||
COLUMN_SEPARATOR, TRUE,
|
COLUMN_SEPARATOR, TRUE,
|
||||||
-1);
|
-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -855,11 +849,10 @@ gtk_app_chooser_button_set_active_custom_item (GtkAppChooserButton *self,
|
|||||||
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
g_return_if_fail (GTK_IS_APP_CHOOSER_BUTTON (self));
|
||||||
g_return_if_fail (name != NULL);
|
g_return_if_fail (name != NULL);
|
||||||
|
|
||||||
if (g_hash_table_lookup (self->priv->custom_item_names, name) == NULL ||
|
if (!g_hash_table_contains (self->priv->custom_item_names, name) ||
|
||||||
!app_chooser_button_iter_from_custom_name (self, name, &iter))
|
!app_chooser_button_iter_from_custom_name (self, name, &iter))
|
||||||
{
|
{
|
||||||
g_warning ("Can't find the item named %s in the app chooser.",
|
g_warning ("Can't find the item named %s in the app chooser.", name);
|
||||||
name);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user