Commit a498d9a9 authored by Matthias Clasen's avatar Matthias Clasen

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
parent f6444847
......@@ -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);
}
......@@ -207,15 +207,15 @@ gtk_app_chooser_combo_box_remove_non_custom (GtkAppChooserComboBox *self)
GtkTreeIter iter;
gboolean custom, res;
model = GTK_TREE_MODEL (self->priv->store);
model = GTK_TREE_MODEL (self->priv->store);
if (!gtk_tree_model_get_iter_first (model, &iter))
return;
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__ */
This diff is collapsed.
......@@ -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);