Commit 117e8864 authored by Cosimo Cecchi's avatar Cosimo Cecchi
Browse files

Merge branch 'open-with-dialog'

parents 8076dbfb 4fe23cae
......@@ -1488,6 +1488,25 @@ GLIB_GSETTINGS
GOBJECT_INTROSPECTION_CHECK([0.9.3])
##################################################
# Packagekit module
#################################################
AC_ARG_ENABLE(packagekit,
AC_HELP_STRING([--disable-packagekit],
[build packagekit open with module]))
ENABLE_PACKAGEKIT=
if test "os_win32" != "yes"; then
if test "x$enable_packagekit" != "xno"; then
ENABLE_PACKAGEKIT=1
AC_DEFINE(ENABLE_PACKAGEKIT, 1, [define to enable packagekit])
fi
fi
AC_SUBST(ENABLE_PACKAGEKIT)
AM_CONDITIONAL(ENABLE_PACKAGEKIT, test "x$ENABLE_PACKAGEKIT" = "x1")
##################################################
# Checks for gtk-doc and docbook-tools
##################################################
......
......@@ -297,6 +297,14 @@
<xi:include href="xml/gtkrecentfilter.xml" />
</chapter>
<chapter id="ApplicationChoosing">
<title>Choosing from installed applications</title>
<xi:include href="xml/gtkappchooser.xml" />
<xi:include href="xml/gtkappchooserbutton.xml" />
<xi:include href="xml/gtkappchooserdialog.xml" />
<xi:include href="xml/gtkappchooserwidget.xml" />
</chapter>
<chapter id="Builder">
<title>Interface builder</title>
<xi:include href="xml/gtkbuildable.xml" />
......
......@@ -6410,3 +6410,98 @@ GTK_SWITCH_GET_CLASS
GtkSwitchPrivate
gtk_switch_get_type
</SECTION>
<SECTION>
<FILE>gtkappchooser</FILE>
<TITLE>GtkAppChooser</TITLE>
GtkAppChooser
gtk_app_chooser_get_app_info
gtk_app_chooser_get_content_type
gtk_app_chooser_refresh
<SUBSECTION Standard>
GTK_TYPE_APP_CHOOSER
GTK_APP_CHOOSER
GTK_IS_APP_CHOOSER
<SUBSECTION Private>
gtk_app_chooser_get_type
</SECTION>
<SECTION>
<FILE>gtkappchooserbutton</FILE>
<TITLE>GtkAppChooserButton</TITLE>
GtkAppChooserButton
gtk_app_chooser_button_new
gtk_app_chooser_button_append_custom_item
gtk_app_chooser_button_append_separator
gtk_app_chooser_button_get_show_dialog_item
gtk_app_chooser_button_set_show_dialog_item
<SUBSECTION Standard>
GtkAppChooserButtonClass
GTK_TYPE_APP_CHOOSER_BUTTON
GTK_APP_CHOOSER_BUTTON
GTK_APP_CHOOSER_BUTTON_CLASS
GTK_IS_APP_CHOOSER_BUTTON
GTK_IS_APP_CHOOSER_BUTTON_CLASS
GTK_APP_CHOOSER_BUTTON_GET_CLASS
<SUBSECTION Private>
GtkAppChooserButtonPrivate
gtk_app_chooser_button_get_type
</SECTION>
<SECTION>
<FILE>gtkappchooserdialog</FILE>
<TITLE>GtkAppChooserDialog</TITLE>
GtkAppChooserDialog
gtk_app_chooser_dialog_new
gtk_app_chooser_dialog_new_for_content_type
gtk_app_chooser_dialog_get_widget
<SUBSECTION Standard>
GtkAppChooserDialogClass
GTK_TYPE_APP_CHOOSER_DIALOG
GTK_APP_CHOOSER_DIALOG
GTK_APP_CHOOSER_DIALOG_CLASS
GTK_IS_APP_CHOOSER_DIALOG
GTK_IS_APP_CHOOSER_DIALOG_CLASS
GTK_APP_CHOOSER_DIALOG_GET_CLASS
<SUBSECTION Private>
GtkAppChooserDialogPrivate
gtk_app_chooser_dialog_get_type
</SECTION>
<SECTION>
<FILE>gtkappchooserwidget</FILE>
<TITLE>GtkAppChooserWidget</TITLE>
GtkAppChooserWidget
gtk_app_chooser_widget_new
gtk_app_chooser_widget_set_show_default
gtk_app_chooser_widget_get_show_default
gtk_app_chooser_widget_set_show_recommended
gtk_app_chooser_widget_get_show_recommended
gtk_app_chooser_widget_set_show_fallback
gtk_app_chooser_widget_get_show_fallback
gtk_app_chooser_widget_set_show_other
gtk_app_chooser_widget_get_show_other
gtk_app_chooser_widget_set_show_all
gtk_app_chooser_widget_get_show_all
gtk_app_chooser_widget_set_default_text
gtk_app_chooser_widget_get_default_text
<SUBSECTION Standard>
GtkAppChooserWidgetClass
GTK_TYPE_APP_CHOOSER_WIDGET
GTK_APP_CHOOSER_WIDGET
GTK_APP_CHOOSER_WIDGET_CLASS
GTK_IS_APP_CHOOSER_WIDGET
GTK_IS_APP_CHOOSER_WIDGET_CLASS
GTK_APP_CHOOSER_WIDGET_GET_CLASS
<SUBSECTION Private>
GtkAppChooserWidgetPrivate
gtk_app_chooser_widget_get_type
</SECTION>
......@@ -11,6 +11,10 @@ gtk_action_group_get_type
gtk_activatable_get_type
gtk_adjustment_get_type
gtk_alignment_get_type
gtk_app_chooser_get_type
gtk_app_chooser_button_get_type
gtk_app_chooser_dialog_get_type
gtk_app_chooser_widget_get_type
gtk_application_get_type
gtk_arrow_get_type
gtk_aspect_frame_get_type
......
......@@ -156,7 +156,11 @@ gtk_public_h_sources = \
gtkactivatable.h \
gtkadjustment.h \
gtkalignment.h \
gtkapplication.h \
gtkappchooser.h \
gtkappchooserdialog.h \
gtkappchooserbutton.h \
gtkappchooserwidget.h \
gtkapplication.h \
gtkarrow.h \
gtkaspectframe.h \
gtkassistant.h \
......@@ -347,6 +351,18 @@ endif
gtk_semi_private_h_sources = \
gtktextlayout.h
if ENABLE_PACKAGEKIT
gtk_appchooser_impl_h_sources = \
gtkappchooseronlinepk.h \
$(NULL)
endif
if ENABLE_PACKAGEKIT
gtk_appchooser_impl_c_sources = \
gtkappchooseronlinepk.c \
$(NULL)
endif
# GTK+ header files that don't get installed
gtk_private_h_sources = \
gtkbuttonprivate.h \
......@@ -371,6 +387,9 @@ gtk_private_h_sources = \
gtkmenuprivate.h \
gtkmnemonichash.h \
gtkmountoperationprivate.h \
gtkappchooserprivate.h \
gtkappchoosermodule.h \
gtkappchooseronline.h \
gtkpango.h \
gtkpathbar.h \
gtkplugprivate.h \
......@@ -398,7 +417,8 @@ gtk_private_h_sources = \
gtktreeprivate.h \
gtkwindow-decorate.h \
gtkwidgetprivate.h \
$(gtk_clipboard_dnd_h_sources)
$(gtk_clipboard_dnd_h_sources) \
$(gtk_appchooser_impl_h_sources)
# GTK+ C sources to build the library from
gtk_base_c_sources = \
......@@ -416,7 +436,13 @@ gtk_base_c_sources = \
gtkactivatable.c \
gtkadjustment.c \
gtkalignment.c \
gtkapplication.c \
gtkappchooser.c \
gtkappchooserwidget.c \
gtkappchooserbutton.c \
gtkappchooserdialog.c \
gtkappchoosermodule.c \
gtkappchooseronline.c \
gtkapplication.c \
gtkarrow.c \
gtkaspectframe.c \
gtkassistant.c \
......@@ -616,7 +642,8 @@ gtk_base_c_sources = \
gtkwidget.c \
gtkwindow-decorate.c \
gtkwindow.c \
$(gtk_clipboard_dnd_c_sources)
$(gtk_clipboard_dnd_c_sources) \
$(gtk_appchooser_impl_c_sources)
gtk_c_sources = $(gtk_base_c_sources)
gtk_all_c_sources = $(gtk_base_c_sources)
......
......@@ -40,6 +40,10 @@
#include <gtk/gtkactivatable.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkalignment.h>
#include <gtk/gtkappchooser.h>
#include <gtk/gtkappchooserdialog.h>
#include <gtk/gtkappchooserwidget.h>
#include <gtk/gtkappchooserbutton.h>
#include <gtk/gtkapplication.h>
#include <gtk/gtkarrow.h>
#include <gtk/gtkaspectframe.h>
......
......@@ -178,6 +178,34 @@ gtk_alignment_new
gtk_alignment_set
gtk_alignment_set_padding
gtk_alternative_dialog_button_order
gtk_app_chooser_get_app_info
gtk_app_chooser_get_content_type
gtk_app_chooser_get_type G_GNUC_CONST
gtk_app_chooser_refresh
gtk_app_chooser_button_append_custom_item
gtk_app_chooser_button_append_separator
gtk_app_chooser_button_get_show_dialog_item
gtk_app_chooser_button_get_type G_GNUC_CONST;
gtk_app_chooser_button_new
gtk_app_chooser_button_set_show_dialog_item
gtk_app_chooser_dialog_new
gtk_app_chooser_dialog_new_for_content_type
gtk_app_chooser_dialog_get_type G_GNUC_CONST
gtk_app_chooser_dialog_get_widget
gtk_app_chooser_widget_new
gtk_app_chooser_widget_get_show_all
gtk_app_chooser_widget_get_default_text
gtk_app_chooser_widget_get_show_default
gtk_app_chooser_widget_get_show_fallback
gtk_app_chooser_widget_get_show_other
gtk_app_chooser_widget_get_show_recommended
gtk_app_chooser_widget_get_type G_GNUC_CONST
gtk_app_chooser_widget_set_default_text
gtk_app_chooser_widget_set_show_all
gtk_app_chooser_widget_set_show_default
gtk_app_chooser_widget_set_show_fallback
gtk_app_chooser_widget_set_show_other
gtk_app_chooser_widget_set_show_recommended
gtk_application_add_window
gtk_application_get_type G_GNUC_CONST
gtk_application_get_windows
......
/*
* gtkappchooser.c: app-chooser interface
*
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
*/
#include "config.h"
#include "gtkappchooser.h"
#include "gtkintl.h"
#include "gtkappchooserprivate.h"
#include "gtkwidget.h"
#include <glib.h>
G_DEFINE_INTERFACE (GtkAppChooser, gtk_app_chooser, GTK_TYPE_WIDGET);
static void
gtk_app_chooser_default_init (GtkAppChooserIface *iface)
{
GParamSpec *pspec;
/**
* GtkAppChooser:content-type:
*
* The content type of the #GtkAppChooser object.
*/
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);
g_object_interface_install_property (iface, pspec);
}
/**
* gtk_app_chooser_get_content_type:
* @self: a #GtkAppChooser
*
* Returns the current value of the #GtkAppChooser:content-type property.
*
* Returns: the content type of @self. Free with g_free()
*
* Since: 3.0
*/
gchar *
gtk_app_chooser_get_content_type (GtkAppChooser *self)
{
gchar *retval = NULL;
g_return_val_if_fail (GTK_IS_APP_CHOOSER (self), NULL);
g_object_get (self,
"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
*
* Reloads the list of applications.
*
* Since: 3.0
*/
void
gtk_app_chooser_refresh (GtkAppChooser *self)
{
GTK_APP_CHOOSER_GET_IFACE (self)->refresh (self);
}
/*
* gtkappchooser.h: app-chooser interface
*
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
*/
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#ifndef __GTK_APP_CHOOSER_H__
#define __GTK_APP_CHOOSER_H__
#include <glib.h>
#include <gio/gio.h>
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))
typedef struct _GtkAppChooser GtkAppChooser;
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);
G_END_DECLS
#endif /* __GTK_APP_CHOOSER_H__ */
/*
* gtkappchooserbutton.h: an app-chooser combobox
*
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
*/
#include "config.h"
#include "gtkappchooserbutton.h"
#include "gtkappchooser.h"
#include "gtkappchooserdialog.h"
#include "gtkappchooserprivate.h"
#include "gtkcelllayout.h"
#include "gtkcellrendererpixbuf.h"
#include "gtkcellrenderertext.h"
#include "gtkcombobox.h"
#include "gtkdialog.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
enum {
PROP_CONTENT_TYPE = 1,
PROP_SHOW_DIALOG_ITEM,
};
enum {
SIGNAL_CUSTOM_ITEM_ACTIVATED,
NUM_SIGNALS
};
enum {
COLUMN_APP_INFO,
COLUMN_NAME,
COLUMN_LABEL,
COLUMN_ICON,
COLUMN_CUSTOM,
COLUMN_SEPARATOR,
NUM_COLUMNS,
};
#define CUSTOM_ITEM_OTHER_APP "gtk-internal-item-other-app"
static void app_chooser_iface_init (GtkAppChooserIface *iface);
static void real_insert_custom_item (GtkAppChooserButton *self,
const gchar *name,
const gchar *label,
GIcon *icon,
gboolean custom,
GtkTreeIter *iter);
static void real_insert_separator (GtkAppChooserButton *self,
gboolean custom,
GtkTreeIter *iter);
static guint signals[NUM_SIGNALS] = { 0, };
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserButton, gtk_app_chooser_button, GTK_TYPE_COMBO_BOX,
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
app_chooser_iface_init));
struct _GtkAppChooserButtonPrivate {
GtkListStore *store;
gchar *content_type;
gboolean show_dialog_item;
GHashTable *custom_item_names;
};
static gboolean
row_separator_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data)
{
gboolean separator;
gtk_tree_model_get (model, iter,
COLUMN_SEPARATOR, &separator,
-1);
return separator;
}
static void
get_first_iter (GtkListStore *store,
GtkTreeIter *iter)
{
GtkTreeIter iter2;
if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), iter))
{
/* the model is empty, append */
gtk_list_store_append (store, iter);
}
else
{
gtk_list_store_insert_before (store, &iter2, iter);
*iter = iter2;
}
}
typedef struct {
GtkAppChooserButton *self;
GAppInfo *info;
gint active_index;
} SelectAppData;
static void
select_app_data_free (SelectAppData *data)
{
g_clear_object (&data->self);
g_clear_object (&data->info);
g_slice_free (SelectAppData, data);
}
static gboolean
select_application_func_cb (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer user_data)
{
SelectAppData *data = user_data;
GAppInfo *app_to_match = data->info, *app = NULL;
gboolean custom;
gtk_tree_model_get (model, iter,
COLUMN_APP_INFO, &app,
COLUMN_CUSTOM, &custom,
-1);
/* cutsom items are always after GAppInfos, so iterating further here
* is just useless.
*/
if (custom)
return TRUE;
if (g_app_info_equal (app, app_to_match))
{
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (data->self), iter);
return TRUE;
}
return FALSE;
}
static void
gtk_app_chooser_button_select_application (GtkAppChooserButton *self,
GAppInfo *info)
{
SelectAppData *data;
data = g_slice_new0 (SelectAppData);
data->self = g_object_ref (self);
data->info = g_object_ref (info);
gtk_tree_model_foreach (GTK_TREE_MODEL (self->priv->store),
select_application_func_cb, data);
select_app_data_free (data);
}
static void
other_application_dialog_response_cb (GtkDialog *dialog,
gint response_id,
gpointer user_data)
{
GtkAppChooserButton *self = user_data;
GAppInfo *info;
if (response_id != GTK_RESPONSE_OK)
{
/* reset the active item, otherwise we are stuck on
* 'Other application...'
*/
gtk_combo_box_set_active (GTK_COMBO_BOX (self), 0);
gtk_widget_destroy (GTK_WIDGET (dialog));
return;