2010-11-16 12:47:51 +00:00
|
|
|
/*
|
2010-11-23 16:23:37 +00:00
|
|
|
* gtkappchooserdialog.c: an app-chooser dialog
|
2010-11-16 12:47:51 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Novell, Inc.
|
|
|
|
* Copyright (C) 2007, 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: Dave Camp <dave@novell.com>
|
|
|
|
* Alexander Larsson <alexl@redhat.com>
|
|
|
|
* Cosimo Cecchi <ccecchi@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2011-01-06 07:07:35 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtkappchooserdialog
|
|
|
|
* @Title: GtkAppChooserDialog
|
|
|
|
* @Short_description: An application chooser dialog
|
|
|
|
*
|
|
|
|
* #GtkAppChooserDialog shows a #GtkAppChooserWidget inside a #GtkDialog.
|
|
|
|
*
|
|
|
|
* Note that #GtkAppChooserDialog does not have any interesting methods
|
|
|
|
* of its own. Instead, you should get the embedded #GtkAppChooserWidget
|
2011-01-06 14:06:24 +00:00
|
|
|
* using gtk_app_chooser_dialog_get_widget() and call its methods if
|
|
|
|
* the generic #GtkAppChooser interface is not sufficient for your needs.
|
2011-01-06 07:07:35 +00:00
|
|
|
*/
|
2010-11-24 23:32:05 +00:00
|
|
|
#include "config.h"
|
2010-11-16 12:47:51 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
#include "gtkappchooserdialog.h"
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
#include "gtkintl.h"
|
2010-11-23 16:23:37 +00:00
|
|
|
#include "gtkappchooser.h"
|
|
|
|
#include "gtkappchooseronline.h"
|
|
|
|
#include "gtkappchooserprivate.h"
|
2010-11-24 23:32:05 +00:00
|
|
|
#include "gtkappchooserprivate.h"
|
|
|
|
|
|
|
|
#include "gtkmessagedialog.h"
|
|
|
|
#include "gtklabel.h"
|
|
|
|
#include "gtkbbox.h"
|
|
|
|
#include "gtkbutton.h"
|
|
|
|
#include "gtkmenuitem.h"
|
|
|
|
#include "gtkstock.h"
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib/gi18n-lib.h>
|
|
|
|
#include <gio/gio.h>
|
|
|
|
|
|
|
|
#define sure_string(s) ((const char *) ((s) != NULL ? (s) : ""))
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
struct _GtkAppChooserDialogPrivate {
|
2010-11-16 12:47:51 +00:00
|
|
|
char *content_type;
|
|
|
|
GFile *gfile;
|
|
|
|
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *button;
|
2010-11-19 17:05:53 +00:00
|
|
|
GtkWidget *online_button;
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
GtkWidget *open_label;
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkWidget *app_chooser_widget;
|
2010-11-22 22:05:59 +00:00
|
|
|
GtkWidget *show_more_button;
|
2010-11-23 15:50:21 +00:00
|
|
|
|
2010-11-29 17:10:06 +00:00
|
|
|
GtkAppChooserOnline *online;
|
|
|
|
|
2010-11-23 15:50:21 +00:00
|
|
|
gboolean show_more_clicked;
|
2010-11-16 12:47:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_GFILE = 1,
|
|
|
|
PROP_CONTENT_TYPE,
|
|
|
|
N_PROPERTIES
|
|
|
|
};
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
static void gtk_app_chooser_dialog_iface_init (GtkAppChooserIface *iface);
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkAppChooserDialog, gtk_app_chooser_dialog, GTK_TYPE_DIALOG,
|
2010-11-24 23:32:05 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_APP_CHOOSER,
|
|
|
|
gtk_app_chooser_dialog_iface_init));
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
show_error_dialog (const gchar *primary,
|
2010-11-24 23:32:05 +00:00
|
|
|
const gchar *secondary,
|
|
|
|
GtkWindow *parent)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
|
|
|
GtkWidget *message_dialog;
|
|
|
|
|
|
|
|
message_dialog = gtk_message_dialog_new (parent, 0,
|
2010-11-24 23:32:05 +00:00
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_OK,
|
|
|
|
NULL);
|
2010-11-16 12:47:51 +00:00
|
|
|
g_object_set (message_dialog,
|
2010-11-24 23:32:05 +00:00
|
|
|
"text", primary,
|
|
|
|
"secondary-text", secondary,
|
|
|
|
NULL);
|
2010-11-16 12:47:51 +00:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (message_dialog), GTK_RESPONSE_OK);
|
|
|
|
|
|
|
|
gtk_widget_show (message_dialog);
|
|
|
|
|
|
|
|
g_signal_connect (message_dialog, "response",
|
2010-11-24 23:32:05 +00:00
|
|
|
G_CALLBACK (gtk_widget_destroy), NULL);
|
2010-11-16 12:47:51 +00:00
|
|
|
}
|
|
|
|
|
2010-11-19 17:05:53 +00:00
|
|
|
static void
|
2010-11-24 23:32:05 +00:00
|
|
|
search_for_mimetype_ready_cb (GObject *source,
|
|
|
|
GAsyncResult *res,
|
|
|
|
gpointer user_data)
|
2010-11-19 17:05:53 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserOnline *online = GTK_APP_CHOOSER_ONLINE (source);
|
|
|
|
GtkAppChooserDialog *self = user_data;
|
2010-11-19 17:05:53 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
|
2010-12-05 17:18:30 +00:00
|
|
|
_gtk_app_chooser_online_search_for_mimetype_finish (online, res, &error);
|
2010-11-19 17:05:53 +00:00
|
|
|
|
|
|
|
if (error != NULL)
|
|
|
|
{
|
|
|
|
show_error_dialog (_("Failed to look for applications online"),
|
2010-11-24 23:32:05 +00:00
|
|
|
error->message, GTK_WINDOW (self));
|
2010-11-19 17:05:53 +00:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->priv->app_chooser_widget));
|
2010-11-19 17:05:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
online_button_clicked_cb (GtkButton *b,
|
2010-11-24 23:32:05 +00:00
|
|
|
gpointer user_data)
|
2010-11-19 17:05:53 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = user_data;
|
2010-11-19 17:05:53 +00:00
|
|
|
|
2010-12-05 17:18:30 +00:00
|
|
|
_gtk_app_chooser_online_search_for_mimetype_async (self->priv->online,
|
|
|
|
self->priv->content_type,
|
|
|
|
GTK_WINDOW (self),
|
|
|
|
search_for_mimetype_ready_cb,
|
|
|
|
self);
|
2010-11-19 17:05:53 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 17:10:06 +00:00
|
|
|
static void
|
|
|
|
app_chooser_online_get_default_ready_cb (GObject *source,
|
|
|
|
GAsyncResult *res,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkAppChooserDialog *self = user_data;
|
|
|
|
|
2010-12-05 17:18:30 +00:00
|
|
|
self->priv->online = _gtk_app_chooser_online_get_default_finish (source, res);
|
2010-11-29 17:10:06 +00:00
|
|
|
|
|
|
|
if (self->priv->online != NULL)
|
|
|
|
{
|
|
|
|
GtkWidget *action_area;
|
|
|
|
|
|
|
|
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);
|
|
|
|
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), self->priv->online_button,
|
|
|
|
TRUE);
|
|
|
|
g_signal_connect (self->priv->online_button, "clicked",
|
|
|
|
G_CALLBACK (online_button_clicked_cb), self);
|
|
|
|
|
|
|
|
gtk_widget_show (self->priv->online_button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ensure_online_button (GtkAppChooserDialog *self)
|
|
|
|
{
|
2010-12-05 17:18:30 +00:00
|
|
|
_gtk_app_chooser_online_get_default_async (app_chooser_online_get_default_ready_cb, self);
|
2010-11-29 17:10:06 +00:00
|
|
|
}
|
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
/* An application is valid if:
|
|
|
|
*
|
|
|
|
* 1) The file exists
|
|
|
|
* 2) The user has permissions to run the file
|
|
|
|
*/
|
|
|
|
static gboolean
|
2010-11-24 23:32:05 +00:00
|
|
|
check_application (GtkAppChooserDialog *self,
|
|
|
|
GAppInfo **app_out)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-17 18:28:48 +00:00
|
|
|
const char *command;
|
2010-11-16 12:47:51 +00:00
|
|
|
char *path = NULL;
|
|
|
|
char **argv = NULL;
|
|
|
|
int argc;
|
|
|
|
GError *error = NULL;
|
|
|
|
gint retval = TRUE;
|
2010-11-17 18:28:48 +00:00
|
|
|
GAppInfo *info;
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
command = NULL;
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->priv->app_chooser_widget));
|
2010-11-17 18:28:48 +00:00
|
|
|
command = g_app_info_get_executable (info);
|
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
g_shell_parse_argv (command, &argc, &argv, &error);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
show_error_dialog (_("Could not run application"),
|
2010-11-24 23:32:05 +00:00
|
|
|
error->message,
|
|
|
|
GTK_WINDOW (self));
|
2010-11-16 12:47:51 +00:00
|
|
|
g_error_free (error);
|
|
|
|
retval = FALSE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
path = g_find_program_in_path (argv[0]);
|
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
char *error_message;
|
|
|
|
|
|
|
|
error_message = g_strdup_printf (_("Could not find '%s'"),
|
2010-11-24 23:32:05 +00:00
|
|
|
argv[0]);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
show_error_dialog (_("Could not find application"),
|
2010-11-24 23:32:05 +00:00
|
|
|
error_message,
|
|
|
|
GTK_WINDOW (self));
|
2010-11-16 12:47:51 +00:00
|
|
|
g_free (error_message);
|
|
|
|
retval = FALSE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:28:48 +00:00
|
|
|
*app_out = info;
|
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
cleanup:
|
|
|
|
g_strfreev (argv);
|
|
|
|
g_free (path);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-11-24 14:49:47 +00:00
|
|
|
static void
|
|
|
|
add_or_find_application (GtkAppChooserDialog *self)
|
|
|
|
{
|
|
|
|
GAppInfo *app;
|
|
|
|
|
|
|
|
app = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self));
|
|
|
|
|
|
|
|
/* we don't care about reporting errors here */
|
2010-12-15 10:58:29 +00:00
|
|
|
g_app_info_set_as_last_used_for_type (app,
|
|
|
|
self->priv->content_type,
|
|
|
|
NULL);
|
2010-11-24 14:49:47 +00:00
|
|
|
|
|
|
|
g_object_unref (app);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_app_chooser_dialog_response (GtkDialog *dialog,
|
2010-11-24 23:32:05 +00:00
|
|
|
gint response_id,
|
|
|
|
gpointer user_data)
|
2010-11-24 14:49:47 +00:00
|
|
|
{
|
|
|
|
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (dialog);
|
|
|
|
|
|
|
|
switch (response_id)
|
|
|
|
{
|
|
|
|
case GTK_RESPONSE_OK:
|
|
|
|
add_or_find_application (self);
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
widget_application_selected_cb (GtkAppChooserWidget *widget,
|
2010-11-24 23:32:05 +00:00
|
|
|
GAppInfo *app_info,
|
|
|
|
gpointer user_data)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = user_data;
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (self->priv->button, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
widget_application_activated_cb (GtkAppChooserWidget *widget,
|
2010-11-24 23:32:05 +00:00
|
|
|
GAppInfo *app_info,
|
|
|
|
gpointer user_data)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = user_data;
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
get_extension (const char *basename)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = strrchr (basename, '.');
|
|
|
|
|
|
|
|
if (p && *(p + 1) != '\0')
|
|
|
|
return g_strdup (p + 1);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
set_dialog_properties (GtkAppChooserDialog *self)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-24 23:32:05 +00:00
|
|
|
gchar *label;
|
|
|
|
gchar *name;
|
|
|
|
gchar *extension;
|
|
|
|
gchar *description;
|
|
|
|
gchar *default_text;
|
|
|
|
gchar *string;
|
2010-11-18 22:17:23 +00:00
|
|
|
PangoFontDescription *font_desc;
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
extension = NULL;
|
|
|
|
label = NULL;
|
|
|
|
description = NULL;
|
|
|
|
|
|
|
|
if (self->priv->gfile != NULL)
|
|
|
|
{
|
|
|
|
name = g_file_get_basename (self->priv->gfile);
|
|
|
|
extension = get_extension (name);
|
|
|
|
}
|
|
|
|
|
|
|
|
description = g_content_type_get_description (self->priv->content_type);
|
2010-11-18 22:17:23 +00:00
|
|
|
gtk_window_set_title (GTK_WINDOW (self), "");
|
2010-11-16 12:47:51 +00:00
|
|
|
|
2010-11-18 22:17:23 +00:00
|
|
|
if (name != NULL)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-17 20:37:09 +00:00
|
|
|
/* Translators: %s is a filename */
|
2010-11-18 22:45:47 +00:00
|
|
|
label = g_strdup_printf (_("Select an application to open \"%s\""), name);
|
2010-11-23 11:47:16 +00:00
|
|
|
string = g_strdup_printf (_("No applications available to open \"%s\""),
|
2010-11-24 23:32:05 +00:00
|
|
|
name);
|
2010-11-16 12:47:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-11-17 20:37:09 +00:00
|
|
|
/* Translators: %s is a file type description */
|
2010-11-18 22:45:47 +00:00
|
|
|
label = g_strdup_printf (_("Select an application for \"%s\" files"),
|
2010-11-24 23:32:05 +00:00
|
|
|
g_content_type_is_unknown (self->priv->content_type) ?
|
|
|
|
self->priv->content_type : description);
|
2010-11-23 11:47:16 +00:00
|
|
|
string = g_strdup_printf (_("No applications available to open \"%s\" files"),
|
2010-11-24 23:32:05 +00:00
|
|
|
g_content_type_is_unknown (self->priv->content_type) ?
|
|
|
|
self->priv->content_type : description);
|
2010-11-16 12:47:51 +00:00
|
|
|
}
|
|
|
|
|
2010-11-18 22:17:23 +00:00
|
|
|
font_desc = pango_font_description_new ();
|
|
|
|
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
|
|
|
|
gtk_widget_modify_font (self->priv->label, font_desc);
|
|
|
|
pango_font_description_free (font_desc);
|
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
gtk_label_set_markup (GTK_LABEL (self->priv->label), label);
|
|
|
|
|
2010-11-23 11:47:16 +00:00
|
|
|
default_text = g_strdup_printf ("<big><b>%s</b></big>\n%s",
|
2010-11-24 23:32:05 +00:00
|
|
|
string,
|
|
|
|
_("Click \"Show other applications\", for more options, or "
|
|
|
|
"\"Find applications online\" to install a new application"));
|
2010-11-23 11:47:16 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_widget_set_default_text (GTK_APP_CHOOSER_WIDGET (self->priv->app_chooser_widget),
|
2010-11-24 23:32:05 +00:00
|
|
|
default_text);
|
2010-11-23 11:47:16 +00:00
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
g_free (label);
|
|
|
|
g_free (name);
|
|
|
|
g_free (extension);
|
|
|
|
g_free (description);
|
2010-11-23 11:47:16 +00:00
|
|
|
g_free (string);
|
|
|
|
g_free (default_text);
|
2010-11-16 12:47:51 +00:00
|
|
|
}
|
|
|
|
|
2010-11-22 22:05:59 +00:00
|
|
|
static void
|
|
|
|
show_more_button_clicked_cb (GtkButton *button,
|
2010-11-24 23:32:05 +00:00
|
|
|
gpointer user_data)
|
2010-11-22 22:05:59 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = user_data;
|
2010-11-22 22:05:59 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
g_object_set (self->priv->app_chooser_widget,
|
2010-11-24 23:32:05 +00:00
|
|
|
"show-recommended", TRUE,
|
|
|
|
"show-fallback", TRUE,
|
|
|
|
"show-other", TRUE,
|
|
|
|
NULL);
|
2010-11-22 22:05:59 +00:00
|
|
|
|
|
|
|
gtk_widget_hide (self->priv->show_more_button);
|
2010-11-23 15:50:21 +00:00
|
|
|
self->priv->show_more_clicked = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-24 23:32:05 +00:00
|
|
|
widget_notify_for_button_cb (GObject *source,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer user_data)
|
2010-11-23 15:50:21 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = user_data;
|
|
|
|
GtkAppChooserWidget *widget = GTK_APP_CHOOSER_WIDGET (source);
|
2010-11-23 15:50:21 +00:00
|
|
|
gboolean should_hide;
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
should_hide = gtk_app_chooser_widget_get_show_all (widget) ||
|
2010-11-23 15:50:21 +00:00
|
|
|
self->priv->show_more_clicked;
|
|
|
|
|
|
|
|
if (should_hide)
|
|
|
|
gtk_widget_hide (self->priv->show_more_button);
|
2010-11-22 22:05:59 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 16:11:17 +00:00
|
|
|
static void
|
|
|
|
forget_menu_item_activate_cb (GtkMenuItem *item,
|
2010-11-24 23:32:05 +00:00
|
|
|
gpointer user_data)
|
2010-11-24 16:11:17 +00:00
|
|
|
{
|
|
|
|
GtkAppChooserDialog *self = user_data;
|
|
|
|
GAppInfo *info;
|
|
|
|
|
|
|
|
info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self));
|
|
|
|
|
|
|
|
if (info != NULL)
|
|
|
|
{
|
2010-11-24 23:32:05 +00:00
|
|
|
g_app_info_remove_supports_type (info, self->priv->content_type, NULL);
|
2010-11-24 16:11:17 +00:00
|
|
|
|
|
|
|
gtk_app_chooser_refresh (GTK_APP_CHOOSER (self));
|
|
|
|
|
|
|
|
g_object_unref (info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
build_forget_menu_item (GtkAppChooserDialog *self)
|
|
|
|
{
|
|
|
|
GtkWidget *retval;
|
|
|
|
|
|
|
|
retval = gtk_menu_item_new_with_label (_("Forget association"));
|
|
|
|
gtk_widget_show (retval);
|
|
|
|
|
|
|
|
g_signal_connect (retval, "activate",
|
2010-11-24 23:32:05 +00:00
|
|
|
G_CALLBACK (forget_menu_item_activate_cb), self);
|
2010-11-24 16:11:17 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
widget_populate_popup_cb (GtkAppChooserWidget *widget,
|
2010-11-24 23:32:05 +00:00
|
|
|
GtkMenu *menu,
|
|
|
|
GAppInfo *info,
|
|
|
|
gpointer user_data)
|
2010-11-24 16:11:17 +00:00
|
|
|
{
|
|
|
|
GtkAppChooserDialog *self = user_data;
|
|
|
|
GtkWidget *menu_item;
|
|
|
|
|
|
|
|
if (g_app_info_can_remove_supports_type (info))
|
|
|
|
{
|
|
|
|
menu_item = build_forget_menu_item (self);
|
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:28:48 +00:00
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
build_dialog_ui (GtkAppChooserDialog *self)
|
2010-11-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *vbox2;
|
|
|
|
GtkWidget *label;
|
2010-11-29 17:10:06 +00:00
|
|
|
GtkWidget *button, *w;
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (self), 5);
|
|
|
|
|
2010-11-17 23:29:18 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2010-11-17 18:28:48 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
|
2010-11-17 23:02:59 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), vbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (vbox);
|
2010-11-24 23:32:05 +00:00
|
|
|
|
2010-11-17 23:29:18 +00:00
|
|
|
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2010-11-17 18:28:48 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), vbox2, TRUE, TRUE, 0);
|
2010-11-17 23:02:59 +00:00
|
|
|
gtk_widget_show (vbox2);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
self->priv->label = gtk_label_new ("");
|
2010-11-19 18:55:24 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (self->priv->label), 0, 0.5);
|
2010-11-17 18:28:48 +00:00
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (self->priv->label), TRUE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), self->priv->label,
|
2010-11-24 23:32:05 +00:00
|
|
|
FALSE, FALSE, 0);
|
2010-11-17 18:28:48 +00:00
|
|
|
gtk_widget_show (self->priv->label);
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
self->priv->app_chooser_widget =
|
|
|
|
gtk_app_chooser_widget_new (self->priv->content_type);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), self->priv->app_chooser_widget, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (self->priv->app_chooser_widget);
|
2010-11-23 15:50:21 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
g_signal_connect (self->priv->app_chooser_widget, "application-selected",
|
2010-11-24 23:32:05 +00:00
|
|
|
G_CALLBACK (widget_application_selected_cb), self);
|
2010-11-23 16:23:37 +00:00
|
|
|
g_signal_connect (self->priv->app_chooser_widget, "application-activated",
|
2010-11-24 23:32:05 +00:00
|
|
|
G_CALLBACK (widget_application_activated_cb), self);
|
2010-11-23 16:23:37 +00:00
|
|
|
g_signal_connect (self->priv->app_chooser_widget, "notify::show-all",
|
2010-11-24 23:32:05 +00:00
|
|
|
G_CALLBACK (widget_notify_for_button_cb), self);
|
2010-11-24 16:11:17 +00:00
|
|
|
g_signal_connect (self->priv->app_chooser_widget, "populate-popup",
|
2010-11-24 23:32:05 +00:00
|
|
|
G_CALLBACK (widget_populate_popup_cb), self);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
2010-11-22 22:05:59 +00:00
|
|
|
button = gtk_button_new_with_label (_("Show other applications"));
|
|
|
|
self->priv->show_more_button = button;
|
|
|
|
w = gtk_image_new_from_stock (GTK_STOCK_ADD,
|
2010-11-24 23:32:05 +00:00
|
|
|
GTK_ICON_SIZE_BUTTON);
|
2010-11-22 22:05:59 +00:00
|
|
|
gtk_button_set_image (GTK_BUTTON (button), w);
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (self->priv->app_chooser_widget), button, FALSE, FALSE, 6);
|
2010-11-22 22:05:59 +00:00
|
|
|
gtk_widget_show_all (button);
|
|
|
|
|
|
|
|
g_signal_connect (button, "clicked",
|
2010-11-24 23:32:05 +00:00
|
|
|
G_CALLBACK (show_more_button_clicked_cb), self);
|
2010-11-22 22:05:59 +00:00
|
|
|
|
2010-11-17 18:28:48 +00:00
|
|
|
gtk_dialog_add_button (GTK_DIALOG (self),
|
2010-11-24 23:32:05 +00:00
|
|
|
GTK_STOCK_CANCEL,
|
|
|
|
GTK_RESPONSE_CANCEL);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
/* Create a custom stock icon */
|
|
|
|
self->priv->button = gtk_button_new ();
|
|
|
|
|
|
|
|
label = gtk_label_new_with_mnemonic (_("_Open"));
|
|
|
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (self->priv->button));
|
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
self->priv->open_label = label;
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (self->priv->button),
|
2010-11-24 23:32:05 +00:00
|
|
|
self->priv->open_label);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
gtk_widget_show (self->priv->button);
|
|
|
|
gtk_widget_set_can_default (self->priv->button, TRUE);
|
|
|
|
|
|
|
|
gtk_dialog_add_action_widget (GTK_DIALOG (self),
|
2010-11-24 23:32:05 +00:00
|
|
|
self->priv->button, GTK_RESPONSE_OK);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (self),
|
2010-11-24 23:32:05 +00:00
|
|
|
GTK_RESPONSE_OK);
|
2010-11-17 18:28:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
set_gfile_and_content_type (GtkAppChooserDialog *self,
|
2010-11-24 23:32:05 +00:00
|
|
|
GFile *file)
|
2010-11-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
GFileInfo *info;
|
|
|
|
|
|
|
|
if (file == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->priv->gfile = g_object_ref (file);
|
|
|
|
|
|
|
|
info = g_file_query_info (self->priv->gfile,
|
2010-11-24 23:32:05 +00:00
|
|
|
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
|
|
|
|
0, NULL, NULL);
|
2010-11-17 18:28:48 +00:00
|
|
|
self->priv->content_type = g_strdup (g_file_info_get_content_type (info));
|
|
|
|
|
|
|
|
g_object_unref (info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GAppInfo *
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_dialog_get_app_info (GtkAppChooser *object)
|
2010-11-17 18:28:48 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
2010-11-17 18:28:48 +00:00
|
|
|
GAppInfo *app = NULL;
|
|
|
|
|
|
|
|
if (!check_application (self, &app))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return app;
|
|
|
|
}
|
|
|
|
|
2010-11-22 22:02:57 +00:00
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_dialog_refresh (GtkAppChooser *object)
|
2010-11-22 22:02:57 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
2010-11-22 22:02:57 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->priv->app_chooser_widget));
|
2010-11-22 22:02:57 +00:00
|
|
|
}
|
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_dialog_constructed (GObject *object)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
g_assert (self->priv->content_type != NULL ||
|
2010-11-24 23:32:05 +00:00
|
|
|
self->priv->gfile != NULL);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
if (G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->constructed != NULL)
|
|
|
|
G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->constructed (object);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
2010-11-17 18:28:48 +00:00
|
|
|
build_dialog_ui (self);
|
2010-11-16 12:47:51 +00:00
|
|
|
set_dialog_properties (self);
|
2010-11-29 17:10:06 +00:00
|
|
|
ensure_online_button (self);
|
2010-11-16 12:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-29 17:10:06 +00:00
|
|
|
gtk_app_chooser_dialog_dispose (GObject *object)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
2010-11-29 17:10:06 +00:00
|
|
|
|
|
|
|
g_clear_object (&self->priv->gfile);
|
|
|
|
g_clear_object (&self->priv->online);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
2010-11-29 17:10:06 +00:00
|
|
|
G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_app_chooser_dialog_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
g_free (self->priv->content_type);
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->finalize (object);
|
2010-11-16 12:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-24 23:32:05 +00:00
|
|
|
gtk_app_chooser_dialog_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_GFILE:
|
2010-11-17 18:28:48 +00:00
|
|
|
set_gfile_and_content_type (self, g_value_get_object (value));
|
2010-11-16 12:47:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_CONTENT_TYPE:
|
2010-11-17 18:28:48 +00:00
|
|
|
/* don't try to override a value previously set with the GFile */
|
|
|
|
if (self->priv->content_type == NULL)
|
2010-11-24 23:32:05 +00:00
|
|
|
self->priv->content_type = g_value_dup_string (value);
|
2010-11-16 12:47:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-24 23:32:05 +00:00
|
|
|
gtk_app_chooser_dialog_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GtkAppChooserDialog *self = GTK_APP_CHOOSER_DIALOG (object);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_GFILE:
|
|
|
|
if (self->priv->gfile != NULL)
|
2010-11-24 23:32:05 +00:00
|
|
|
g_value_set_object (value, self->priv->gfile);
|
2010-11-16 12:47:51 +00:00
|
|
|
break;
|
|
|
|
case PROP_CONTENT_TYPE:
|
|
|
|
g_value_set_string (value, self->priv->content_type);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-17 18:28:48 +00:00
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_dialog_iface_init (GtkAppChooserIface *iface)
|
2010-11-17 18:28:48 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
iface->get_app_info = gtk_app_chooser_dialog_get_app_info;
|
|
|
|
iface->refresh = gtk_app_chooser_dialog_refresh;
|
2010-11-17 18:28:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_dialog_class_init (GtkAppChooserDialogClass *klass)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2010-11-17 18:28:48 +00:00
|
|
|
GParamSpec *pspec;
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
2010-11-29 17:10:06 +00:00
|
|
|
gobject_class->dispose = gtk_app_chooser_dialog_dispose;
|
2010-11-23 16:23:37 +00:00
|
|
|
gobject_class->finalize = gtk_app_chooser_dialog_finalize;
|
|
|
|
gobject_class->set_property = gtk_app_chooser_dialog_set_property;
|
|
|
|
gobject_class->get_property = gtk_app_chooser_dialog_get_property;
|
|
|
|
gobject_class->constructed = gtk_app_chooser_dialog_constructed;
|
2010-11-16 12:47:51 +00:00
|
|
|
|
2010-11-17 18:28:48 +00:00
|
|
|
g_object_class_override_property (gobject_class, PROP_CONTENT_TYPE, "content-type");
|
|
|
|
|
2010-11-30 14:03:33 +00:00
|
|
|
/**
|
|
|
|
* GtkAppChooserDialog:gfile:
|
|
|
|
*
|
|
|
|
* The GFile used by the #GtkAppChooserDialog.
|
|
|
|
* The dialog's #GtkAppChooserWidget content type will be guessed from the
|
|
|
|
* file, if present.
|
|
|
|
*/
|
2010-11-17 18:28:48 +00:00
|
|
|
pspec = g_param_spec_object ("gfile",
|
2010-11-24 23:32:05 +00:00
|
|
|
P_("GFile"),
|
2010-11-30 14:03:33 +00:00
|
|
|
P_("The GFile used by the app chooser dialog"),
|
2010-11-24 23:32:05 +00:00
|
|
|
G_TYPE_FILE,
|
|
|
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2010-11-17 18:28:48 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_GFILE, pspec);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GtkAppChooserDialogPrivate));
|
2010-11-16 12:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_dialog_init (GtkAppChooserDialog *self)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTK_TYPE_APP_CHOOSER_DIALOG,
|
2010-11-24 23:32:05 +00:00
|
|
|
GtkAppChooserDialogPrivate);
|
2010-11-24 14:49:47 +00:00
|
|
|
|
|
|
|
/* 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",
|
2010-11-24 23:32:05 +00:00
|
|
|
G_CALLBACK (gtk_app_chooser_dialog_response), NULL);
|
2010-11-16 12:47:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-11-24 23:32:05 +00:00
|
|
|
set_parent_and_flags (GtkWidget *dialog,
|
|
|
|
GtkWindow *parent,
|
|
|
|
GtkDialogFlags flags)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
|
|
|
if (parent != NULL)
|
2010-11-24 23:32:05 +00:00
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
|
|
|
|
2010-11-16 12:47:51 +00:00
|
|
|
if (flags & GTK_DIALOG_MODAL)
|
|
|
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
|
|
|
|
|
|
|
if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
|
|
|
|
}
|
|
|
|
|
2010-11-16 18:24:00 +00:00
|
|
|
/**
|
2010-11-23 16:23:37 +00:00
|
|
|
* gtk_app_chooser_dialog_new:
|
2010-11-16 18:24:00 +00:00
|
|
|
* @parent: (allow-none): a #GtkWindow, or %NULL
|
|
|
|
* @flags: flags for this dialog
|
|
|
|
* @file: a #GFile
|
|
|
|
*
|
2010-11-24 23:32:05 +00:00
|
|
|
* Creates a new #GtkAppChooserDialog for the provided #GFile,
|
|
|
|
* to allow the user to select an application for it.
|
2010-11-16 18:24:00 +00:00
|
|
|
*
|
2010-11-23 16:23:37 +00:00
|
|
|
* Returns: a newly created #GtkAppChooserDialog
|
2010-11-16 18:24:00 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-11-16 12:47:51 +00:00
|
|
|
GtkWidget *
|
2010-11-24 23:32:05 +00:00
|
|
|
gtk_app_chooser_dialog_new (GtkWindow *parent,
|
|
|
|
GtkDialogFlags flags,
|
|
|
|
GFile *file)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
|
|
|
GtkWidget *retval;
|
|
|
|
|
|
|
|
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
retval = g_object_new (GTK_TYPE_APP_CHOOSER_DIALOG,
|
2010-11-24 23:32:05 +00:00
|
|
|
"gfile", file,
|
|
|
|
NULL);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
set_parent_and_flags (retval, parent, flags);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-11-16 18:24:00 +00:00
|
|
|
/**
|
2010-11-23 16:23:37 +00:00
|
|
|
* gtk_app_chooser_dialog_new_for_content_type:
|
2010-11-16 18:24:00 +00:00
|
|
|
* @parent: (allow-none): a #GtkWindow, or %NULL
|
|
|
|
* @flags: flags for this dialog
|
|
|
|
* @content_type: a content type string
|
|
|
|
*
|
2010-11-24 23:32:05 +00:00
|
|
|
* Creates a new #GtkAppChooserDialog for the provided content type,
|
|
|
|
* to allow the user to select an application for it.
|
2010-11-16 18:24:00 +00:00
|
|
|
*
|
2010-11-23 16:23:37 +00:00
|
|
|
* Returns: a newly created #GtkAppChooserDialog
|
2010-11-16 18:24:00 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-11-16 12:47:51 +00:00
|
|
|
GtkWidget *
|
2010-11-24 23:32:05 +00:00
|
|
|
gtk_app_chooser_dialog_new_for_content_type (GtkWindow *parent,
|
|
|
|
GtkDialogFlags flags,
|
|
|
|
const gchar *content_type)
|
2010-11-16 12:47:51 +00:00
|
|
|
{
|
|
|
|
GtkWidget *retval;
|
|
|
|
|
|
|
|
g_return_val_if_fail (content_type != NULL, NULL);
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
retval = g_object_new (GTK_TYPE_APP_CHOOSER_DIALOG,
|
2010-11-24 23:32:05 +00:00
|
|
|
"content-type", content_type,
|
|
|
|
NULL);
|
2010-11-16 12:47:51 +00:00
|
|
|
|
|
|
|
set_parent_and_flags (retval, parent, flags);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2010-11-16 13:31:03 +00:00
|
|
|
|
2010-11-24 23:32:05 +00:00
|
|
|
/**
|
|
|
|
* gtk_app_chooser_dialog_get_widget:
|
|
|
|
* @self: a #GtkAppChooserDialog
|
|
|
|
*
|
|
|
|
* Returns the #GtkAppChooserWidget of this dialog.
|
|
|
|
*
|
2010-11-30 16:27:53 +00:00
|
|
|
* Returns: (transfer none): the #GtkAppChooserWidget of @self
|
2010-11-24 23:32:05 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
2010-11-17 18:28:48 +00:00
|
|
|
GtkWidget *
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_dialog_get_widget (GtkAppChooserDialog *self)
|
2010-11-16 17:02:29 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_APP_CHOOSER_DIALOG (self), NULL);
|
2010-11-16 17:02:29 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
return self->priv->app_chooser_widget;
|
2010-11-16 18:23:15 +00:00
|
|
|
}
|