2010-11-17 18:28:48 +00:00
|
|
|
/*
|
2010-11-23 16:23:37 +00:00
|
|
|
* gtkappchooser.c: app-chooser interface
|
2010-11-17 18:28:48 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-11-17 18:28:48 +00:00
|
|
|
*
|
|
|
|
* Authors: Cosimo Cecchi <ccecchi@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2011-01-06 07:07:35 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtkappchooser
|
|
|
|
* @Title: GtkAppChooser
|
2011-08-07 10:09:10 +00:00
|
|
|
* @Short_description: Interface implemented by widgets for choosing an application
|
2011-09-10 05:40:05 +00:00
|
|
|
* @See_also: #GAppInfo
|
2011-01-06 07:07:35 +00:00
|
|
|
*
|
|
|
|
* #GtkAppChooser is an interface that can be implemented by widgets which
|
|
|
|
* allow the user to choose an application (typically for the purpose of
|
|
|
|
* opening a file). The main objects that implement this interface are
|
|
|
|
* #GtkAppChooserWidget, #GtkAppChooserDialog and #GtkAppChooserButton.
|
2011-09-10 05:40:05 +00:00
|
|
|
*
|
|
|
|
* Applications are represented by GIO #GAppInfo objects here.
|
|
|
|
* GIO has a concept of recommended and fallback applications for a
|
|
|
|
* given content type. Recommended applications are those that claim
|
|
|
|
* to handle the content type itself, while fallback also includes
|
|
|
|
* applications that handle a more generic content type. GIO also
|
|
|
|
* knows the default and last-used application for a given content
|
|
|
|
* type. The #GtkAppChooserWidget provides detailed control over
|
|
|
|
* whether the shown list of applications should include default,
|
|
|
|
* recommended or fallback applications.
|
|
|
|
*
|
|
|
|
* To obtain the application that has been selected in a #GtkAppChooser,
|
|
|
|
* use gtk_app_chooser_get_app_info().
|
2011-01-06 07:07:35 +00:00
|
|
|
*/
|
|
|
|
|
2010-11-24 23:32:05 +00:00
|
|
|
#include "config.h"
|
2010-11-17 18:28:48 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
#include "gtkappchooser.h"
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
#include "gtkintl.h"
|
2010-11-23 16:23:37 +00:00
|
|
|
#include "gtkappchooserprivate.h"
|
2010-11-17 18:28:48 +00:00
|
|
|
#include "gtkwidget.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
G_DEFINE_INTERFACE (GtkAppChooser, gtk_app_chooser, GTK_TYPE_WIDGET);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
static void
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_default_init (GtkAppChooserIface *iface)
|
2010-11-17 18:28:48 +00:00
|
|
|
{
|
|
|
|
GParamSpec *pspec;
|
|
|
|
|
2010-11-30 14:03:33 +00:00
|
|
|
/**
|
|
|
|
* GtkAppChooser:content-type:
|
|
|
|
*
|
|
|
|
* The content type of the #GtkAppChooser object.
|
2011-06-01 00:00:50 +00:00
|
|
|
*
|
2014-02-07 02:07:03 +00:00
|
|
|
* See [GContentType][gio-GContentType]
|
2011-06-01 00:00:50 +00:00
|
|
|
* for more information about content types.
|
2010-11-30 14:03:33 +00:00
|
|
|
*/
|
2010-11-17 18:28:48 +00:00
|
|
|
pspec = g_param_spec_string ("content-type",
|
2010-11-24 23:32:05 +00:00
|
|
|
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);
|
2010-11-17 18:28:48 +00:00
|
|
|
g_object_interface_install_property (iface, pspec);
|
|
|
|
}
|
|
|
|
|
2010-11-30 14:03:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
*/
|
2020-07-24 18:40:36 +00:00
|
|
|
char *
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_get_content_type (GtkAppChooser *self)
|
2010-11-17 18:28:48 +00:00
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
char *retval = NULL;
|
2010-11-17 18:28:48 +00:00
|
|
|
|
2010-11-23 16:23:37 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_APP_CHOOSER (self), NULL);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
g_object_get (self,
|
2010-11-24 23:32:05 +00:00
|
|
|
"content-type", &retval,
|
|
|
|
NULL);
|
2010-11-17 18:28:48 +00:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-11-24 23:32:05 +00:00
|
|
|
/**
|
|
|
|
* gtk_app_chooser_get_app_info:
|
|
|
|
* @self: a #GtkAppChooser
|
|
|
|
*
|
|
|
|
* Returns the currently selected application.
|
|
|
|
*
|
2015-12-28 20:14:08 +00:00
|
|
|
* Returns: (nullable) (transfer full): a #GAppInfo for the currently selected
|
2010-11-30 14:03:33 +00:00
|
|
|
* application, or %NULL if none is selected. Free with g_object_unref()
|
2010-11-24 23:32:05 +00:00
|
|
|
*/
|
2010-11-17 18:28:48 +00:00
|
|
|
GAppInfo *
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_get_app_info (GtkAppChooser *self)
|
2010-11-17 18:28:48 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
return GTK_APP_CHOOSER_GET_IFACE (self)->get_app_info (self);
|
2010-11-17 18:28:48 +00:00
|
|
|
}
|
2010-11-22 22:02:57 +00:00
|
|
|
|
2010-11-24 23:32:05 +00:00
|
|
|
/**
|
|
|
|
* gtk_app_chooser_refresh:
|
|
|
|
* @self: a #GtkAppChooser
|
|
|
|
*
|
2010-11-30 14:03:33 +00:00
|
|
|
* Reloads the list of applications.
|
2010-11-24 23:32:05 +00:00
|
|
|
*/
|
2010-11-22 22:02:57 +00:00
|
|
|
void
|
2010-11-23 16:23:37 +00:00
|
|
|
gtk_app_chooser_refresh (GtkAppChooser *self)
|
2010-11-22 22:02:57 +00:00
|
|
|
{
|
2010-11-23 16:23:37 +00:00
|
|
|
GTK_APP_CHOOSER_GET_IFACE (self)->refresh (self);
|
2010-11-22 22:02:57 +00:00
|
|
|
}
|