mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
Coding style fixups
This commit adjusts the app chooser code to GTK+ coding style: - line up prototypes - remove some excess {} - remove tabs and trailing whitespace - add docs
This commit is contained in:
parent
f64448473e
commit
a498d9a9ba
@ -21,7 +21,7 @@
|
||||
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkappchooser.h"
|
||||
|
||||
@ -39,11 +39,11 @@ gtk_app_chooser_default_init (GtkAppChooserIface *iface)
|
||||
GParamSpec *pspec;
|
||||
|
||||
pspec = g_param_spec_string ("content-type",
|
||||
P_("Content type"),
|
||||
P_("The content type used by the open with object"),
|
||||
NULL,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
P_("Content type"),
|
||||
P_("The content type used by the open with object"),
|
||||
NULL,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_object_interface_install_property (iface, pspec);
|
||||
}
|
||||
|
||||
@ -55,18 +55,37 @@ gtk_app_chooser_get_content_type (GtkAppChooser *self)
|
||||
g_return_val_if_fail (GTK_IS_APP_CHOOSER (self), NULL);
|
||||
|
||||
g_object_get (self,
|
||||
"content-type", &retval,
|
||||
NULL);
|
||||
"content-type", &retval,
|
||||
NULL);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_app_chooser_get_app_info:
|
||||
* @self: a #GtkAppChooser
|
||||
*
|
||||
* Returns the currently selected application.
|
||||
*
|
||||
* Returns: (transfer full): a #GAppInfo for the currently selected
|
||||
* application, or %NULL if none is selected. Free with g_object_unref().
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
GAppInfo *
|
||||
gtk_app_chooser_get_app_info (GtkAppChooser *self)
|
||||
{
|
||||
return GTK_APP_CHOOSER_GET_IFACE (self)->get_app_info (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_app_chooser_refresh:
|
||||
* @self: a #GtkAppChooser
|
||||
*
|
||||
* Reload the list of applications.
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_app_chooser_refresh (GtkAppChooser *self)
|
||||
{
|
||||
|
@ -33,20 +33,17 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_APP_CHOOSER\
|
||||
(gtk_app_chooser_get_type ())
|
||||
#define GTK_APP_CHOOSER(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER, GtkAppChooser))
|
||||
#define GTK_IS_APP_CHOOSER(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER))
|
||||
#define GTK_TYPE_APP_CHOOSER (gtk_app_chooser_get_type ())
|
||||
#define GTK_APP_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER, GtkAppChooser))
|
||||
#define GTK_IS_APP_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER))
|
||||
|
||||
typedef struct _GtkAppChooser GtkAppChooser;
|
||||
|
||||
GType gtk_app_chooser_get_type () G_GNUC_CONST;
|
||||
GType gtk_app_chooser_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GAppInfo * gtk_app_chooser_get_app_info (GtkAppChooser *self);
|
||||
gchar * gtk_app_chooser_get_content_type (GtkAppChooser *self);
|
||||
void gtk_app_chooser_refresh (GtkAppChooser *self);
|
||||
GAppInfo * gtk_app_chooser_get_app_info (GtkAppChooser *self);
|
||||
gchar * gtk_app_chooser_get_content_type (GtkAppChooser *self);
|
||||
void gtk_app_chooser_refresh (GtkAppChooser *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkappchoosercombobox.h"
|
||||
|
||||
@ -73,14 +73,14 @@ custom_app_data_free (gpointer boxed)
|
||||
|
||||
#define CUSTOM_COMBO_DATA_TYPE custom_app_combo_data_get_type()
|
||||
G_DEFINE_BOXED_TYPE (CustomAppComboData, custom_app_combo_data,
|
||||
custom_app_data_copy,
|
||||
custom_app_data_free);
|
||||
custom_app_data_copy,
|
||||
custom_app_data_free);
|
||||
|
||||
static void app_chooser_iface_init (GtkAppChooserIface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserComboBox, gtk_app_chooser_combo_box, GTK_TYPE_COMBO_BOX,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
|
||||
app_chooser_iface_init));
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
|
||||
app_chooser_iface_init));
|
||||
|
||||
struct _GtkAppChooserComboBoxPrivate {
|
||||
gchar *content_type;
|
||||
@ -89,21 +89,21 @@ struct _GtkAppChooserComboBoxPrivate {
|
||||
|
||||
static gboolean
|
||||
row_separator_func (GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean separator;
|
||||
|
||||
gtk_tree_model_get (model, iter,
|
||||
COLUMN_SEPARATOR, &separator,
|
||||
-1);
|
||||
COLUMN_SEPARATOR, &separator,
|
||||
-1);
|
||||
|
||||
return separator;
|
||||
}
|
||||
|
||||
static void
|
||||
get_first_iter (GtkListStore *store,
|
||||
GtkTreeIter *iter)
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkTreeIter iter2;
|
||||
|
||||
@ -138,27 +138,27 @@ gtk_app_chooser_combo_box_populate (GtkAppChooserComboBox *self)
|
||||
icon = g_app_info_get_icon (app);
|
||||
|
||||
if (icon == NULL)
|
||||
icon = g_themed_icon_new ("x-application/executable");
|
||||
icon = g_themed_icon_new ("application-x-executable");
|
||||
else
|
||||
g_object_ref (icon);
|
||||
g_object_ref (icon);
|
||||
|
||||
if (first)
|
||||
{
|
||||
get_first_iter (self->priv->store, &iter);
|
||||
first = FALSE;
|
||||
}
|
||||
{
|
||||
get_first_iter (self->priv->store, &iter);
|
||||
first = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_list_store_insert_after (self->priv->store, &iter2, &iter);
|
||||
iter = iter2;
|
||||
}
|
||||
{
|
||||
gtk_list_store_insert_after (self->priv->store, &iter2, &iter);
|
||||
iter = iter2;
|
||||
}
|
||||
|
||||
gtk_list_store_set (self->priv->store, &iter,
|
||||
COLUMN_APP_INFO, app,
|
||||
COLUMN_NAME, g_app_info_get_display_name (app),
|
||||
COLUMN_ICON, icon,
|
||||
COLUMN_CUSTOM, FALSE,
|
||||
-1);
|
||||
COLUMN_APP_INFO, app,
|
||||
COLUMN_NAME, g_app_info_get_display_name (app),
|
||||
COLUMN_ICON, icon,
|
||||
COLUMN_CUSTOM, FALSE,
|
||||
-1);
|
||||
|
||||
g_object_unref (icon);
|
||||
}
|
||||
@ -172,30 +172,30 @@ gtk_app_chooser_combo_box_build_ui (GtkAppChooserComboBox *self)
|
||||
GtkCellRenderer *cell;
|
||||
|
||||
self->priv->store = gtk_list_store_new (NUM_COLUMNS,
|
||||
G_TYPE_APP_INFO,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_ICON,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN,
|
||||
CUSTOM_COMBO_DATA_TYPE);
|
||||
G_TYPE_APP_INFO,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_ICON,
|
||||
G_TYPE_BOOLEAN,
|
||||
G_TYPE_BOOLEAN,
|
||||
CUSTOM_COMBO_DATA_TYPE);
|
||||
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (self),
|
||||
GTK_TREE_MODEL (self->priv->store));
|
||||
GTK_TREE_MODEL (self->priv->store));
|
||||
|
||||
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (self),
|
||||
row_separator_func, NULL, NULL);
|
||||
row_separator_func, NULL, NULL);
|
||||
|
||||
cell = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), cell, FALSE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), cell,
|
||||
"gicon", COLUMN_ICON,
|
||||
NULL);
|
||||
"gicon", COLUMN_ICON,
|
||||
NULL);
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self), cell, TRUE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (self), cell,
|
||||
"text", COLUMN_NAME,
|
||||
NULL);
|
||||
"text", COLUMN_NAME,
|
||||
NULL);
|
||||
|
||||
gtk_app_chooser_combo_box_populate (self);
|
||||
}
|
||||
@ -214,8 +214,8 @@ gtk_app_chooser_combo_box_remove_non_custom (GtkAppChooserComboBox *self)
|
||||
|
||||
do {
|
||||
gtk_tree_model_get (model, &iter,
|
||||
COLUMN_CUSTOM, &custom,
|
||||
-1);
|
||||
COLUMN_CUSTOM, &custom,
|
||||
-1);
|
||||
if (custom)
|
||||
res = gtk_tree_model_iter_next (model, &iter);
|
||||
else
|
||||
@ -235,10 +235,10 @@ gtk_app_chooser_combo_box_changed (GtkComboBox *object)
|
||||
return;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
|
||||
COLUMN_CUSTOM, &custom,
|
||||
COLUMN_SEPARATOR, &separator,
|
||||
COLUMN_CALLBACK, &custom_data,
|
||||
-1);
|
||||
COLUMN_CUSTOM, &custom,
|
||||
COLUMN_SEPARATOR, &separator,
|
||||
COLUMN_CALLBACK, &custom_data,
|
||||
-1);
|
||||
|
||||
if (custom && !separator &&
|
||||
custom_data != NULL && custom_data->func != NULL)
|
||||
@ -265,8 +265,8 @@ gtk_app_chooser_combo_box_get_app_info (GtkAppChooser *object)
|
||||
return NULL;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (self->priv->store), &iter,
|
||||
COLUMN_APP_INFO, &info,
|
||||
-1);
|
||||
COLUMN_APP_INFO, &info,
|
||||
-1);
|
||||
|
||||
return info;
|
||||
}
|
||||
@ -285,10 +285,10 @@ gtk_app_chooser_combo_box_constructed (GObject *obj)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_app_chooser_combo_box_set_property (GObject *obj,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_app_chooser_combo_box_set_property (GObject *obj,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserComboBox *self = GTK_APP_CHOOSER_COMBO_BOX (obj);
|
||||
|
||||
@ -304,10 +304,10 @@ gtk_app_chooser_combo_box_set_property (GObject *obj,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_app_chooser_combo_box_get_property (GObject *obj,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_app_chooser_combo_box_get_property (GObject *obj,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserComboBox *self = GTK_APP_CHOOSER_COMBO_BOX (obj);
|
||||
|
||||
@ -360,21 +360,40 @@ gtk_app_chooser_combo_box_class_init (GtkAppChooserComboBoxClass *klass)
|
||||
static void
|
||||
gtk_app_chooser_combo_box_init (GtkAppChooserComboBox *self)
|
||||
{
|
||||
self->priv =
|
||||
G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_COMBO_BOX,
|
||||
GtkAppChooserComboBoxPrivate);
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_COMBO_BOX,
|
||||
GtkAppChooserComboBoxPrivate);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_app_chooser_combo_box_new:
|
||||
* @content_type: the content type to show applications for
|
||||
*
|
||||
* Creates a new #GtkAppChooserComboBox for applications
|
||||
* that can handle content of the given type.
|
||||
*
|
||||
* Returns: a newly created #GtkAppChooserComboBox
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_app_chooser_combo_box_new (const gchar *content_type)
|
||||
{
|
||||
g_return_val_if_fail (content_type != NULL, NULL);
|
||||
|
||||
return g_object_new (GTK_TYPE_APP_CHOOSER_COMBO_BOX,
|
||||
"content-type", content_type,
|
||||
NULL);
|
||||
"content-type", content_type,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_app_chooser_combo_box_append_separator:
|
||||
* @self: a #GtkAppChooserComboBox
|
||||
*
|
||||
* Appends a separator to the list of applications that is shown
|
||||
* in the popup.
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_app_chooser_combo_box_append_separator (GtkAppChooserComboBox *self)
|
||||
{
|
||||
@ -384,17 +403,30 @@ gtk_app_chooser_combo_box_append_separator (GtkAppChooserComboBox *self)
|
||||
|
||||
gtk_list_store_append (self->priv->store, &iter);
|
||||
gtk_list_store_set (self->priv->store, &iter,
|
||||
COLUMN_CUSTOM, TRUE,
|
||||
COLUMN_SEPARATOR, TRUE,
|
||||
-1);
|
||||
COLUMN_CUSTOM, TRUE,
|
||||
COLUMN_SEPARATOR, TRUE,
|
||||
-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_app_chooser_combo_box_append_custom_item:
|
||||
* @self: a #GtkAppChooserComboBox
|
||||
* @label: the label for the custom item
|
||||
* @icon: the icon for the custom item
|
||||
* @func: callback to call if the item is activated
|
||||
* @user_data: user data for @func
|
||||
*
|
||||
* Appends a custom item to the list of applications that is shown
|
||||
* in the popup. See also gtk_app_chooser_combo_box_append_separator().
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
void
|
||||
gtk_app_chooser_combo_box_append_custom_item (GtkAppChooserComboBox *self,
|
||||
const gchar *label,
|
||||
GIcon *icon,
|
||||
GtkAppChooserComboBoxItemFunc func,
|
||||
gpointer user_data)
|
||||
gtk_app_chooser_combo_box_append_custom_item (GtkAppChooserComboBox *self,
|
||||
const gchar *label,
|
||||
GIcon *icon,
|
||||
GtkAppChooserComboBoxItemFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
CustomAppComboData *data;
|
||||
@ -405,10 +437,10 @@ gtk_app_chooser_combo_box_append_custom_item (GtkAppChooserComboBox *self,
|
||||
|
||||
gtk_list_store_append (self->priv->store, &iter);
|
||||
gtk_list_store_set (self->priv->store, &iter,
|
||||
COLUMN_NAME, label,
|
||||
COLUMN_ICON, icon,
|
||||
COLUMN_CALLBACK, data,
|
||||
COLUMN_CUSTOM, TRUE,
|
||||
COLUMN_SEPARATOR, FALSE,
|
||||
-1);
|
||||
COLUMN_NAME, label,
|
||||
COLUMN_ICON, icon,
|
||||
COLUMN_CALLBACK, data,
|
||||
COLUMN_CUSTOM, TRUE,
|
||||
COLUMN_SEPARATOR, FALSE,
|
||||
-1);
|
||||
}
|
||||
|
@ -31,25 +31,19 @@
|
||||
#include <gtk/gtkcombobox.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define GTK_TYPE_APP_CHOOSER_COMBO_BOX\
|
||||
(gtk_app_chooser_combo_box_get_type ())
|
||||
#define GTK_APP_CHOOSER_COMBO_BOX(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_COMBO_BOX, GtkAppChooserComboBox))
|
||||
#define GTK_APP_CHOOSER_COMBO_BOX_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_COMBO_BOX, GtkAppChooserComboBoxClass))
|
||||
#define GTK_IS_APP_CHOOSER_COMBO_BOX(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_COMBO_BOX))
|
||||
#define GTK_IS_APP_CHOOSER_COMBO_BOX_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_COMBO_BOX))
|
||||
#define GTK_APP_CHOOSER_COMBO_BOX_GET_CLASS(obj)\
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_COMBO_BOX, GtkAppChooserComboBoxClass))
|
||||
#define GTK_TYPE_APP_CHOOSER_COMBO_BOX (gtk_app_chooser_combo_box_get_type ())
|
||||
#define GTK_APP_CHOOSER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_COMBO_BOX, GtkAppChooserComboBox))
|
||||
#define GTK_APP_CHOOSER_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_COMBO_BOX, GtkAppChooserComboBoxClass))
|
||||
#define GTK_IS_APP_CHOOSER_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_COMBO_BOX))
|
||||
#define GTK_IS_APP_CHOOSER_COMBO_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_COMBO_BOX))
|
||||
#define GTK_APP_CHOOSER_COMBO_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_COMBO_BOX, GtkAppChooserComboBoxClass))
|
||||
|
||||
typedef struct _GtkAppChooserComboBox GtkAppChooserComboBox;
|
||||
typedef struct _GtkAppChooserComboBoxClass GtkAppChooserComboBoxClass;
|
||||
typedef struct _GtkAppChooserComboBoxPrivate GtkAppChooserComboBoxPrivate;
|
||||
|
||||
typedef void (* GtkAppChooserComboBoxItemFunc) (GtkAppChooserComboBox *self,
|
||||
gpointer user_data);
|
||||
gpointer user_data);
|
||||
|
||||
struct _GtkAppChooserComboBox {
|
||||
GtkComboBox parent;
|
||||
@ -65,15 +59,15 @@ struct _GtkAppChooserComboBoxClass {
|
||||
gpointer padding[16];
|
||||
};
|
||||
|
||||
GType gtk_app_chooser_combo_box_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_app_chooser_combo_box_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gtk_app_chooser_combo_box_new (const gchar *content_type);
|
||||
GtkWidget * gtk_app_chooser_combo_box_new (const gchar *content_type);
|
||||
|
||||
void gtk_app_chooser_combo_box_append_separator (GtkAppChooserComboBox *self);
|
||||
void gtk_app_chooser_combo_box_append_custom_item (GtkAppChooserComboBox *self,
|
||||
const gchar *label,
|
||||
GIcon *icon,
|
||||
GtkAppChooserComboBoxItemFunc func,
|
||||
gpointer user_data);
|
||||
void gtk_app_chooser_combo_box_append_separator (GtkAppChooserComboBox *self);
|
||||
void gtk_app_chooser_combo_box_append_custom_item (GtkAppChooserComboBox *self,
|
||||
const gchar *label,
|
||||
GIcon *icon,
|
||||
GtkAppChooserComboBoxItemFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
#endif /* __GTK_APP_CHOOSER_COMBO_BOX_H__ */
|
||||
|
@ -24,7 +24,7 @@
|
||||
* Cosimo Cecchi <ccecchi@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkappchooserdialog.h"
|
||||
|
||||
@ -32,10 +32,17 @@
|
||||
#include "gtkappchooser.h"
|
||||
#include "gtkappchooseronline.h"
|
||||
#include "gtkappchooserprivate.h"
|
||||
#include "gtkappchooserprivate.h"
|
||||
|
||||
#include "gtkmessagedialog.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkbbox.h"
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkmenuitem.h"
|
||||
#include "gtkstock.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define sure_string(s) ((const char *) ((s) != NULL ? (s) : ""))
|
||||
@ -64,36 +71,36 @@ enum {
|
||||
|
||||
static void gtk_app_chooser_dialog_iface_init (GtkAppChooserIface *iface);
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserDialog, gtk_app_chooser_dialog, GTK_TYPE_DIALOG,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
|
||||
gtk_app_chooser_dialog_iface_init));
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
|
||||
gtk_app_chooser_dialog_iface_init));
|
||||
|
||||
static void
|
||||
show_error_dialog (const gchar *primary,
|
||||
const gchar *secondary,
|
||||
GtkWindow *parent)
|
||||
const gchar *secondary,
|
||||
GtkWindow *parent)
|
||||
{
|
||||
GtkWidget *message_dialog;
|
||||
|
||||
message_dialog = gtk_message_dialog_new (parent, 0,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_OK,
|
||||
NULL);
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_OK,
|
||||
NULL);
|
||||
g_object_set (message_dialog,
|
||||
"text", primary,
|
||||
"secondary-text", secondary,
|
||||
NULL);
|
||||
"text", primary,
|
||||
"secondary-text", secondary,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (message_dialog), GTK_RESPONSE_OK);
|
||||
|
||||
gtk_widget_show (message_dialog);
|
||||
|
||||
g_signal_connect (message_dialog, "response",
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
search_for_mimetype_ready_cb (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
search_for_mimetype_ready_cb (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserOnline *online = GTK_APP_CHOOSER_ONLINE (source);
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
@ -104,7 +111,7 @@ search_for_mimetype_ready_cb (GObject *source,
|
||||
if (error != NULL)
|
||||
{
|
||||
show_error_dialog (_("Failed to look for applications online"),
|
||||
error->message, GTK_WINDOW (self));
|
||||
error->message, GTK_WINDOW (self));
|
||||
g_error_free (error);
|
||||
}
|
||||
else
|
||||
@ -117,7 +124,7 @@ search_for_mimetype_ready_cb (GObject *source,
|
||||
|
||||
static void
|
||||
online_button_clicked_cb (GtkButton *b,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserOnline *online;
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
@ -125,10 +132,10 @@ online_button_clicked_cb (GtkButton *b,
|
||||
online = gtk_app_chooser_online_get_default ();
|
||||
|
||||
gtk_app_chooser_online_search_for_mimetype_async (online,
|
||||
self->priv->content_type,
|
||||
GTK_WINDOW (self),
|
||||
search_for_mimetype_ready_cb,
|
||||
self);
|
||||
self->priv->content_type,
|
||||
GTK_WINDOW (self),
|
||||
search_for_mimetype_ready_cb,
|
||||
self);
|
||||
}
|
||||
|
||||
/* An application is valid if:
|
||||
@ -137,8 +144,8 @@ online_button_clicked_cb (GtkButton *b,
|
||||
* 2) The user has permissions to run the file
|
||||
*/
|
||||
static gboolean
|
||||
check_application (GtkAppChooserDialog *self,
|
||||
GAppInfo **app_out)
|
||||
check_application (GtkAppChooserDialog *self,
|
||||
GAppInfo **app_out)
|
||||
{
|
||||
const char *command;
|
||||
char *path = NULL;
|
||||
@ -158,8 +165,8 @@ check_application (GtkAppChooserDialog *self,
|
||||
if (error)
|
||||
{
|
||||
show_error_dialog (_("Could not run application"),
|
||||
error->message,
|
||||
GTK_WINDOW (self));
|
||||
error->message,
|
||||
GTK_WINDOW (self));
|
||||
g_error_free (error);
|
||||
retval = FALSE;
|
||||
goto cleanup;
|
||||
@ -171,11 +178,11 @@ check_application (GtkAppChooserDialog *self,
|
||||
char *error_message;
|
||||
|
||||
error_message = g_strdup_printf (_("Could not find '%s'"),
|
||||
argv[0]);
|
||||
argv[0]);
|
||||
|
||||
show_error_dialog (_("Could not find application"),
|
||||
error_message,
|
||||
GTK_WINDOW (self));
|
||||
error_message,
|
||||
GTK_WINDOW (self));
|
||||
g_free (error_message);
|
||||
retval = FALSE;
|
||||
goto cleanup;
|
||||
@ -199,16 +206,16 @@ add_or_find_application (GtkAppChooserDialog *self)
|
||||
|
||||
/* we don't care about reporting errors here */
|
||||
g_app_info_add_supports_type (app,
|
||||
self->priv->content_type,
|
||||
NULL);
|
||||
self->priv->content_type,
|
||||
NULL);
|
||||
|
||||
g_object_unref (app);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_app_chooser_dialog_response (GtkDialog *dialog,
|
||||
gint response_id,
|
||||
gpointer user_data)
|
||||
gint response_id,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (dialog);
|
||||
|
||||
@ -224,8 +231,8 @@ gtk_app_chooser_dialog_response (GtkDialog *dialog,
|
||||
|
||||
static void
|
||||
widget_application_selected_cb (GtkAppChooserWidget *widget,
|
||||
GAppInfo *app_info,
|
||||
gpointer user_data)
|
||||
GAppInfo *app_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
|
||||
@ -234,8 +241,8 @@ widget_application_selected_cb (GtkAppChooserWidget *widget,
|
||||
|
||||
static void
|
||||
widget_application_activated_cb (GtkAppChooserWidget *widget,
|
||||
GAppInfo *app_info,
|
||||
gpointer user_data)
|
||||
GAppInfo *app_info,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
|
||||
@ -258,7 +265,12 @@ get_extension (const char *basename)
|
||||
static void
|
||||
set_dialog_properties (GtkAppChooserDialog *self)
|
||||
{
|
||||
char *label, *name, *extension, *description, *default_text, *string;
|
||||
gchar *label;
|
||||
gchar *name;
|
||||
gchar *extension;
|
||||
gchar *description;
|
||||
gchar *default_text;
|
||||
gchar *string;
|
||||
PangoFontDescription *font_desc;
|
||||
|
||||
name = NULL;
|
||||
@ -280,17 +292,17 @@ set_dialog_properties (GtkAppChooserDialog *self)
|
||||
/* Translators: %s is a filename */
|
||||
label = g_strdup_printf (_("Select an application to open \"%s\""), name);
|
||||
string = g_strdup_printf (_("No applications available to open \"%s\""),
|
||||
name);
|
||||
name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Translators: %s is a file type description */
|
||||
label = g_strdup_printf (_("Select an application for \"%s\" files"),
|
||||
g_content_type_is_unknown (self->priv->content_type) ?
|
||||
self->priv->content_type : description);
|
||||
g_content_type_is_unknown (self->priv->content_type) ?
|
||||
self->priv->content_type : description);
|
||||
string = g_strdup_printf (_("No applications available to open \"%s\" files"),
|
||||
g_content_type_is_unknown (self->priv->content_type) ?
|
||||
self->priv->content_type : description);
|
||||
g_content_type_is_unknown (self->priv->content_type) ?
|
||||
self->priv->content_type : description);
|
||||
}
|
||||
|
||||
font_desc = pango_font_description_new ();
|
||||
@ -301,12 +313,12 @@ set_dialog_properties (GtkAppChooserDialog *self)
|
||||
gtk_label_set_markup (GTK_LABEL (self->priv->label), label);
|
||||
|
||||
default_text = g_strdup_printf ("<big><b>%s</b></big>\n%s",
|
||||
string,
|
||||
_("Click \"Show other applications\", for more options, or "
|
||||
"\"Find applications online\" to install a new application"));
|
||||
string,
|
||||
_("Click \"Show other applications\", for more options, or "
|
||||
"\"Find applications online\" to install a new application"));
|
||||
|
||||
gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget),
|
||||
default_text);
|
||||
default_text);
|
||||
|
||||
g_free (label);
|
||||
g_free (name);
|
||||
@ -318,24 +330,24 @@ set_dialog_properties (GtkAppChooserDialog *self)
|
||||
|
||||
static void
|
||||
show_more_button_clicked_cb (GtkButton *button,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
|
||||
g_object_set (self->priv->app_chooser_widget,
|
||||
"show-recommended", TRUE,
|
||||
"show-fallback", TRUE,
|
||||
"show-other", TRUE,
|
||||
NULL);
|
||||
"show-recommended", TRUE,
|
||||
"show-fallback", TRUE,
|
||||
"show-other", TRUE,
|
||||
NULL);
|
||||
|
||||
gtk_widget_hide (self->priv->show_more_button);
|
||||
self->priv->show_more_clicked = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
widget_notify_for_button_cb (GObject *source,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
widget_notify_for_button_cb (GObject *source,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
GtkAppChooserWidget *widget = GTK_APP_CHOOSER_WIDGET (source);
|
||||
@ -350,7 +362,7 @@ widget_notify_for_button_cb (GObject *source,
|
||||
|
||||
static void
|
||||
forget_menu_item_activate_cb (GtkMenuItem *item,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
GAppInfo *info;
|
||||
@ -359,8 +371,7 @@ forget_menu_item_activate_cb (GtkMenuItem *item,
|
||||
|
||||
if (info != NULL)
|
||||
{
|
||||
g_app_info_remove_supports_type (info, self->priv->content_type,
|
||||
NULL);
|
||||
g_app_info_remove_supports_type (info, self->priv->content_type, NULL);
|
||||
|
||||
gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
|
||||
|
||||
@ -377,16 +388,16 @@ build_forget_menu_item (GtkAppChooserDialog *self)
|
||||
gtk_widget_show (retval);
|
||||
|
||||
g_signal_connect (retval, "activate",
|
||||
G_CALLBACK (forget_menu_item_activate_cb), self);
|
||||
G_CALLBACK (forget_menu_item_activate_cb), self);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
widget_populate_popup_cb (GtkAppChooserWidget *widget,
|
||||
GtkMenu *menu,
|
||||
GAppInfo *info,
|
||||
gpointer user_data)
|
||||
GtkMenu *menu,
|
||||
GAppInfo *info,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserDialog *self = user_data;
|
||||
GtkWidget *menu_item;
|
||||
@ -421,7 +432,7 @@ build_dialog_ui (GtkAppChooserDialog *self)
|
||||
gtk_misc_set_alignment (GTK_MISC (self->priv->label), 0, 0.5);
|
||||
gtk_label_set_line_wrap (GTK_LABEL (self->priv->label), TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), self->priv->label,
|
||||
FALSE, FALSE, 0);
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (self->priv->label);
|
||||
|
||||
self->priv->app_chooser_widget =
|
||||
@ -430,28 +441,28 @@ build_dialog_ui (GtkAppChooserDialog *self)
|
||||
gtk_widget_show (self->priv->app_chooser_widget);
|
||||
|
||||
g_signal_connect (self->priv->app_chooser_widget, "application-selected",
|
||||
G_CALLBACK (widget_application_selected_cb), self);
|
||||
G_CALLBACK (widget_application_selected_cb), self);
|
||||
g_signal_connect (self->priv->app_chooser_widget, "application-activated",
|
||||
G_CALLBACK (widget_application_activated_cb), self);
|
||||
G_CALLBACK (widget_application_activated_cb), self);
|
||||
g_signal_connect (self->priv->app_chooser_widget, "notify::show-all",
|
||||
G_CALLBACK (widget_notify_for_button_cb), self);
|
||||
G_CALLBACK (widget_notify_for_button_cb), self);
|
||||
g_signal_connect (self->priv->app_chooser_widget, "populate-popup",
|
||||
G_CALLBACK (widget_populate_popup_cb), self);
|
||||
G_CALLBACK (widget_populate_popup_cb), self);
|
||||
|
||||
button = gtk_button_new_with_label (_("Show other applications"));
|
||||
self->priv->show_more_button = button;
|
||||
w = gtk_image_new_from_stock (GTK_STOCK_ADD,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
gtk_button_set_image (GTK_BUTTON (button), w);
|
||||
gtk_box_pack_start (GTK_BOX (self->priv->app_chooser_widget), button, FALSE, FALSE, 6);
|
||||
gtk_widget_show_all (button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (show_more_button_clicked_cb), self);
|
||||
G_CALLBACK (show_more_button_clicked_cb), self);
|
||||
|
||||
gtk_dialog_add_button (GTK_DIALOG (self),
|
||||
GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL);
|
||||
GTK_STOCK_CANCEL,
|
||||
GTK_RESPONSE_CANCEL);
|
||||
|
||||
/* Create a custom stock icon */
|
||||
self->priv->button = gtk_button_new ();
|
||||
@ -463,31 +474,31 @@ build_dialog_ui (GtkAppChooserDialog *self)
|
||||
self->priv->open_label = label;
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (self->priv->button),
|
||||
self->priv->open_label);
|
||||
self->priv->open_label);
|
||||
|
||||
gtk_widget_show (self->priv->button);
|
||||
gtk_widget_set_can_default (self->priv->button, TRUE);
|
||||
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (self),
|
||||
self->priv->button, GTK_RESPONSE_OK);
|
||||
self->priv->button, GTK_RESPONSE_OK);
|
||||
|
||||
action_area = gtk_dialog_get_action_area (GTK_DIALOG (self));
|
||||
self->priv->online_button = gtk_button_new_with_label (_("Find applications online"));
|
||||
gtk_box_pack_start (GTK_BOX (action_area), self->priv->online_button,
|
||||
FALSE, FALSE, 0);
|
||||
FALSE, FALSE, 0);
|
||||
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), self->priv->online_button,
|
||||
TRUE);
|
||||
TRUE);
|
||||
gtk_widget_show (self->priv->online_button);
|
||||
g_signal_connect (self->priv->online_button, "clicked",
|
||||
G_CALLBACK (online_button_clicked_cb), self);
|
||||
G_CALLBACK (online_button_clicked_cb), self);
|
||||
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (self),
|
||||
GTK_RESPONSE_OK);
|
||||
GTK_RESPONSE_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
set_gfile_and_content_type (GtkAppChooserDialog *self,
|
||||
GFile *file)
|
||||
GFile *file)
|
||||
{
|
||||
GFileInfo *info;
|
||||
|
||||
@ -497,8 +508,8 @@ set_gfile_and_content_type (GtkAppChooserDialog *self,
|
||||
self->priv->gfile = g_object_ref (file);
|
||||
|
||||
info = g_file_query_info (self->priv->gfile,
|
||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
|
||||
0, NULL, NULL);
|
||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
|
||||
0, NULL, NULL);
|
||||
self->priv->content_type = g_strdup (g_file_info_get_content_type (info));
|
||||
|
||||
g_object_unref (info);
|
||||
@ -530,7 +541,7 @@ gtk_app_chooser_dialog_constructed (GObject *object)
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
|
||||
g_assert (self->priv->content_type != NULL ||
|
||||
self->priv->gfile != NULL);
|
||||
self->priv->gfile != NULL);
|
||||
|
||||
if (G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->constructed != NULL)
|
||||
G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->constructed (object);
|
||||
@ -553,10 +564,10 @@ gtk_app_chooser_dialog_finalize (GObject *object)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_app_chooser_dialog_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_app_chooser_dialog_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
|
||||
@ -568,7 +579,7 @@ gtk_app_chooser_dialog_set_property (GObject *object,
|
||||
case PROP_CONTENT_TYPE:
|
||||
/* don't try to override a value previously set with the GFile */
|
||||
if (self->priv->content_type == NULL)
|
||||
self->priv->content_type = g_value_dup_string (value);
|
||||
self->priv->content_type = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
@ -577,10 +588,10 @@ gtk_app_chooser_dialog_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_app_chooser_dialog_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_app_chooser_dialog_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
||||
|
||||
@ -588,7 +599,7 @@ gtk_app_chooser_dialog_get_property (GObject *object,
|
||||
{
|
||||
case PROP_GFILE:
|
||||
if (self->priv->gfile != NULL)
|
||||
g_value_set_object (value, self->priv->gfile);
|
||||
g_value_set_object (value, self->priv->gfile);
|
||||
break;
|
||||
case PROP_CONTENT_TYPE:
|
||||
g_value_set_string (value, self->priv->content_type);
|
||||
@ -621,11 +632,11 @@ gtk_app_chooser_dialog_class_init (GtkAppChooserDialogClass *klass)
|
||||
g_object_class_override_property (gobject_class, PROP_CONTENT_TYPE, "content-type");
|
||||
|
||||
pspec = g_param_spec_object ("gfile",
|
||||
P_("GFile"),
|
||||
P_("The GFile used by the open with dialog"),
|
||||
G_TYPE_FILE,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
P_("GFile"),
|
||||
P_("The GFile used by the open with dialog"),
|
||||
G_TYPE_FILE,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_property (gobject_class, PROP_GFILE, pspec);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GtkAppChooserDialogPrivate));
|
||||
@ -635,23 +646,22 @@ static void
|
||||
gtk_app_chooser_dialog_init (GtkAppChooserDialog *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_DIALOG,
|
||||
GtkAppChooserDialogPrivate);
|
||||
GtkAppChooserDialogPrivate);
|
||||
|
||||
/* we can't override the class signal handler here, as it's a RUN_LAST;
|
||||
* we want our signal handler instead to be executed before any user code.
|
||||
*/
|
||||
g_signal_connect (self, "response",
|
||||
G_CALLBACK (gtk_app_chooser_dialog_response), NULL);
|
||||
G_CALLBACK (gtk_app_chooser_dialog_response), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
set_parent_and_flags (GtkWidget *dialog,
|
||||
GtkWindow *parent,
|
||||
GtkDialogFlags flags)
|
||||
set_parent_and_flags (GtkWidget *dialog,
|
||||
GtkWindow *parent,
|
||||
GtkDialogFlags flags)
|
||||
{
|
||||
if (parent != NULL)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
||||
parent);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
||||
|
||||
if (flags & GTK_DIALOG_MODAL)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
@ -666,25 +676,25 @@ set_parent_and_flags (GtkWidget *dialog,
|
||||
* @flags: flags for this dialog
|
||||
* @file: a #GFile
|
||||
*
|
||||
* Creates a new #GtkAppChooserDialog for the provided #GFile, to allow
|
||||
* the user to select an application for it.
|
||||
* Creates a new #GtkAppChooserDialog for the provided #GFile,
|
||||
* to allow the user to select an application for it.
|
||||
*
|
||||
* Returns: a newly created #GtkAppChooserDialog
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
GtkWidget *
|
||||
gtk_app_chooser_dialog_new (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
GFile *file)
|
||||
gtk_app_chooser_dialog_new (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
GFile *file)
|
||||
{
|
||||
GtkWidget *retval;
|
||||
|
||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||
|
||||
retval = g_object_new (GTK_TYPE_APP_CHOOSER_DIALOG,
|
||||
"gfile", file,
|
||||
NULL);
|
||||
"gfile", file,
|
||||
NULL);
|
||||
|
||||
set_parent_and_flags (retval, parent, flags);
|
||||
|
||||
@ -697,31 +707,41 @@ gtk_app_chooser_dialog_new (GtkWindow *parent,
|
||||
* @flags: flags for this dialog
|
||||
* @content_type: a content type string
|
||||
*
|
||||
* Creates a new #GtkAppChooserDialog for the provided content type, to allow
|
||||
* the user to select an application for it.
|
||||
* Creates a new #GtkAppChooserDialog for the provided content type,
|
||||
* to allow the user to select an application for it.
|
||||
*
|
||||
* Returns: a newly created #GtkAppChooserDialog
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
GtkWidget *
|
||||
gtk_app_chooser_dialog_new_for_content_type (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
const gchar *content_type)
|
||||
gtk_app_chooser_dialog_new_for_content_type (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
const gchar *content_type)
|
||||
{
|
||||
GtkWidget *retval;
|
||||
|
||||
g_return_val_if_fail (content_type != NULL, NULL);
|
||||
|
||||
retval = g_object_new (GTK_TYPE_APP_CHOOSER_DIALOG,
|
||||
"content-type", content_type,
|
||||
NULL);
|
||||
"content-type", content_type,
|
||||
NULL);
|
||||
|
||||
set_parent_and_flags (retval, parent, flags);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_app_chooser_dialog_get_widget:
|
||||
* @self: a #GtkAppChooserDialog
|
||||
*
|
||||
* Returns the #GtkAppChooserWidget of this dialog.
|
||||
*
|
||||
* Returns: the #GtkAppChooserWidget of @self
|
||||
*
|
||||
* Since: 3.0
|
||||
*/
|
||||
GtkWidget *
|
||||
gtk_app_chooser_dialog_get_widget (GtkAppChooserDialog *self)
|
||||
{
|
||||
|
@ -34,18 +34,12 @@
|
||||
#include <gtk/gtkdialog.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define GTK_TYPE_APP_CHOOSER_DIALOG\
|
||||
(gtk_app_chooser_dialog_get_type ())
|
||||
#define GTK_APP_CHOOSER_DIALOG(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_DIALOG, GtkAppChooserDialog))
|
||||
#define GTK_APP_CHOOSER_DIALOG_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_DIALOG, GtkAppChooserDialogClass))
|
||||
#define GTK_IS_APP_CHOOSER_DIALOG(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_DIALOG))
|
||||
#define GTK_IS_APP_CHOOSER_DIALOG_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_DIALOG))
|
||||
#define GTK_APP_CHOOSER_DIALOG_GET_CLASS(obj)\
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_DIALOG, GtkAppChooserDialogClass))
|
||||
#define GTK_TYPE_APP_CHOOSER_DIALOG (gtk_app_chooser_dialog_get_type ())
|
||||
#define GTK_APP_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_DIALOG, GtkAppChooserDialog))
|
||||
#define GTK_APP_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_DIALOG, GtkAppChooserDialogClass))
|
||||
#define GTK_IS_APP_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_DIALOG))
|
||||
#define GTK_IS_APP_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_DIALOG))
|
||||
#define GTK_APP_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_DIALOG, GtkAppChooserDialogClass))
|
||||
|
||||
typedef struct _GtkAppChooserDialog GtkAppChooserDialog;
|
||||
typedef struct _GtkAppChooserDialogClass GtkAppChooserDialogClass;
|
||||
@ -65,15 +59,15 @@ struct _GtkAppChooserDialogClass {
|
||||
gpointer padding[16];
|
||||
};
|
||||
|
||||
GType gtk_app_chooser_dialog_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_app_chooser_dialog_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gtk_app_chooser_dialog_new (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
GFile *file);
|
||||
GtkWidget * gtk_app_chooser_dialog_new_for_content_type (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
const gchar *content_type);
|
||||
GtkWidget * gtk_app_chooser_dialog_new (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
GFile *file);
|
||||
GtkWidget * gtk_app_chooser_dialog_new_for_content_type (GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
const gchar *content_type);
|
||||
|
||||
GtkWidget * gtk_app_chooser_dialog_get_widget (GtkAppChooserDialog *self);
|
||||
GtkWidget * gtk_app_chooser_dialog_get_widget (GtkAppChooserDialog *self);
|
||||
|
||||
#endif /* __GTK_APP_CHOOSER_DIALOG_H__ */
|
||||
|
@ -21,7 +21,7 @@
|
||||
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkappchoosermodule.h"
|
||||
|
||||
@ -45,7 +45,7 @@ _gtk_app_chooser_module_ensure (void)
|
||||
G_LOCK (registered_ep);
|
||||
|
||||
if (!registered_ep)
|
||||
{
|
||||
{
|
||||
registered_ep = TRUE;
|
||||
|
||||
ep = g_io_extension_point_register ("gtkappchooser-online");
|
||||
|
@ -21,7 +21,7 @@
|
||||
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkappchooseronline.h"
|
||||
|
||||
@ -55,13 +55,11 @@ gtk_app_chooser_online_get_default (void)
|
||||
{
|
||||
/* pick the first */
|
||||
extension = extensions->data;
|
||||
retval = g_object_new (g_io_extension_get_type (extension),
|
||||
NULL);
|
||||
retval = g_object_new (g_io_extension_get_type (extension), NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = g_object_new (GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY,
|
||||
NULL);
|
||||
retval = g_object_new (GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY, NULL);
|
||||
}
|
||||
|
||||
return retval;
|
||||
@ -69,10 +67,10 @@ gtk_app_chooser_online_get_default (void)
|
||||
|
||||
void
|
||||
gtk_app_chooser_online_search_for_mimetype_async (GtkAppChooserOnline *self,
|
||||
const gchar *content_type,
|
||||
GtkWindow *parent,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
const gchar *content_type,
|
||||
GtkWindow *parent,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserOnlineInterface *iface;
|
||||
|
||||
@ -84,9 +82,9 @@ gtk_app_chooser_online_search_for_mimetype_async (GtkAppChooserOnline *self,
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_app_chooser_online_search_for_mimetype_finish (GtkAppChooserOnline *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
gtk_app_chooser_online_search_for_mimetype_finish (GtkAppChooserOnline *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GtkAppChooserOnlineInterface *iface;
|
||||
|
||||
|
@ -31,14 +31,10 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_APP_CHOOSER_ONLINE\
|
||||
(gtk_app_chooser_online_get_type ())
|
||||
#define GTK_APP_CHOOSER_ONLINE(o)\
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_APP_CHOOSER_ONLINE, GtkAppChooserOnline))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE(o)\
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_APP_CHOOSER_ONLINE))
|
||||
#define GTK_APP_CHOOSER_ONLINE_GET_IFACE(obj)\
|
||||
(G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_APP_CHOOSER_ONLINE, GtkAppChooserOnlineInterface))
|
||||
#define GTK_TYPE_APP_CHOOSER_ONLINE (gtk_app_chooser_online_get_type ())
|
||||
#define GTK_APP_CHOOSER_ONLINE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_APP_CHOOSER_ONLINE, GtkAppChooserOnline))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_APP_CHOOSER_ONLINE))
|
||||
#define GTK_APP_CHOOSER_ONLINE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_APP_CHOOSER_ONLINE, GtkAppChooserOnlineInterface))
|
||||
|
||||
typedef struct _GtkAppChooserOnline GtkAppChooserOnline;
|
||||
typedef struct _GtkAppChooserOnlineInterface GtkAppChooserOnlineInterface;
|
||||
@ -47,27 +43,27 @@ struct _GtkAppChooserOnlineInterface {
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Methods */
|
||||
void (*search_for_mimetype_async) (GtkAppChooserOnline *self,
|
||||
const gchar *content_type,
|
||||
GtkWindow *parent,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
void (*search_for_mimetype_async) (GtkAppChooserOnline *self,
|
||||
const gchar *content_type,
|
||||
GtkWindow *parent,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean (*search_for_mimetype_finish) (GtkAppChooserOnline *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
gboolean (*search_for_mimetype_finish) (GtkAppChooserOnline *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
GType gtk_app_chooser_online_get_type (void) G_GNUC_CONST;
|
||||
void gtk_app_chooser_online_search_for_mimetype_async (GtkAppChooserOnline *self,
|
||||
const gchar *content_type,
|
||||
GtkWindow *parent,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean gtk_app_chooser_online_search_for_mimetype_finish (GtkAppChooserOnline *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
GType gtk_app_chooser_online_get_type (void) G_GNUC_CONST;
|
||||
void gtk_app_chooser_online_search_for_mimetype_async (GtkAppChooserOnline *self,
|
||||
const gchar *content_type,
|
||||
GtkWindow *parent,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean gtk_app_chooser_online_search_for_mimetype_finish (GtkAppChooserOnline *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
GtkAppChooserOnline * gtk_app_chooser_online_get_default (void);
|
||||
GtkAppChooserOnline * gtk_app_chooser_online_get_default (void);
|
||||
|
||||
#endif /* __GTK_APP_CHOOSER_ONLINE_H__ */
|
||||
|
@ -27,18 +27,12 @@
|
||||
#include <gtk/gtkappchooseronline.h>
|
||||
#include <glib.h>
|
||||
|
||||
#define GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY\
|
||||
(_gtk_app_chooser_online_dummy_get_type ())
|
||||
#define GTK_APP_CHOOSER_ONLINE_DUMMY(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY, GtkAppChooserOnlineDummy))
|
||||
#define GTK_APP_CHOOSER_ONLINE_DUMMY_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY, GtkAppChooserOnlineDummyClass))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE_DUMMY(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE_DUMMY_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY))
|
||||
#define GTK_APP_CHOOSER_ONLINE_DUMMY_GET_CLASS(obj)\
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY, GtkAppChooserOnlineDummyClass))
|
||||
#define GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY (_gtk_app_chooser_online_dummy_get_type ())
|
||||
#define GTK_APP_CHOOSER_ONLINE_DUMMY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY, GtkAppChooserOnlineDummy))
|
||||
#define GTK_APP_CHOOSER_ONLINE_DUMMY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY, GtkAppChooserOnlineDummyClass))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE_DUMMY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE_DUMMY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY))
|
||||
#define GTK_APP_CHOOSER_ONLINE_DUMMY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_DUMMY, GtkAppChooserOnlineDummyClass))
|
||||
|
||||
typedef struct _GtkAppChooserOnlineDummy GtkAppChooserOnlineDummy;
|
||||
typedef struct _GtkAppChooserOnlineDummyClass GtkAppChooserOnlineDummyClass;
|
||||
|
@ -21,12 +21,14 @@
|
||||
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkappchooseronlinepk.h"
|
||||
|
||||
#include "gtkappchooseronline.h"
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include "x11/gdkx.h"
|
||||
#endif
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
@ -34,12 +36,12 @@
|
||||
static void app_chooser_online_iface_init (GtkAppChooserOnlineInterface *iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserOnlinePk, gtk_app_chooser_online_pk,
|
||||
G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER_ONLINE,
|
||||
app_chooser_online_iface_init)
|
||||
g_io_extension_point_implement ("gtkappchooser-online",
|
||||
g_define_type_id,
|
||||
"packagekit", 10));
|
||||
G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER_ONLINE,
|
||||
app_chooser_online_iface_init)
|
||||
g_io_extension_point_implement ("gtkappchooser-online",
|
||||
g_define_type_id,
|
||||
"packagekit", 10));
|
||||
|
||||
struct _GtkAppChooserOnlinePkPrivate {
|
||||
GSimpleAsyncResult *result;
|
||||
@ -72,13 +74,13 @@ static void
|
||||
gtk_app_chooser_online_pk_init (GtkAppChooserOnlinePk *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_ONLINE_PK,
|
||||
GtkAppChooserOnlinePkPrivate);
|
||||
GtkAppChooserOnlinePkPrivate);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pk_search_mime_finish (GtkAppChooserOnline *obj,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
|
||||
|
||||
@ -86,9 +88,9 @@ pk_search_mime_finish (GtkAppChooserOnline *obj,
|
||||
}
|
||||
|
||||
static void
|
||||
install_mime_types_ready_cb (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
install_mime_types_ready_cb (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserOnlinePk *self = user_data;
|
||||
GDBusProxy *proxy = G_DBUS_PROXY (source);
|
||||
@ -97,24 +99,25 @@ install_mime_types_ready_cb (GObject *source,
|
||||
|
||||
variant = g_dbus_proxy_call_finish (proxy, res, &error);
|
||||
|
||||
if (variant == NULL) {
|
||||
/* don't show errors if the user cancelled the installation explicitely
|
||||
* or if PK wasn't able to find any apps
|
||||
*/
|
||||
if (g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.Cancelled") != 0 &&
|
||||
g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.NoPackagesFound") != 0)
|
||||
g_simple_async_result_set_from_error (self->priv->result, error);
|
||||
if (variant == NULL)
|
||||
{
|
||||
/* don't show errors if the user cancelled the installation explicitely
|
||||
* or if PK wasn't able to find any apps
|
||||
*/
|
||||
if (g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.Cancelled") != 0 &&
|
||||
g_strcmp0 (g_dbus_error_get_remote_error (error), "org.freedesktop.PackageKit.Modify.NoPackagesFound") != 0)
|
||||
g_simple_async_result_set_from_error (self->priv->result, error);
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_simple_async_result_complete (self->priv->result);
|
||||
}
|
||||
|
||||
static void
|
||||
pk_proxy_appeared_cb (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
pk_proxy_appeared_cb (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserOnlinePk *self = user_data;
|
||||
GDBusProxy *proxy;
|
||||
@ -125,58 +128,63 @@ pk_proxy_appeared_cb (GObject *source,
|
||||
|
||||
proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
|
||||
|
||||
if (error != NULL) {
|
||||
g_simple_async_result_set_from_error (self->priv->result, error);
|
||||
g_error_free (error);
|
||||
if (error != NULL)
|
||||
{
|
||||
g_simple_async_result_set_from_error (self->priv->result, error);
|
||||
g_error_free (error);
|
||||
|
||||
g_simple_async_result_complete (self->priv->result);
|
||||
g_simple_async_result_complete (self->priv->result);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
window = gtk_widget_get_window (GTK_WIDGET (self->priv->parent));
|
||||
xid = GDK_WINDOW_XID (window);
|
||||
#else
|
||||
xid = 0;
|
||||
#endif
|
||||
|
||||
mime_types[0] = self->priv->content_type;
|
||||
mime_types[1] = NULL;
|
||||
|
||||
g_dbus_proxy_call (proxy,
|
||||
"InstallMimeTypes",
|
||||
g_variant_new ("(u^ass)",
|
||||
xid,
|
||||
mime_types,
|
||||
"hide-confirm-search"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
G_MAXINT, /* no timeout */
|
||||
NULL,
|
||||
install_mime_types_ready_cb,
|
||||
self);
|
||||
"InstallMimeTypes",
|
||||
g_variant_new ("(u^ass)",
|
||||
xid,
|
||||
mime_types,
|
||||
"hide-confirm-search"),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
G_MAXINT, /* no timeout */
|
||||
NULL,
|
||||
install_mime_types_ready_cb,
|
||||
self);
|
||||
}
|
||||
|
||||
static void
|
||||
pk_search_mime_async (GtkAppChooserOnline *obj,
|
||||
const gchar *content_type,
|
||||
GtkWindow *parent,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
const gchar *content_type,
|
||||
GtkWindow *parent,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkAppChooserOnlinePk *self = GTK_APP_CHOOSER_ONLINE_PK (obj);
|
||||
|
||||
self->priv->result = g_simple_async_result_new (G_OBJECT (self),
|
||||
callback, user_data,
|
||||
gtk_app_chooser_online_search_for_mimetype_async);
|
||||
callback, user_data,
|
||||
gtk_app_chooser_online_search_for_mimetype_async);
|
||||
self->priv->parent = parent;
|
||||
self->priv->content_type = g_strdup (content_type);
|
||||
|
||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL,
|
||||
"org.freedesktop.PackageKit",
|
||||
"/org/freedesktop/PackageKit",
|
||||
"org.freedesktop.PackageKit.Modify",
|
||||
NULL,
|
||||
pk_proxy_appeared_cb,
|
||||
self);
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL,
|
||||
"org.freedesktop.PackageKit",
|
||||
"/org/freedesktop/PackageKit",
|
||||
"org.freedesktop.PackageKit.Modify",
|
||||
NULL,
|
||||
pk_proxy_appeared_cb,
|
||||
self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -27,18 +27,12 @@
|
||||
#include <gtk/gtkappchooseronline.h>
|
||||
#include <glib.h>
|
||||
|
||||
#define GTK_TYPE_APP_CHOOSER_ONLINE_PK\
|
||||
(_gtk_app_chooser_online_pk_get_type ())
|
||||
#define GTK_APP_CHOOSER_ONLINE_PK(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_PK, GtkAppChooserOnlinePk))
|
||||
#define GTK_APP_CHOOSER_ONLINE_PK_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_ONLINE_PK, GtkAppChooserOnlinePkClass))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE_PK(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_PK))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE_PK_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_ONLINE_PK))
|
||||
#define GTK_APP_CHOOSER_ONLINE_PK_GET_CLASS(obj)\
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_PK, GtkAppChooserOnlinePkClass))
|
||||
#define GTK_TYPE_APP_CHOOSER_ONLINE_PK (_gtk_app_chooser_online_pk_get_type ())
|
||||
#define GTK_APP_CHOOSER_ONLINE_PK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_PK, GtkAppChooserOnlinePk))
|
||||
#define GTK_APP_CHOOSER_ONLINE_PK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_ONLINE_PK, GtkAppChooserOnlinePkClass))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE_PK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_PK))
|
||||
#define GTK_IS_APP_CHOOSER_ONLINE_PK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_ONLINE_PK))
|
||||
#define GTK_APP_CHOOSER_ONLINE_PK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_ONLINE_PK, GtkAppChooserOnlinePkClass))
|
||||
|
||||
typedef struct _GtkAppChooserOnlinePk GtkAppChooserOnlinePk;
|
||||
typedef struct _GtkAppChooserOnlinePkClass GtkAppChooserOnlinePkClass;
|
||||
|
@ -27,13 +27,13 @@
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#include "gtkappchooser.h"
|
||||
#include "gtkappchooserwidget.h"
|
||||
|
||||
typedef struct _GtkAppChooserIface GtkAppChooserIface;
|
||||
typedef GtkAppChooserIface GtkAppChooserInterface;
|
||||
|
||||
#define GTK_APP_CHOOSER_GET_IFACE(inst)\
|
||||
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_APP_CHOOSER, GtkAppChooserIface))
|
||||
#define GTK_APP_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_APP_CHOOSER, GtkAppChooserIface))
|
||||
|
||||
struct _GtkAppChooserIface {
|
||||
GTypeInterface base_iface;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,18 +35,12 @@
|
||||
#include <gtk/gtkmenu.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define GTK_TYPE_APP_CHOOSER_WIDGET\
|
||||
(gtk_app_chooser_widget_get_type ())
|
||||
#define GTK_APP_CHOOSER_WIDGET(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_WIDGET, GtkAppChooserWidget))
|
||||
#define GTK_APP_CHOOSER_WIDGET_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_WIDGET, GtkAppChooserWidgetClass))
|
||||
#define GTK_IS_APP_CHOOSER_WIDGET(obj)\
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_WIDGET))
|
||||
#define GTK_IS_APP_CHOOSER_WIDGET_CLASS(klass)\
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_WIDGET))
|
||||
#define GTK_APP_CHOOSER_WIDGET_GET_CLASS(obj)\
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_WIDGET, GtkAppChooserWidgetClass))
|
||||
#define GTK_TYPE_APP_CHOOSER_WIDGET (gtk_app_chooser_widget_get_type ())
|
||||
#define GTK_APP_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_APP_CHOOSER_WIDGET, GtkAppChooserWidget))
|
||||
#define GTK_APP_CHOOSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_APP_CHOOSER_WIDGET, GtkAppChooserWidgetClass))
|
||||
#define GTK_IS_APP_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_APP_CHOOSER_WIDGET))
|
||||
#define GTK_IS_APP_CHOOSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_APP_CHOOSER_WIDGET))
|
||||
#define GTK_APP_CHOOSER_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_APP_CHOOSER_WIDGET, GtkAppChooserWidgetClass))
|
||||
|
||||
typedef struct _GtkAppChooserWidget GtkAppChooserWidget;
|
||||
typedef struct _GtkAppChooserWidgetClass GtkAppChooserWidgetClass;
|
||||
@ -62,53 +56,46 @@ struct _GtkAppChooserWidget {
|
||||
struct _GtkAppChooserWidgetClass {
|
||||
GtkBoxClass parent_class;
|
||||
|
||||
void (* application_selected) (GtkAppChooserWidget *self,
|
||||
GAppInfo *app_info);
|
||||
void (* application_selected) (GtkAppChooserWidget *self,
|
||||
GAppInfo *app_info);
|
||||
|
||||
void (* application_activated) (GtkAppChooserWidget *self,
|
||||
GAppInfo *app_info);
|
||||
GAppInfo *app_info);
|
||||
|
||||
void (* populate_popup) (GtkAppChooserWidget *self,
|
||||
GtkMenu *menu,
|
||||
GAppInfo *app_info);
|
||||
void (* populate_popup) (GtkAppChooserWidget *self,
|
||||
GtkMenu *menu,
|
||||
GAppInfo *app_info);
|
||||
|
||||
/* padding for future class expansion */
|
||||
gpointer padding[16];
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
GTK_APP_CHOOSER_WIDGET_SHOW_RECOMMENDED = 1 << 0,
|
||||
GTK_APP_CHOOSER_WIDGET_SHOW_FALLBACK = 1 << 1,
|
||||
GTK_APP_CHOOSER_WIDGET_SHOW_OTHER = 1 << 2,
|
||||
GTK_APP_CHOOSER_WIDGET_SHOW_ALL = 1 << 3,
|
||||
} GtkAppChooserWidgetShowFlags;
|
||||
GType gtk_app_chooser_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GType gtk_app_chooser_widget_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gtk_app_chooser_widget_new (const gchar *content_type);
|
||||
|
||||
GtkWidget * gtk_app_chooser_widget_new (const gchar *content_type);
|
||||
void gtk_app_chooser_widget_set_show_default (GtkAppChooserWidget *self,
|
||||
gboolean setting);
|
||||
gboolean gtk_app_chooser_widget_get_show_default (GtkAppChooserWidget *self);
|
||||
|
||||
void gtk_app_chooser_widget_set_show_default (GtkAppChooserWidget *self,
|
||||
gboolean setting);
|
||||
gboolean gtk_app_chooser_widget_get_show_default (GtkAppChooserWidget *self);
|
||||
void gtk_app_chooser_widget_set_show_recommended (GtkAppChooserWidget *self,
|
||||
gboolean setting);
|
||||
gboolean gtk_app_chooser_widget_get_show_recommended (GtkAppChooserWidget *self);
|
||||
|
||||
void gtk_app_chooser_widget_set_show_recommended (GtkAppChooserWidget *self,
|
||||
gboolean setting);
|
||||
gboolean gtk_app_chooser_widget_get_show_recommended (GtkAppChooserWidget *self);
|
||||
void gtk_app_chooser_widget_set_show_fallback (GtkAppChooserWidget *self,
|
||||
gboolean setting);
|
||||
gboolean gtk_app_chooser_widget_get_show_fallback (GtkAppChooserWidget *self);
|
||||
|
||||
void gtk_app_chooser_widget_set_show_fallback (GtkAppChooserWidget *self,
|
||||
gboolean setting);
|
||||
gboolean gtk_app_chooser_widget_get_show_fallback (GtkAppChooserWidget *self);
|
||||
void gtk_app_chooser_widget_set_show_other (GtkAppChooserWidget *self,
|
||||
gboolean setting);
|
||||
gboolean gtk_app_chooser_widget_get_show_other (GtkAppChooserWidget *self);
|
||||
|
||||
void gtk_app_chooser_widget_set_show_other (GtkAppChooserWidget *self,
|
||||
gboolean setting);
|
||||
gboolean gtk_app_chooser_widget_get_show_other (GtkAppChooserWidget *self);
|
||||
void gtk_app_chooser_widget_set_show_all (GtkAppChooserWidget *self,
|
||||
gboolean show_all);
|
||||
gboolean gtk_app_chooser_widget_get_show_all (GtkAppChooserWidget *self);
|
||||
|
||||
void gtk_app_chooser_widget_set_show_all (GtkAppChooserWidget *self,
|
||||
gboolean show_all);
|
||||
gboolean gtk_app_chooser_widget_get_show_all (GtkAppChooserWidget *self);
|
||||
|
||||
void gtk_app_chooser_widget_set_default_text (GtkAppChooserWidget *self,
|
||||
const gchar *text);
|
||||
const gchar * gtk_app_chooser_widget_get_default_text (GtkAppChooserWidget *self);
|
||||
void gtk_app_chooser_widget_set_default_text (GtkAppChooserWidget *self,
|
||||
const gchar *text);
|
||||
const gchar * gtk_app_chooser_widget_get_default_text (GtkAppChooserWidget *self);
|
||||
|
||||
#endif /* __GTK_APP_CHOOSER_WIDGET_H__ */
|
||||
|
@ -81,8 +81,7 @@ prepare_dialog (void)
|
||||
|
||||
if (use_file)
|
||||
{
|
||||
dialog = gtk_app_chooser_dialog_new (GTK_WINDOW (toplevel),
|
||||
0, file);
|
||||
dialog = gtk_app_chooser_dialog_new (GTK_WINDOW (toplevel), 0, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -18,7 +18,6 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
@ -28,7 +27,7 @@ static GtkWidget *sel_image, *sel_name;
|
||||
|
||||
static void
|
||||
combo_changed_cb (GtkComboBox *cb,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
GAppInfo *app_info;
|
||||
|
||||
@ -38,7 +37,7 @@ combo_changed_cb (GtkComboBox *cb,
|
||||
return;
|
||||
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (sel_image), g_app_info_get_icon (app_info),
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
gtk_label_set_text (GTK_LABEL (sel_name), g_app_info_get_display_name (app_info));
|
||||
|
||||
g_object_unref (app_info);
|
||||
@ -46,10 +45,10 @@ combo_changed_cb (GtkComboBox *cb,
|
||||
|
||||
static void
|
||||
special_item_activated_cb (GtkAppChooserComboBox *cb,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_image_set_from_gicon (GTK_IMAGE (sel_image), g_themed_icon_new ("face-smile"),
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
gtk_label_set_text (GTK_LABEL (sel_name), "Special Item");
|
||||
}
|
||||
|
||||
@ -72,7 +71,7 @@ main (int argc,
|
||||
gtk_box_pack_start (GTK_BOX (box), combobox, TRUE, TRUE, 0);
|
||||
|
||||
g_signal_connect (combobox, "changed",
|
||||
G_CALLBACK (combo_changed_cb), NULL);
|
||||
G_CALLBACK (combo_changed_cb), NULL);
|
||||
|
||||
w = gtk_label_new (NULL);
|
||||
gtk_label_set_markup (GTK_LABEL (w), "<b>Selected app info</b>");
|
||||
@ -88,10 +87,10 @@ main (int argc,
|
||||
|
||||
gtk_app_chooser_combo_box_append_separator (GTK_APP_CHOOSER_COMBO_BOX (combobox));
|
||||
gtk_app_chooser_combo_box_append_custom_item (GTK_APP_CHOOSER_COMBO_BOX (combobox),
|
||||
"Hey, I'm special!",
|
||||
g_themed_icon_new ("face-smile"),
|
||||
special_item_activated_cb,
|
||||
NULL);
|
||||
"Hey, I'm special!",
|
||||
g_themed_icon_new ("face-smile"),
|
||||
special_item_activated_cb,
|
||||
NULL);
|
||||
|
||||
/* test refresh on a combo */
|
||||
gtk_app_chooser_refresh (GTK_APP_CHOOSER (combobox));
|
||||
@ -99,7 +98,7 @@ main (int argc,
|
||||
gtk_widget_show_all (toplevel);
|
||||
|
||||
g_signal_connect (toplevel, "delete-event",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user