gtk: Remove GtkRecentChooser

It's not used any more, recent files are only used by the filtchooser
and that one uses GtkRecentManager directly.
This commit is contained in:
Benjamin Otte 2018-02-02 18:01:17 +01:00
parent bb8baa2b76
commit 55874470ff
33 changed files with 0 additions and 7400 deletions

View File

@ -276,11 +276,6 @@
<chapter id="RecentDocuments"> <chapter id="RecentDocuments">
<title>Recently Used Documents</title> <title>Recently Used Documents</title>
<xi:include href="xml/gtkrecentmanager.xml" /> <xi:include href="xml/gtkrecentmanager.xml" />
<xi:include href="xml/gtkrecentchooser.xml" />
<xi:include href="xml/gtkrecentchooserdialog.xml" />
<xi:include href="xml/gtkrecentchoosermenu.xml" />
<xi:include href="xml/gtkrecentchooserwidget.xml" />
<xi:include href="xml/gtkrecentfilter.xml" />
</chapter> </chapter>
<chapter id="ApplicationChoosing"> <chapter id="ApplicationChoosing">

View File

@ -2179,143 +2179,6 @@ gtk_range_get_type
GtkRangePrivate GtkRangePrivate
</SECTION> </SECTION>
<SECTION>
<FILE>gtkrecentchooser</FILE>
<TITLE>GtkRecentChooser</TITLE>
GtkRecentChooser
GtkRecentChooserIface
GTK_RECENT_CHOOSER_ERROR
GtkRecentChooserError
gtk_recent_chooser_set_show_private
gtk_recent_chooser_get_show_private
gtk_recent_chooser_set_show_not_found
gtk_recent_chooser_get_show_not_found
gtk_recent_chooser_set_show_icons
gtk_recent_chooser_get_show_icons
gtk_recent_chooser_set_select_multiple
gtk_recent_chooser_get_select_multiple
gtk_recent_chooser_set_local_only
gtk_recent_chooser_get_local_only
gtk_recent_chooser_set_limit
gtk_recent_chooser_get_limit
gtk_recent_chooser_set_show_tips
gtk_recent_chooser_get_show_tips
GtkRecentSortType
gtk_recent_chooser_set_sort_type
gtk_recent_chooser_get_sort_type
GtkRecentSortFunc
gtk_recent_chooser_set_sort_func
gtk_recent_chooser_set_current_uri
gtk_recent_chooser_get_current_uri
gtk_recent_chooser_get_current_item
gtk_recent_chooser_select_uri
gtk_recent_chooser_unselect_uri
gtk_recent_chooser_select_all
gtk_recent_chooser_unselect_all
gtk_recent_chooser_get_items
gtk_recent_chooser_get_uris
gtk_recent_chooser_add_filter
gtk_recent_chooser_remove_filter
gtk_recent_chooser_list_filters
gtk_recent_chooser_set_filter
gtk_recent_chooser_get_filter
<SUBSECTION Standard>
GTK_RECENT_CHOOSER
GTK_IS_RECENT_CHOOSER
GTK_TYPE_RECENT_CHOOSER
GTK_RECENT_CHOOSER_GET_IFACE
<SUBSECTION Private>
gtk_recent_chooser_get_type
gtk_recent_chooser_error_quark
</SECTION>
<SECTION>
<FILE>gtkrecentchooserdialog</FILE>
<TITLE>GtkRecentChooserDialog</TITLE>
GtkRecentChooserDialog
gtk_recent_chooser_dialog_new
gtk_recent_chooser_dialog_new_for_manager
<SUBSECTION Standard>
GTK_RECENT_CHOOSER_DIALOG
GTK_IS_RECENT_CHOOSER_DIALOG
GTK_TYPE_RECENT_CHOOSER_DIALOG
GTK_RECENT_CHOOSER_DIALOG_CLASS
GTK_IS_RECENT_CHOOSER_DIALOG_CLASS
GTK_RECENT_CHOOSER_DIALOG_GET_CLASS
<SUBSECTION Private>
gtk_recent_chooser_dialog_get_type
GtkRecentChooserDialogPrivate
</SECTION>
<SECTION>
<FILE>gtkrecentchoosermenu</FILE>
<TITLE>GtkRecentChooserMenu</TITLE>
GtkRecentChooserMenu
gtk_recent_chooser_menu_new
gtk_recent_chooser_menu_new_for_manager
gtk_recent_chooser_menu_get_show_numbers
gtk_recent_chooser_menu_set_show_numbers
<SUBSECTION Standard>
GTK_RECENT_CHOOSER_MENU
GTK_IS_RECENT_CHOOSER_MENU
GTK_TYPE_RECENT_CHOOSER_MENU
GTK_RECENT_CHOOSER_MENU_CLASS
GTK_IS_RECENT_CHOOSER_MENU_CLASS
GTK_RECENT_CHOOSER_MENU_GET_CLASS
<SUBSECTION Private>
gtk_recent_chooser_menu_get_type
GtkRecentChooserMenuPrivate
</SECTION>
<SECTION>
<FILE>gtkrecentchooserwidget</FILE>
<TITLE>GtkRecentChooserWidget</TITLE>
GtkRecentChooserWidget
gtk_recent_chooser_widget_new
gtk_recent_chooser_widget_new_for_manager
<SUBSECTION Standard>
GTK_RECENT_CHOOSER_WIDGET
GTK_IS_RECENT_CHOOSER_WIDGET
GTK_TYPE_RECENT_CHOOSER_WIDGET
GTK_RECENT_CHOOSER_WIDGET_CLASS
GTK_IS_RECENT_CHOOSER_WIDGET_CLASS
GTK_RECENT_CHOOSER_WIDGET_GET_CLASS
<SUBSECTION Private>
gtk_recent_chooser_widget_get_type
GtkRecentChooserWidgetPrivate
</SECTION>
<SECTION>
<FILE>gtkrecentfilter</FILE>
<TITLE>GtkRecentFilter</TITLE>
GtkRecentFilter
GtkRecentFilterInfo
GtkRecentFilterFlags
GtkRecentFilterFunc
gtk_recent_filter_new
gtk_recent_filter_get_name
gtk_recent_filter_set_name
gtk_recent_filter_add_mime_type
gtk_recent_filter_add_pattern
gtk_recent_filter_add_pixbuf_formats
gtk_recent_filter_add_application
gtk_recent_filter_add_group
gtk_recent_filter_add_age
gtk_recent_filter_add_custom
gtk_recent_filter_get_needed
gtk_recent_filter_filter
<SUBSECTION Standard>
GTK_RECENT_FILTER
GTK_IS_RECENT_FILTER
GTK_TYPE_RECENT_FILTER
<SUBSECTION Private>
gtk_recent_filter_get_type
</SECTION>
<SECTION> <SECTION>
<FILE>gtkrecentmanager</FILE> <FILE>gtkrecentmanager</FILE>
<TITLE>GtkRecentManager</TITLE> <TITLE>GtkRecentManager</TITLE>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

View File

@ -112,7 +112,6 @@ images = [
'images/printdialog.png', 'images/printdialog.png',
'images/progressbar.png', 'images/progressbar.png',
'images/radio-group.png', 'images/radio-group.png',
'images/recentchooserdialog.png',
'images/right-center.png', 'images/right-center.png',
'images/right-end.png', 'images/right-end.png',
'images/right-start.png', 'images/right-start.png',

View File

@ -198,9 +198,6 @@
<link linkend="GtkFileChooserDialog"> <link linkend="GtkFileChooserDialog">
<inlinegraphic fileref="filechooser.png" format="PNG"></inlinegraphic> <inlinegraphic fileref="filechooser.png" format="PNG"></inlinegraphic>
</link> </link>
<link linkend="GtkRecentChooserDialog">
<inlinegraphic fileref="recentchooserdialog.png" format="PNG"></inlinegraphic>
</link>
<link linkend="GtkFontChooserDialog"> <link linkend="GtkFontChooserDialog">
<inlinegraphic fileref="fontchooser.png" format="PNG"></inlinegraphic> <inlinegraphic fileref="fontchooser.png" format="PNG"></inlinegraphic>
</link> </link>

View File

@ -448,25 +448,6 @@ create_action_bar (void)
return info; return info;
} }
static WidgetInfo *
create_recent_chooser_dialog (void)
{
WidgetInfo *info;
GtkWidget *widget;
widget = gtk_recent_chooser_dialog_new ("Recent Chooser Dialog",
NULL,
"Cancel", GTK_RESPONSE_CANCEL,
"Open", GTK_RESPONSE_ACCEPT,
NULL);
gtk_window_set_default_size (GTK_WINDOW (widget), 505, 305);
info = new_widget_info ("recentchooserdialog", widget, ASIS);
info->include_decorations = TRUE;
return info;
}
static WidgetInfo * static WidgetInfo *
create_text_view (void) create_text_view (void)
{ {
@ -1511,7 +1492,6 @@ get_all_widgets (void)
retval = g_list_prepend (retval, create_window ()); retval = g_list_prepend (retval, create_window ());
retval = g_list_prepend (retval, create_filesel ()); retval = g_list_prepend (retval, create_filesel ());
retval = g_list_prepend (retval, create_assistant ()); retval = g_list_prepend (retval, create_assistant ());
retval = g_list_prepend (retval, create_recent_chooser_dialog ());
retval = g_list_prepend (retval, create_page_setup_dialog ()); retval = g_list_prepend (retval, create_page_setup_dialog ());
retval = g_list_prepend (retval, create_print_dialog ()); retval = g_list_prepend (retval, create_print_dialog ());
retval = g_list_prepend (retval, create_volume_button ()); retval = g_list_prepend (retval, create_volume_button ());

View File

@ -130,11 +130,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioButton, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioMenuItem, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioMenuItem, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioToolButton, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRadioToolButton, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRange, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRange, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentChooser, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentChooserDialog, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentChooserMenu, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentChooserWidget, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentFilter, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentManager, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRecentManager, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRevealer, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRevealer, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkScale, g_object_unref) G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkScale, g_object_unref)

View File

@ -167,11 +167,6 @@
#include <gtk/gtkradiomenuitem.h> #include <gtk/gtkradiomenuitem.h>
#include <gtk/gtkradiotoolbutton.h> #include <gtk/gtkradiotoolbutton.h>
#include <gtk/gtkrange.h> #include <gtk/gtkrange.h>
#include <gtk/gtkrecentchooser.h>
#include <gtk/gtkrecentchooserdialog.h>
#include <gtk/gtkrecentchoosermenu.h>
#include <gtk/gtkrecentchooserwidget.h>
#include <gtk/gtkrecentfilter.h>
#include <gtk/gtkrecentmanager.h> #include <gtk/gtkrecentmanager.h>
#include <gtk/gtkrender.h> #include <gtk/gtkrender.h>
#include <gtk/gtkrevealer.h> #include <gtk/gtkrevealer.h>

View File

@ -1,999 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentchooser.c - Abstract interface for recent file selectors GUIs
*
* Copyright (C) 2006, Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkrecentchooser.h"
#include "gtkrecentchooserprivate.h"
#include "gtkrecentmanager.h"
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
#include "gtkmarshalers.h"
/**
* SECTION:gtkrecentchooser
* @Short_description: Interface implemented by widgets displaying recently
* used files
* @Title: GtkRecentChooser
* @See_also: #GtkRecentManager, #GtkRecentChooserDialog,
* #GtkRecentChooserWidget, #GtkRecentChooserMenu
*
* #GtkRecentChooser is an interface that can be implemented by widgets
* displaying the list of recently used files. In GTK+, the main objects
* that implement this interface are #GtkRecentChooserWidget,
* #GtkRecentChooserDialog and #GtkRecentChooserMenu.
*
* Recently used files are supported since GTK+ 2.10.
*/
enum
{
ITEM_ACTIVATED,
SELECTION_CHANGED,
LAST_SIGNAL
};
static guint chooser_signals[LAST_SIGNAL] = { 0, };
typedef GtkRecentChooserIface GtkRecentChooserInterface;
G_DEFINE_INTERFACE (GtkRecentChooser, gtk_recent_chooser, G_TYPE_OBJECT);
static void
gtk_recent_chooser_default_init (GtkRecentChooserInterface *iface)
{
GType iface_type = G_TYPE_FROM_INTERFACE (iface);
/**
* GtkRecentChooser::selection-changed:
* @chooser: the object which received the signal
*
* This signal is emitted when there is a change in the set of
* selected recently used resources. This can happen when a user
* modifies the selection with the mouse or the keyboard, or when
* explicitly calling functions to change the selection.
*
* Since: 2.10
*/
chooser_signals[SELECTION_CHANGED] =
g_signal_new (I_("selection-changed"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkRecentChooserIface, selection_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GtkRecentChooser::item-activated:
* @chooser: the object which received the signal
*
* This signal is emitted when the user "activates" a recent item
* in the recent chooser. This can happen by double-clicking on an item
* in the recently used resources list, or by pressing
* `Enter`.
*
* Since: 2.10
*/
chooser_signals[ITEM_ACTIVATED] =
g_signal_new (I_("item-activated"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkRecentChooserIface, item_activated),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GtkRecentChooser:recent-manager:
*
* The #GtkRecentManager instance used by the #GtkRecentChooser to
* display the list of recently used resources.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_object ("recent-manager",
P_("Recent Manager"),
P_("The RecentManager object to use"),
GTK_TYPE_RECENT_MANAGER,
GTK_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY));
/**
* GtkRecentManager:show-private:
*
* Whether this #GtkRecentChooser should display recently used resources
* marked with the "private" flag. Such resources should be considered
* private to the applications and groups that have added them.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("show-private",
P_("Show Private"),
P_("Whether the private items should be displayed"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkRecentChooser:show-tips:
*
* Whether this #GtkRecentChooser should display a tooltip containing the
* full path of the recently used resources.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("show-tips",
P_("Show Tooltips"),
P_("Whether there should be a tooltip on the item"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkRecentChooser:show-icons:
*
* Whether this #GtkRecentChooser should display an icon near the item.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("show-icons",
P_("Show Icons"),
P_("Whether there should be an icon near the item"),
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkRecentChooser:show-not-found:
*
* Whether this #GtkRecentChooser should display the recently used resources
* even if not present anymore. Setting this to %FALSE will perform a
* potentially expensive check on every local resource (every remote
* resource will always be displayed).
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("show-not-found",
P_("Show Not Found"),
P_("Whether the items pointing to unavailable resources should be displayed"),
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkRecentChooser:select-multiple:
*
* Allow the user to select multiple resources.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("select-multiple",
P_("Select Multiple"),
P_("Whether to allow multiple items to be selected"),
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkRecentChooser:local-only:
*
* Whether this #GtkRecentChooser should display only local (file:)
* resources.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_boolean ("local-only",
P_("Local only"),
P_("Whether the selected resource(s) should be limited to local file: URIs"),
TRUE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkRecentChooser:limit:
*
* The maximum number of recently used resources to be displayed,
* or -1 to display all items.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_int ("limit",
P_("Limit"),
P_("The maximum number of items to be displayed"),
-1, G_MAXINT, 50,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkRecentChooser:sort-type:
*
* Sorting order to be used when displaying the recently used resources.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_enum ("sort-type",
P_("Sort Type"),
P_("The sorting order of the items displayed"),
GTK_TYPE_RECENT_SORT_TYPE,
GTK_RECENT_SORT_NONE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
/**
* GtkRecentChooser:filter:
*
* The #GtkRecentFilter object to be used when displaying
* the recently used resources.
*
* Since: 2.10
*/
g_object_interface_install_property (iface,
g_param_spec_object ("filter",
P_("Filter"),
P_("The current filter for selecting which resources are displayed"),
GTK_TYPE_RECENT_FILTER,
GTK_PARAM_READWRITE));
}
GQuark
gtk_recent_chooser_error_quark (void)
{
return g_quark_from_static_string ("gtk-recent-chooser-error-quark");
}
/**
* _gtk_recent_chooser_get_recent_manager:
* @chooser: a #GtkRecentChooser
*
* Gets the #GtkRecentManager used by @chooser.
*
* Returns: the recent manager for @chooser.
*
* Since: 2.10
*/
GtkRecentManager *
_gtk_recent_chooser_get_recent_manager (GtkRecentChooser *chooser)
{
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_recent_manager (chooser);
}
/**
* gtk_recent_chooser_set_show_private:
* @chooser: a #GtkRecentChooser
* @show_private: %TRUE to show private items, %FALSE otherwise
*
* Whether to show recently used resources marked registered as private.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser,
gboolean show_private)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_object_set (chooser, "show-private", show_private, NULL);
}
/**
* gtk_recent_chooser_get_show_private:
* @chooser: a #GtkRecentChooser
*
* Returns whether @chooser should display recently used resources
* registered as private.
*
* Returns: %TRUE if the recent chooser should show private items,
* %FALSE otherwise.
*
* Since: 2.10
*/
gboolean
gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser)
{
gboolean show_private;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
g_object_get (chooser, "show-private", &show_private, NULL);
return show_private;
}
/**
* gtk_recent_chooser_set_show_not_found:
* @chooser: a #GtkRecentChooser
* @show_not_found: whether to show the local items we didnt find
*
* Sets whether @chooser should display the recently used resources that
* it didnt find. This only applies to local resources.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_show_not_found (GtkRecentChooser *chooser,
gboolean show_not_found)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_object_set (chooser, "show-not-found", show_not_found, NULL);
}
/**
* gtk_recent_chooser_get_show_not_found:
* @chooser: a #GtkRecentChooser
*
* Retrieves whether @chooser should show the recently used resources that
* were not found.
*
* Returns: %TRUE if the resources not found should be displayed, and
* %FALSE otheriwse.
*
* Since: 2.10
*/
gboolean
gtk_recent_chooser_get_show_not_found (GtkRecentChooser *chooser)
{
gboolean show_not_found;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
g_object_get (chooser, "show-not-found", &show_not_found, NULL);
return show_not_found;
}
/**
* gtk_recent_chooser_set_show_icons:
* @chooser: a #GtkRecentChooser
* @show_icons: whether to show an icon near the resource
*
* Sets whether @chooser should show an icon near the resource when
* displaying it.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser,
gboolean show_icons)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_object_set (chooser, "show-icons", show_icons, NULL);
}
/**
* gtk_recent_chooser_get_show_icons:
* @chooser: a #GtkRecentChooser
*
* Retrieves whether @chooser should show an icon near the resource.
*
* Returns: %TRUE if the icons should be displayed, %FALSE otherwise.
*
* Since: 2.10
*/
gboolean
gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser)
{
gboolean show_icons;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
g_object_get (chooser, "show-icons", &show_icons, NULL);
return show_icons;
}
/**
* gtk_recent_chooser_set_select_multiple:
* @chooser: a #GtkRecentChooser
* @select_multiple: %TRUE if @chooser can select more than one item
*
* Sets whether @chooser can select multiple items.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_select_multiple (GtkRecentChooser *chooser,
gboolean select_multiple)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_object_set (chooser, "select-multiple", select_multiple, NULL);
}
/**
* gtk_recent_chooser_get_select_multiple:
* @chooser: a #GtkRecentChooser
*
* Gets whether @chooser can select multiple items.
*
* Returns: %TRUE if @chooser can select more than one item.
*
* Since: 2.10
*/
gboolean
gtk_recent_chooser_get_select_multiple (GtkRecentChooser *chooser)
{
gboolean select_multiple;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
g_object_get (chooser, "select-multiple", &select_multiple, NULL);
return select_multiple;
}
/**
* gtk_recent_chooser_set_local_only:
* @chooser: a #GtkRecentChooser
* @local_only: %TRUE if only local files can be shown
*
* Sets whether only local resources, that is resources using the file:// URI
* scheme, should be shown in the recently used resources selector. If
* @local_only is %TRUE (the default) then the shown resources are guaranteed
* to be accessible through the operating system native file system.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser,
gboolean local_only)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_object_set (chooser, "local-only", local_only, NULL);
}
/**
* gtk_recent_chooser_get_local_only:
* @chooser: a #GtkRecentChooser
*
* Gets whether only local resources should be shown in the recently used
* resources selector. See gtk_recent_chooser_set_local_only()
*
* Returns: %TRUE if only local resources should be shown.
*
* Since: 2.10
*/
gboolean
gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser)
{
gboolean local_only;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
g_object_get (chooser, "local-only", &local_only, NULL);
return local_only;
}
/**
* gtk_recent_chooser_set_limit:
* @chooser: a #GtkRecentChooser
* @limit: a positive integer, or -1 for all items
*
* Sets the number of items that should be returned by
* gtk_recent_chooser_get_items() and gtk_recent_chooser_get_uris().
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_limit (GtkRecentChooser *chooser,
gint limit)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_object_set (chooser, "limit", limit, NULL);
}
/**
* gtk_recent_chooser_get_limit:
* @chooser: a #GtkRecentChooser
*
* Gets the number of items returned by gtk_recent_chooser_get_items()
* and gtk_recent_chooser_get_uris().
*
* Returns: A positive integer, or -1 meaning that all items are
* returned.
*
* Since: 2.10
*/
gint
gtk_recent_chooser_get_limit (GtkRecentChooser *chooser)
{
gint limit;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), 10);
g_object_get (chooser, "limit", &limit, NULL);
return limit;
}
/**
* gtk_recent_chooser_set_show_tips:
* @chooser: a #GtkRecentChooser
* @show_tips: %TRUE if tooltips should be shown
*
* Sets whether to show a tooltips containing the full path of each
* recently used resource in a #GtkRecentChooser widget.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser,
gboolean show_tips)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_object_set (chooser, "show-tips", show_tips, NULL);
}
/**
* gtk_recent_chooser_get_show_tips:
* @chooser: a #GtkRecentChooser
*
* Gets whether @chooser should display tooltips containing the full path
* of a recently user resource.
*
* Returns: %TRUE if the recent chooser should show tooltips,
* %FALSE otherwise.
*
* Since: 2.10
*/
gboolean
gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser)
{
gboolean show_tips;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
g_object_get (chooser, "show-tips", &show_tips, NULL);
return show_tips;
}
/**
* gtk_recent_chooser_set_sort_type:
* @chooser: a #GtkRecentChooser
* @sort_type: sort order that the chooser should use
*
* Changes the sorting order of the recently used resources list displayed by
* @chooser.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_sort_type (GtkRecentChooser *chooser,
GtkRecentSortType sort_type)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_object_set (chooser, "sort-type", sort_type, NULL);
}
/**
* gtk_recent_chooser_get_sort_type:
* @chooser: a #GtkRecentChooser
*
* Gets the value set by gtk_recent_chooser_set_sort_type().
*
* Returns: the sorting order of the @chooser.
*
* Since: 2.10
*/
GtkRecentSortType
gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser)
{
GtkRecentSortType sort_type;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), GTK_RECENT_SORT_NONE);
g_object_get (chooser, "sort-type", &sort_type, NULL);
return sort_type;
}
/**
* gtk_recent_chooser_set_sort_func:
* @chooser: a #GtkRecentChooser
* @sort_func: the comparison function
* @sort_data: (allow-none): user data to pass to @sort_func, or %NULL
* @data_destroy: (allow-none): destroy notifier for @sort_data, or %NULL
*
* Sets the comparison function used when sorting to be @sort_func. If
* the @chooser has the sort type set to #GTK_RECENT_SORT_CUSTOM then
* the chooser will sort using this function.
*
* To the comparison function will be passed two #GtkRecentInfo structs and
* @sort_data; @sort_func should return a positive integer if the first
* item comes before the second, zero if the two items are equal and
* a negative integer if the first item comes after the second.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_sort_func (GtkRecentChooser *chooser,
GtkRecentSortFunc sort_func,
gpointer sort_data,
GDestroyNotify data_destroy)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_sort_func (chooser,
sort_func,
sort_data,
data_destroy);
}
/**
* gtk_recent_chooser_set_current_uri:
* @chooser: a #GtkRecentChooser
* @uri: a URI
* @error: (allow-none): return location for a #GError, or %NULL
*
* Sets @uri as the current URI for @chooser.
*
* Returns: %TRUE if the URI was found.
*
* Since: 2.10
*/
gboolean
gtk_recent_chooser_set_current_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error)
{
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->set_current_uri (chooser, uri, error);
}
/**
* gtk_recent_chooser_get_current_uri:
* @chooser: a #GtkRecentChooser
*
* Gets the URI currently selected by @chooser.
*
* Returns: a newly allocated string holding a URI.
*
* Since: 2.10
*/
gchar *
gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser)
{
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_current_uri (chooser);
}
/**
* gtk_recent_chooser_get_current_item:
* @chooser: a #GtkRecentChooser
*
* Gets the #GtkRecentInfo currently selected by @chooser.
*
* Returns: a #GtkRecentInfo. Use gtk_recent_info_unref() when
* when you have finished using it.
*
* Since: 2.10
*/
GtkRecentInfo *
gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser)
{
GtkRecentManager *manager;
GtkRecentInfo *retval;
gchar *uri;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
uri = gtk_recent_chooser_get_current_uri (chooser);
if (!uri)
return NULL;
manager = _gtk_recent_chooser_get_recent_manager (chooser);
retval = gtk_recent_manager_lookup_item (manager, uri, NULL);
g_free (uri);
return retval;
}
/**
* gtk_recent_chooser_select_uri:
* @chooser: a #GtkRecentChooser
* @uri: a URI
* @error: (allow-none): return location for a #GError, or %NULL
*
* Selects @uri inside @chooser.
*
* Returns: %TRUE if @uri was found.
*
* Since: 2.10
*/
gboolean
gtk_recent_chooser_select_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error)
{
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), FALSE);
return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_uri (chooser, uri, error);
}
/**
* gtk_recent_chooser_unselect_uri:
* @chooser: a #GtkRecentChooser
* @uri: a URI
*
* Unselects @uri inside @chooser.
*
* Since: 2.10
*/
void
gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser,
const gchar *uri)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_uri (chooser, uri);
}
/**
* gtk_recent_chooser_select_all:
* @chooser: a #GtkRecentChooser
*
* Selects all the items inside @chooser, if the @chooser supports
* multiple selection.
*
* Since: 2.10
*/
void
gtk_recent_chooser_select_all (GtkRecentChooser *chooser)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
GTK_RECENT_CHOOSER_GET_IFACE (chooser)->select_all (chooser);
}
/**
* gtk_recent_chooser_unselect_all:
* @chooser: a #GtkRecentChooser
*
* Unselects all the items inside @chooser.
*
* Since: 2.10
*/
void
gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
GTK_RECENT_CHOOSER_GET_IFACE (chooser)->unselect_all (chooser);
}
/**
* gtk_recent_chooser_get_items:
* @chooser: a #GtkRecentChooser
*
* Gets the list of recently used resources in form of #GtkRecentInfo objects.
*
* The return value of this function is affected by the sort-type and
* limit properties of @chooser.
*
* Returns: (element-type GtkRecentInfo) (transfer full): A newly allocated
* list of #GtkRecentInfo objects. You should
* use gtk_recent_info_unref() on every item of the list, and then free
* the list itself using g_list_free().
*
* Since: 2.10
*/
GList *
gtk_recent_chooser_get_items (GtkRecentChooser *chooser)
{
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->get_items (chooser);
}
/**
* gtk_recent_chooser_get_uris:
* @chooser: a #GtkRecentChooser
* @length: (out) (allow-none): return location for a the length of the
* URI list, or %NULL
*
* Gets the URI of the recently used resources.
*
* The return value of this function is affected by the sort-type and limit
* properties of @chooser.
*
* Since the returned array is %NULL terminated, @length may be %NULL.
*
* Returns: (array length=length zero-terminated=1) (transfer full):
* A newly allocated, %NULL-terminated array of strings. Use
* g_strfreev() to free it.
*
* Since: 2.10
*/
gchar **
gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
gsize *length)
{
GList *items, *l;
gchar **retval;
gsize n_items, i;
items = gtk_recent_chooser_get_items (chooser);
n_items = g_list_length (items);
retval = g_new0 (gchar *, n_items + 1);
for (l = items, i = 0; l != NULL; l = l->next)
{
GtkRecentInfo *info = (GtkRecentInfo *) l->data;
const gchar *uri;
g_assert (info != NULL);
uri = gtk_recent_info_get_uri (info);
g_assert (uri != NULL);
retval[i++] = g_strdup (uri);
}
retval[i] = NULL;
if (length)
*length = i;
g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
return retval;
}
/**
* gtk_recent_chooser_add_filter:
* @chooser: a #GtkRecentChooser
* @filter: a #GtkRecentFilter
*
* Adds @filter to the list of #GtkRecentFilter objects held by @chooser.
*
* If no previous filter objects were defined, this function will call
* gtk_recent_chooser_set_filter().
*
* Since: 2.10
*/
void
gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
GTK_RECENT_CHOOSER_GET_IFACE (chooser)->add_filter (chooser, filter);
}
/**
* gtk_recent_chooser_remove_filter:
* @chooser: a #GtkRecentChooser
* @filter: a #GtkRecentFilter
*
* Removes @filter from the list of #GtkRecentFilter objects held by @chooser.
*
* Since: 2.10
*/
void
gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
GTK_RECENT_CHOOSER_GET_IFACE (chooser)->remove_filter (chooser, filter);
}
/**
* gtk_recent_chooser_list_filters:
* @chooser: a #GtkRecentChooser
*
* Gets the #GtkRecentFilter objects held by @chooser.
*
* Returns: (element-type GtkRecentFilter) (transfer container): A singly linked list
* of #GtkRecentFilter objects. You
* should just free the returned list using g_slist_free().
*
* Since: 2.10
*/
GSList *
gtk_recent_chooser_list_filters (GtkRecentChooser *chooser)
{
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
return GTK_RECENT_CHOOSER_GET_IFACE (chooser)->list_filters (chooser);
}
/**
* gtk_recent_chooser_set_filter:
* @chooser: a #GtkRecentChooser
* @filter: (allow-none): a #GtkRecentFilter
*
* Sets @filter as the current #GtkRecentFilter object used by @chooser
* to affect the displayed recently used resources.
*
* Since: 2.10
*/
void
gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_return_if_fail (filter == NULL || GTK_IS_RECENT_FILTER (filter));
g_object_set (G_OBJECT (chooser), "filter", filter, NULL);
}
/**
* gtk_recent_chooser_get_filter:
* @chooser: a #GtkRecentChooser
*
* Gets the #GtkRecentFilter object currently used by @chooser to affect
* the display of the recently used resources.
*
* Returns: (transfer none): a #GtkRecentFilter object.
*
* Since: 2.10
*/
GtkRecentFilter *
gtk_recent_chooser_get_filter (GtkRecentChooser *chooser)
{
GtkRecentFilter *filter;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
g_object_get (G_OBJECT (chooser), "filter", &filter, NULL);
/* we need this hack because g_object_get() increases the refcount
* of the returned object; see also gtk_file_chooser_get_filter()
* inside gtkfilechooser.c
*/
if (filter)
g_object_unref (filter);
return filter;
}
void
_gtk_recent_chooser_item_activated (GtkRecentChooser *chooser)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_signal_emit (chooser, chooser_signals[ITEM_ACTIVATED], 0);
}
void
_gtk_recent_chooser_selection_changed (GtkRecentChooser *chooser)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (chooser));
g_signal_emit (chooser, chooser_signals[SELECTION_CHANGED], 0);
}

View File

@ -1,263 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentchooser.h - Abstract interface for recent file selectors GUIs
*
* Copyright (C) 2006, Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_RECENT_CHOOSER_H__
#define __GTK_RECENT_CHOOSER_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkwidget.h>
#include <gtk/gtkrecentmanager.h>
#include <gtk/gtkrecentfilter.h>
G_BEGIN_DECLS
#define GTK_TYPE_RECENT_CHOOSER (gtk_recent_chooser_get_type ())
#define GTK_RECENT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER, GtkRecentChooser))
#define GTK_IS_RECENT_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER))
#define GTK_RECENT_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_RECENT_CHOOSER, GtkRecentChooserIface))
/**
* GtkRecentSortType:
* @GTK_RECENT_SORT_NONE: Do not sort the returned list of recently used
* resources.
* @GTK_RECENT_SORT_MRU: Sort the returned list with the most recently used
* items first.
* @GTK_RECENT_SORT_LRU: Sort the returned list with the least recently used
* items first.
* @GTK_RECENT_SORT_CUSTOM: Sort the returned list using a custom sorting
* function passed using gtk_recent_chooser_set_sort_func().
*
* Used to specify the sorting method to be applyed to the recently
* used resource list.
*
* Since: 2.10
*/
typedef enum
{
GTK_RECENT_SORT_NONE = 0,
GTK_RECENT_SORT_MRU,
GTK_RECENT_SORT_LRU,
GTK_RECENT_SORT_CUSTOM
} GtkRecentSortType;
typedef gint (*GtkRecentSortFunc) (GtkRecentInfo *a,
GtkRecentInfo *b,
gpointer user_data);
typedef struct _GtkRecentChooser GtkRecentChooser; /* dummy */
typedef struct _GtkRecentChooserIface GtkRecentChooserIface;
/**
* GTK_RECENT_CHOOSER_ERROR:
*
* Used to get the #GError quark for #GtkRecentChooser errors.
*
* Since: 2.10
*/
#define GTK_RECENT_CHOOSER_ERROR (gtk_recent_chooser_error_quark ())
/**
* GtkRecentChooserError:
* @GTK_RECENT_CHOOSER_ERROR_NOT_FOUND: Indicates that a file does not exist
* @GTK_RECENT_CHOOSER_ERROR_INVALID_URI: Indicates a malformed URI
*
* These identify the various errors that can occur while calling
* #GtkRecentChooser functions.
*
* Since: 2.10
*/
typedef enum
{
GTK_RECENT_CHOOSER_ERROR_NOT_FOUND,
GTK_RECENT_CHOOSER_ERROR_INVALID_URI
} GtkRecentChooserError;
GDK_AVAILABLE_IN_ALL
GQuark gtk_recent_chooser_error_quark (void);
/**
* GtkRecentChooserIface:
* @set_current_uri: Sets uri as the current URI for chooser.
* @get_current_uri: Gets the URI currently selected by chooser.
* @select_uri: Selects uri inside chooser.
* @unselect_uri: Unselects uri inside chooser.
* @select_all: Selects all the items inside chooser, if the chooser
* supports multiple selection.
* @unselect_all: Unselects all the items inside chooser.
* @get_items: Gets the list of recently used resources in form of
* #GtkRecentInfo objects.
* @get_recent_manager: Gets the #GtkRecentManager used by chooser.
* @add_filter: Adds filter to the list of #GtkRecentFilter objects
* held by chooser.
* @remove_filter: Removes filter from the list of #GtkRecentFilter
* objects held by chooser.
* @list_filters: Gets the #GtkRecentFilter objects held by chooser.
* @set_sort_func: Sets the comparison function used when sorting to
* be sort_func.
* @item_activated: Signal emitted when the user activates a recent
* item in the recent chooser.
* @selection_changed: Signal emitted when there is a change in the
* set of selected recently used resources.
*/
struct _GtkRecentChooserIface
{
/*< private >*/
GTypeInterface base_iface;
/*< public >*/
/*
* Methods
*/
gboolean (* set_current_uri) (GtkRecentChooser *chooser,
const gchar *uri,
GError **error);
gchar * (* get_current_uri) (GtkRecentChooser *chooser);
gboolean (* select_uri) (GtkRecentChooser *chooser,
const gchar *uri,
GError **error);
void (* unselect_uri) (GtkRecentChooser *chooser,
const gchar *uri);
void (* select_all) (GtkRecentChooser *chooser);
void (* unselect_all) (GtkRecentChooser *chooser);
GList * (* get_items) (GtkRecentChooser *chooser);
GtkRecentManager *(* get_recent_manager) (GtkRecentChooser *chooser);
void (* add_filter) (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
void (* remove_filter) (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
GSList * (* list_filters) (GtkRecentChooser *chooser);
void (* set_sort_func) (GtkRecentChooser *chooser,
GtkRecentSortFunc sort_func,
gpointer sort_data,
GDestroyNotify data_destroy);
/*
* Signals
*/
void (* item_activated) (GtkRecentChooser *chooser);
void (* selection_changed) (GtkRecentChooser *chooser);
};
GDK_AVAILABLE_IN_ALL
GType gtk_recent_chooser_get_type (void) G_GNUC_CONST;
/*
* Configuration
*/
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser,
gboolean show_private);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_show_not_found (GtkRecentChooser *chooser,
gboolean show_not_found);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_get_show_not_found (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_select_multiple (GtkRecentChooser *chooser,
gboolean select_multiple);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_get_select_multiple (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_limit (GtkRecentChooser *chooser,
gint limit);
GDK_AVAILABLE_IN_ALL
gint gtk_recent_chooser_get_limit (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser,
gboolean local_only);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser,
gboolean show_tips);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser,
gboolean show_icons);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_sort_type (GtkRecentChooser *chooser,
GtkRecentSortType sort_type);
GDK_AVAILABLE_IN_ALL
GtkRecentSortType gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_sort_func (GtkRecentChooser *chooser,
GtkRecentSortFunc sort_func,
gpointer sort_data,
GDestroyNotify data_destroy);
/*
* Items handling
*/
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_set_current_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error);
GDK_AVAILABLE_IN_ALL
gchar * gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
GtkRecentInfo *gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_select_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser,
const gchar *uri);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_select_all (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
GList * gtk_recent_chooser_get_items (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
gchar ** gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
gsize *length);
/*
* Filters
*/
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
GDK_AVAILABLE_IN_ALL
GSList * gtk_recent_chooser_list_filters (GtkRecentChooser *chooser);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
GDK_AVAILABLE_IN_ALL
GtkRecentFilter *gtk_recent_chooser_get_filter (GtkRecentChooser *chooser);
G_END_DECLS
#endif /* __GTK_RECENT_CHOOSER_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentchooserdefault.h
* Copyright (C) 2006 Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_RECENT_CHOOSER_DEFAULT_H__
#define __GTK_RECENT_CHOOSER_DEFAULT_H__
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GTK_TYPE_RECENT_CHOOSER_DEFAULT (_gtk_recent_chooser_default_get_type ())
#define GTK_RECENT_CHOOSER_DEFAULT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER_DEFAULT, GtkRecentChooserDefault))
#define GTK_IS_RECENT_CHOOSER_DEFAULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER_DEFAULT))
typedef struct _GtkRecentChooserDefault GtkRecentChooserDefault;
GType _gtk_recent_chooser_default_get_type (void) G_GNUC_CONST;
GtkWidget *_gtk_recent_chooser_default_new (GtkRecentManager *recent_manager);
G_END_DECLS
#endif /* __GTK_RECENT_CHOOSER_DEFAULT_H__ */

View File

@ -1,360 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentchooserdialog.c: Recent files selector dialog
* Copyright (C) 2006 Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkrecentchooserdialog.h"
#include "gtkrecentchooserwidget.h"
#include "gtkrecentchooserutils.h"
#include "gtkrecentmanager.h"
#include "gtktypebuiltins.h"
#include "gtksettings.h"
#include "gtkdialogprivate.h"
#include "gtkbox.h"
#include <stdarg.h>
/**
* SECTION:gtkrecentchooserdialog
* @Short_description: Displays recently used files in a dialog
* @Title: GtkRecentChooserDialog
* @See_also:#GtkRecentChooser, #GtkDialog
*
* #GtkRecentChooserDialog is a dialog box suitable for displaying the recently
* used documents. This widgets works by putting a #GtkRecentChooserWidget inside
* a #GtkDialog. It exposes the #GtkRecentChooserIface interface, so you can use
* all the #GtkRecentChooser functions on the recent chooser dialog as well as
* those for #GtkDialog.
*
* Note that #GtkRecentChooserDialog does not have any methods of its own.
* Instead, you should use the functions that work on a #GtkRecentChooser.
*
* ## Typical usage ## {#gtkrecentchooser-typical-usage}
*
* In the simplest of cases, you can use the following code to use
* a #GtkRecentChooserDialog to select a recently used file:
*
* |[<!-- language="C" -->
* GtkWidget *dialog;
* gint res;
*
* dialog = gtk_recent_chooser_dialog_new ("Recent Documents",
* parent_window,
* _("_Cancel"),
* GTK_RESPONSE_CANCEL,
* _("_Open"),
* GTK_RESPONSE_ACCEPT,
* NULL);
*
* res = gtk_dialog_run (GTK_DIALOG (dialog));
* if (res == GTK_RESPONSE_ACCEPT)
* {
* GtkRecentInfo *info;
* GtkRecentChooser *chooser = GTK_RECENT_CHOOSER (dialog);
*
* info = gtk_recent_chooser_get_current_item (chooser);
* open_file (gtk_recent_info_get_uri (info));
* gtk_recent_info_unref (info);
* }
*
* gtk_widget_destroy (dialog);
* ]|
*
* Recently used files are supported since GTK+ 2.10.
*/
struct _GtkRecentChooserDialogPrivate
{
GtkRecentManager *manager;
GtkWidget *chooser;
};
#define GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE(obj) (GTK_RECENT_CHOOSER_DIALOG (obj)->priv)
static void gtk_recent_chooser_dialog_finalize (GObject *object);
static void gtk_recent_chooser_dialog_constructed (GObject *object);
static void gtk_recent_chooser_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_recent_chooser_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserDialog,
gtk_recent_chooser_dialog,
GTK_TYPE_DIALOG,
G_ADD_PRIVATE (GtkRecentChooserDialog)
G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER,
_gtk_recent_chooser_delegate_iface_init))
static void
gtk_recent_chooser_dialog_class_init (GtkRecentChooserDialogClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property = gtk_recent_chooser_dialog_set_property;
gobject_class->get_property = gtk_recent_chooser_dialog_get_property;
gobject_class->constructed = gtk_recent_chooser_dialog_constructed;
gobject_class->finalize = gtk_recent_chooser_dialog_finalize;
_gtk_recent_chooser_install_properties (gobject_class);
}
static void
gtk_recent_chooser_dialog_init (GtkRecentChooserDialog *dialog)
{
GtkRecentChooserDialogPrivate *priv;
GtkWidget *content_area;
GtkDialog *rc_dialog = GTK_DIALOG (dialog);
priv = gtk_recent_chooser_dialog_get_instance_private (dialog);
dialog->priv = priv;
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog));
content_area = gtk_dialog_get_content_area (rc_dialog);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
}
/* we intercept the GtkRecentChooser::item_activated signal and try to
* make the dialog emit a valid response signal
*/
static void
gtk_recent_chooser_item_activated_cb (GtkRecentChooser *chooser,
gpointer user_data)
{
GtkDialog *rc_dialog;
GtkRecentChooserDialog *dialog;
GtkWidget *action_area;
GList *children, *l;
dialog = GTK_RECENT_CHOOSER_DIALOG (user_data);
rc_dialog = GTK_DIALOG (dialog);
if (gtk_window_activate_default (GTK_WINDOW (dialog)))
return;
action_area = gtk_dialog_get_action_area (rc_dialog);
children = gtk_container_get_children (GTK_CONTAINER (action_area));
for (l = children; l; l = l->next)
{
GtkWidget *widget;
gint response_id;
widget = GTK_WIDGET (l->data);
response_id = gtk_dialog_get_response_for_widget (rc_dialog, widget);
if (response_id == GTK_RESPONSE_ACCEPT ||
response_id == GTK_RESPONSE_OK ||
response_id == GTK_RESPONSE_YES ||
response_id == GTK_RESPONSE_APPLY)
{
g_list_free (children);
gtk_dialog_response (GTK_DIALOG (dialog), response_id);
return;
}
}
g_list_free (children);
}
static void
gtk_recent_chooser_dialog_constructed (GObject *object)
{
GtkRecentChooserDialogPrivate *priv;
GtkWidget *content_area;
G_OBJECT_CLASS (gtk_recent_chooser_dialog_parent_class)->constructed (object);
priv = GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE (object);
if (priv->manager)
priv->chooser = g_object_new (GTK_TYPE_RECENT_CHOOSER_WIDGET,
"recent-manager", priv->manager,
NULL);
else
priv->chooser = g_object_new (GTK_TYPE_RECENT_CHOOSER_WIDGET, NULL);
g_signal_connect (priv->chooser, "item-activated",
G_CALLBACK (gtk_recent_chooser_item_activated_cb),
object);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (object));
gtk_box_pack_start (GTK_BOX (content_area),
priv->chooser);
_gtk_recent_chooser_set_delegate (GTK_RECENT_CHOOSER (object),
GTK_RECENT_CHOOSER (priv->chooser));
}
static void
gtk_recent_chooser_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkRecentChooserDialogPrivate *priv;
priv = GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE (object);
switch (prop_id)
{
case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER:
priv->manager = g_value_get_object (value);
break;
default:
g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value);
break;
}
}
static void
gtk_recent_chooser_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkRecentChooserDialogPrivate *priv;
priv = GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE (object);
g_object_get_property (G_OBJECT (priv->chooser), pspec->name, value);
}
static void
gtk_recent_chooser_dialog_finalize (GObject *object)
{
GtkRecentChooserDialog *dialog = GTK_RECENT_CHOOSER_DIALOG (object);
dialog->priv->manager = NULL;
G_OBJECT_CLASS (gtk_recent_chooser_dialog_parent_class)->finalize (object);
}
static GtkWidget *
gtk_recent_chooser_dialog_new_valist (const gchar *title,
GtkWindow *parent,
GtkRecentManager *manager,
const gchar *first_button_text,
va_list varargs)
{
GtkWidget *result;
const char *button_text = first_button_text;
gint response_id;
result = g_object_new (GTK_TYPE_RECENT_CHOOSER_DIALOG,
"title", title,
"recent-manager", manager,
NULL);
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (result), parent);
while (button_text)
{
response_id = va_arg (varargs, gint);
gtk_dialog_add_button (GTK_DIALOG (result), button_text, response_id);
button_text = va_arg (varargs, const gchar *);
}
return result;
}
/**
* gtk_recent_chooser_dialog_new:
* @title: (allow-none): Title of the dialog, or %NULL
* @parent: (allow-none): Transient parent of the dialog, or %NULL,
* @first_button_text: (allow-none): text to go in the first button, or %NULL
* @...: response ID for the first button, then additional (button, id)
* pairs, ending with %NULL
*
* Creates a new #GtkRecentChooserDialog. This function is analogous to
* gtk_dialog_new_with_buttons().
*
* Returns: a new #GtkRecentChooserDialog
*
* Since: 2.10
*/
GtkWidget *
gtk_recent_chooser_dialog_new (const gchar *title,
GtkWindow *parent,
const gchar *first_button_text,
...)
{
GtkWidget *result;
va_list varargs;
va_start (varargs, first_button_text);
result = gtk_recent_chooser_dialog_new_valist (title,
parent,
NULL,
first_button_text,
varargs);
va_end (varargs);
return result;
}
/**
* gtk_recent_chooser_dialog_new_for_manager:
* @title: (allow-none): Title of the dialog, or %NULL
* @parent: (allow-none): Transient parent of the dialog, or %NULL,
* @manager: a #GtkRecentManager
* @first_button_text: (allow-none): text to go in the first button, or %NULL
* @...: response ID for the first button, then additional (button, id)
* pairs, ending with %NULL
*
* Creates a new #GtkRecentChooserDialog with a specified recent manager.
*
* This is useful if you have implemented your own recent manager, or if you
* have a customized instance of a #GtkRecentManager object.
*
* Returns: a new #GtkRecentChooserDialog
*
* Since: 2.10
*/
GtkWidget *
gtk_recent_chooser_dialog_new_for_manager (const gchar *title,
GtkWindow *parent,
GtkRecentManager *manager,
const gchar *first_button_text,
...)
{
GtkWidget *result;
va_list varargs;
va_start (varargs, first_button_text);
result = gtk_recent_chooser_dialog_new_valist (title,
parent,
manager,
first_button_text,
varargs);
va_end (varargs);
return result;
}

View File

@ -1,81 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentchooserdialog.h: Recent files selector dialog
* Copyright (C) 2006 Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_RECENT_CHOOSER_DIALOG_H__
#define __GTK_RECENT_CHOOSER_DIALOG_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkdialog.h>
#include <gtk/gtkrecentchooser.h>
G_BEGIN_DECLS
#define GTK_TYPE_RECENT_CHOOSER_DIALOG (gtk_recent_chooser_dialog_get_type ())
#define GTK_RECENT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER_DIALOG, GtkRecentChooserDialog))
#define GTK_IS_RECENT_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER_DIALOG))
#define GTK_RECENT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_CHOOSER_DIALOG, GtkRecentChooserDialogClass))
#define GTK_IS_RECENT_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_CHOOSER_DIALOG))
#define GTK_RECENT_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_CHOOSER_DIALOG, GtkRecentChooserDialogClass))
typedef struct _GtkRecentChooserDialog GtkRecentChooserDialog;
typedef struct _GtkRecentChooserDialogClass GtkRecentChooserDialogClass;
typedef struct _GtkRecentChooserDialogPrivate GtkRecentChooserDialogPrivate;
struct _GtkRecentChooserDialog
{
GtkDialog parent_instance;
/*< private >*/
GtkRecentChooserDialogPrivate *priv;
};
struct _GtkRecentChooserDialogClass
{
GtkDialogClass parent_class;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GDK_AVAILABLE_IN_ALL
GType gtk_recent_chooser_dialog_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_recent_chooser_dialog_new (const gchar *title,
GtkWindow *parent,
const gchar *first_button_text,
...) G_GNUC_NULL_TERMINATED;
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_recent_chooser_dialog_new_for_manager (const gchar *title,
GtkWindow *parent,
GtkRecentManager *manager,
const gchar *first_button_text,
...) G_GNUC_NULL_TERMINATED;
G_END_DECLS
#endif /* __GTK_RECENT_CHOOSER_DIALOG_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,77 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentchoosermenu.h - Recently used items menu widget
* Copyright (C) 2006, Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_RECENT_CHOOSER_MENU_H__
#define __GTK_RECENT_CHOOSER_MENU_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkmenu.h>
#include <gtk/gtkrecentchooser.h>
G_BEGIN_DECLS
#define GTK_TYPE_RECENT_CHOOSER_MENU (gtk_recent_chooser_menu_get_type ())
#define GTK_RECENT_CHOOSER_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER_MENU, GtkRecentChooserMenu))
#define GTK_IS_RECENT_CHOOSER_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER_MENU))
#define GTK_RECENT_CHOOSER_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_CHOOSER_MENU, GtkRecentChooserMenuClass))
#define GTK_IS_RECENT_CHOOSER_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_CHOOSER_MENU))
#define GTK_RECENT_CHOOSER_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_CHOOSER_MENU, GtkRecentChooserMenuClass))
typedef struct _GtkRecentChooserMenu GtkRecentChooserMenu;
typedef struct _GtkRecentChooserMenuClass GtkRecentChooserMenuClass;
typedef struct _GtkRecentChooserMenuPrivate GtkRecentChooserMenuPrivate;
struct _GtkRecentChooserMenu
{
GtkMenu parent_instance;
/*< private >*/
GtkRecentChooserMenuPrivate *priv;
};
struct _GtkRecentChooserMenuClass
{
GtkMenuClass parent_class;
/* padding for future expansion */
void (* gtk_recent1) (void);
void (* gtk_recent2) (void);
void (* gtk_recent3) (void);
void (* gtk_recent4) (void);
};
GDK_AVAILABLE_IN_ALL
GType gtk_recent_chooser_menu_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_recent_chooser_menu_new (void);
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_recent_chooser_menu_new_for_manager (GtkRecentManager *manager);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_chooser_menu_get_show_numbers (GtkRecentChooserMenu *menu);
GDK_AVAILABLE_IN_ALL
void gtk_recent_chooser_menu_set_show_numbers (GtkRecentChooserMenu *menu,
gboolean show_numbers);
G_END_DECLS
#endif /* ! __GTK_RECENT_CHOOSER_MENU_H__ */

View File

@ -1,40 +0,0 @@
/* gtkrecentprivatechooser.h - Interface definitions for recent selectors UI
*
* Copyright (C) 2006 Emmanuele Bassi
*
* All rights reserved
*
* 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 this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_RECENT_CHOOSER_PRIVATE_H__
#define __GTK_RECENT_CHOOSER_PRIVATE_H__
#include "gtkrecentmanager.h"
#include "gtkrecentchooser.h"
G_BEGIN_DECLS
GtkRecentManager *_gtk_recent_chooser_get_recent_manager (GtkRecentChooser *chooser);
GList * _gtk_recent_chooser_get_items (GtkRecentChooser *chooser,
GtkRecentFilter *filter,
GtkRecentSortFunc func,
gpointer data);
void _gtk_recent_chooser_item_activated (GtkRecentChooser *chooser);
void _gtk_recent_chooser_selection_changed (GtkRecentChooser *chooser);
G_END_DECLS
#endif /* ! __GTK_RECENT_CHOOSER_PRIVATE_H__ */

View File

@ -1,530 +0,0 @@
/* gtkrecentchooserutils.h - Private utility functions for implementing a
* GtkRecentChooser interface
*
* Copyright (C) 2006 Emmanuele Bassi
*
* All rights reserved
*
* 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 this library. If not, see <http://www.gnu.org/licenses/>.
*
* Based on gtkfilechooserutils.c:
* Copyright (C) 2003 Red Hat, Inc.
*/
#include "config.h"
#include "gtkrecentchooserutils.h"
/* Methods */
static void delegate_set_sort_func (GtkRecentChooser *chooser,
GtkRecentSortFunc sort_func,
gpointer sort_data,
GDestroyNotify data_destroy);
static void delegate_add_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
static void delegate_remove_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
static GSList *delegate_list_filters (GtkRecentChooser *chooser);
static gboolean delegate_select_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error);
static void delegate_unselect_uri (GtkRecentChooser *chooser,
const gchar *uri);
static GList *delegate_get_items (GtkRecentChooser *chooser);
static GtkRecentManager *delegate_get_recent_manager (GtkRecentChooser *chooser);
static void delegate_select_all (GtkRecentChooser *chooser);
static void delegate_unselect_all (GtkRecentChooser *chooser);
static gboolean delegate_set_current_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error);
static gchar * delegate_get_current_uri (GtkRecentChooser *chooser);
/* Signals */
static void delegate_notify (GObject *object,
GParamSpec *pspec,
gpointer user_data);
static void delegate_selection_changed (GtkRecentChooser *receiver,
gpointer user_data);
static void delegate_item_activated (GtkRecentChooser *receiver,
gpointer user_data);
/**
* _gtk_recent_chooser_install_properties:
* @klass: the class structure for a type deriving from #GObject
*
* Installs the necessary properties for a class implementing
* #GtkRecentChooser. A #GtkParamSpecOverride property is installed
* for each property, using the values from the #GtkRecentChooserProp
* enumeration. The caller must make sure itself that the enumeration
* values dont collide with some other property values they
* are using.
*/
void
_gtk_recent_chooser_install_properties (GObjectClass *klass)
{
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER,
"recent-manager");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE,
"show-private");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_SHOW_TIPS,
"show-tips");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_SHOW_ICONS,
"show-icons");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND,
"show-not-found");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE,
"select-multiple");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_LIMIT,
"limit");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY,
"local-only");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_SORT_TYPE,
"sort-type");
g_object_class_override_property (klass,
GTK_RECENT_CHOOSER_PROP_FILTER,
"filter");
}
/**
* _gtk_recent_chooser_delegate_iface_init:
* @iface: a #GtkRecentChooserIface
*
* An interface-initialization function for use in cases where
* an object is simply delegating the methods, signals of
* the #GtkRecentChooser interface to another object.
* _gtk_recent_chooser_set_delegate() must be called on each
* instance of the object so that the delegate object can
* be found.
*/
void
_gtk_recent_chooser_delegate_iface_init (GtkRecentChooserIface *iface)
{
iface->set_current_uri = delegate_set_current_uri;
iface->get_current_uri = delegate_get_current_uri;
iface->select_uri = delegate_select_uri;
iface->unselect_uri = delegate_unselect_uri;
iface->select_all = delegate_select_all;
iface->unselect_all = delegate_unselect_all;
iface->get_items = delegate_get_items;
iface->get_recent_manager = delegate_get_recent_manager;
iface->set_sort_func = delegate_set_sort_func;
iface->add_filter = delegate_add_filter;
iface->remove_filter = delegate_remove_filter;
iface->list_filters = delegate_list_filters;
}
/**
* _gtk_recent_chooser_set_delegate:
* @receiver: a #GObject implementing #GtkRecentChooser
* @delegate: another #GObject implementing #GtkRecentChooser
*
* Establishes that calls on @receiver for #GtkRecentChooser
* methods should be delegated to @delegate, and that
* #GtkRecentChooser signals emitted on @delegate should be
* forwarded to @receiver. Must be used in conjunction with
* _gtk_recent_chooser_delegate_iface_init().
*/
void
_gtk_recent_chooser_set_delegate (GtkRecentChooser *receiver,
GtkRecentChooser *delegate)
{
g_return_if_fail (GTK_IS_RECENT_CHOOSER (receiver));
g_return_if_fail (GTK_IS_RECENT_CHOOSER (delegate));
g_object_set_data (G_OBJECT (receiver),
"gtk-recent-chooser-delegate", delegate);
g_signal_connect (delegate, "notify",
G_CALLBACK (delegate_notify), receiver);
g_signal_connect (delegate, "selection-changed",
G_CALLBACK (delegate_selection_changed), receiver);
g_signal_connect (delegate, "item-activated",
G_CALLBACK (delegate_item_activated), receiver);
}
GQuark
_gtk_recent_chooser_delegate_get_quark (void)
{
static GQuark quark = 0;
if (G_UNLIKELY (quark == 0))
quark = g_quark_from_static_string ("gtk-recent-chooser-delegate");
return quark;
}
static GtkRecentChooser *
get_delegate (GtkRecentChooser *receiver)
{
return g_object_get_qdata (G_OBJECT (receiver),
GTK_RECENT_CHOOSER_DELEGATE_QUARK);
}
static void
delegate_set_sort_func (GtkRecentChooser *chooser,
GtkRecentSortFunc sort_func,
gpointer sort_data,
GDestroyNotify data_destroy)
{
gtk_recent_chooser_set_sort_func (get_delegate (chooser),
sort_func,
sort_data,
data_destroy);
}
static void
delegate_add_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
gtk_recent_chooser_add_filter (get_delegate (chooser), filter);
}
static void
delegate_remove_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter)
{
gtk_recent_chooser_remove_filter (get_delegate (chooser), filter);
}
static GSList *
delegate_list_filters (GtkRecentChooser *chooser)
{
return gtk_recent_chooser_list_filters (get_delegate (chooser));
}
static gboolean
delegate_select_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error)
{
return gtk_recent_chooser_select_uri (get_delegate (chooser), uri, error);
}
static void
delegate_unselect_uri (GtkRecentChooser *chooser,
const gchar *uri)
{
gtk_recent_chooser_unselect_uri (get_delegate (chooser), uri);
}
static GList *
delegate_get_items (GtkRecentChooser *chooser)
{
return gtk_recent_chooser_get_items (get_delegate (chooser));
}
static GtkRecentManager *
delegate_get_recent_manager (GtkRecentChooser *chooser)
{
return _gtk_recent_chooser_get_recent_manager (get_delegate (chooser));
}
static void
delegate_select_all (GtkRecentChooser *chooser)
{
gtk_recent_chooser_select_all (get_delegate (chooser));
}
static void
delegate_unselect_all (GtkRecentChooser *chooser)
{
gtk_recent_chooser_unselect_all (get_delegate (chooser));
}
static gboolean
delegate_set_current_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error)
{
return gtk_recent_chooser_set_current_uri (get_delegate (chooser), uri, error);
}
static gchar *
delegate_get_current_uri (GtkRecentChooser *chooser)
{
return gtk_recent_chooser_get_current_uri (get_delegate (chooser));
}
static void
delegate_notify (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
gpointer iface;
iface = g_type_interface_peek (g_type_class_peek (G_OBJECT_TYPE (object)),
gtk_recent_chooser_get_type ());
if (g_object_interface_find_property (iface, pspec->name))
g_object_notify (user_data, pspec->name);
}
static void
delegate_selection_changed (GtkRecentChooser *receiver,
gpointer user_data)
{
_gtk_recent_chooser_selection_changed (GTK_RECENT_CHOOSER (user_data));
}
static void
delegate_item_activated (GtkRecentChooser *receiver,
gpointer user_data)
{
_gtk_recent_chooser_item_activated (GTK_RECENT_CHOOSER (user_data));
}
static gint
sort_recent_items_mru (GtkRecentInfo *a,
GtkRecentInfo *b,
gpointer unused)
{
g_assert (a != NULL && b != NULL);
return gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a);
}
static gint
sort_recent_items_lru (GtkRecentInfo *a,
GtkRecentInfo *b,
gpointer unused)
{
g_assert (a != NULL && b != NULL);
return -1 * (gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a));
}
typedef struct
{
GtkRecentSortFunc func;
gpointer data;
} SortRecentData;
/* our proxy sorting function */
static gint
sort_recent_items_proxy (gpointer *a,
gpointer *b,
gpointer user_data)
{
GtkRecentInfo *info_a = (GtkRecentInfo *) a;
GtkRecentInfo *info_b = (GtkRecentInfo *) b;
SortRecentData *sort_recent = user_data;
if (sort_recent->func)
return (* sort_recent->func) (info_a, info_b, sort_recent->data);
/* fallback */
return 0;
}
static gboolean
get_is_recent_filtered (GtkRecentFilter *filter,
GtkRecentInfo *info)
{
GtkRecentFilterInfo filter_info;
GtkRecentFilterFlags needed;
gboolean retval;
g_assert (info != NULL);
needed = gtk_recent_filter_get_needed (filter);
filter_info.contains = GTK_RECENT_FILTER_URI | GTK_RECENT_FILTER_MIME_TYPE;
filter_info.uri = gtk_recent_info_get_uri (info);
filter_info.mime_type = gtk_recent_info_get_mime_type (info);
if (needed & GTK_RECENT_FILTER_DISPLAY_NAME)
{
filter_info.display_name = gtk_recent_info_get_display_name (info);
filter_info.contains |= GTK_RECENT_FILTER_DISPLAY_NAME;
}
else
filter_info.uri = NULL;
if (needed & GTK_RECENT_FILTER_APPLICATION)
{
filter_info.applications = (const gchar **) gtk_recent_info_get_applications (info, NULL);
filter_info.contains |= GTK_RECENT_FILTER_APPLICATION;
}
else
filter_info.applications = NULL;
if (needed & GTK_RECENT_FILTER_GROUP)
{
filter_info.groups = (const gchar **) gtk_recent_info_get_groups (info, NULL);
filter_info.contains |= GTK_RECENT_FILTER_GROUP;
}
else
filter_info.groups = NULL;
if (needed & GTK_RECENT_FILTER_AGE)
{
filter_info.age = gtk_recent_info_get_age (info);
filter_info.contains |= GTK_RECENT_FILTER_AGE;
}
else
filter_info.age = -1;
retval = gtk_recent_filter_filter (filter, &filter_info);
/* these we own */
if (filter_info.applications)
g_strfreev ((gchar **) filter_info.applications);
if (filter_info.groups)
g_strfreev ((gchar **) filter_info.groups);
return !retval;
}
/*
* _gtk_recent_chooser_get_items:
* @chooser: a #GtkRecentChooser
* @filter: a #GtkRecentFilter
* @sort_func: (allow-none): sorting function, or %NULL
* @sort_data: (allow-none): sorting function data, or %NULL
*
* Default implementation for getting the filtered, sorted and
* clamped list of recently used resources from a #GtkRecentChooser.
* This function should be used by implementations of the
* #GtkRecentChooser interface inside the GtkRecentChooser::get_items
* vfunc.
*
* Returns: a list of #GtkRecentInfo objects
*/
GList *
_gtk_recent_chooser_get_items (GtkRecentChooser *chooser,
GtkRecentFilter *filter,
GtkRecentSortFunc sort_func,
gpointer sort_data)
{
GtkRecentManager *manager;
gint limit;
GtkRecentSortType sort_type;
GList *items;
GCompareDataFunc compare_func;
gint length;
g_return_val_if_fail (GTK_IS_RECENT_CHOOSER (chooser), NULL);
manager = _gtk_recent_chooser_get_recent_manager (chooser);
if (!manager)
return NULL;
items = gtk_recent_manager_get_items (manager);
if (!items)
return NULL;
limit = gtk_recent_chooser_get_limit (chooser);
if (limit == 0)
return NULL;
if (filter)
{
GList *filter_items, *l;
gboolean local_only = FALSE;
gboolean show_private = FALSE;
gboolean show_not_found = FALSE;
g_object_get (G_OBJECT (chooser),
"local-only", &local_only,
"show-private", &show_private,
"show-not-found", &show_not_found,
NULL);
filter_items = NULL;
for (l = items; l != NULL; l = l->next)
{
GtkRecentInfo *info = l->data;
gboolean remove_item = FALSE;
if (get_is_recent_filtered (filter, info))
remove_item = TRUE;
if (local_only && !gtk_recent_info_is_local (info))
remove_item = TRUE;
if (!show_private && gtk_recent_info_get_private_hint (info))
remove_item = TRUE;
if (!show_not_found && !gtk_recent_info_exists (info))
remove_item = TRUE;
if (!remove_item)
filter_items = g_list_prepend (filter_items, info);
else
gtk_recent_info_unref (info);
}
g_list_free (items);
items = filter_items;
}
if (!items)
return NULL;
sort_type = gtk_recent_chooser_get_sort_type (chooser);
switch (sort_type)
{
case GTK_RECENT_SORT_NONE:
compare_func = NULL;
break;
case GTK_RECENT_SORT_MRU:
compare_func = (GCompareDataFunc) sort_recent_items_mru;
break;
case GTK_RECENT_SORT_LRU:
compare_func = (GCompareDataFunc) sort_recent_items_lru;
break;
case GTK_RECENT_SORT_CUSTOM:
compare_func = (GCompareDataFunc) sort_recent_items_proxy;
break;
default:
g_assert_not_reached ();
break;
}
if (compare_func)
{
SortRecentData sort_recent;
sort_recent.func = sort_func;
sort_recent.data = sort_data;
items = g_list_sort_with_data (items, compare_func, &sort_recent);
}
length = g_list_length (items);
if ((limit != -1) && (length > limit))
{
GList *clamp, *l;
clamp = g_list_nth (items, limit - 1);
if (!clamp)
return items;
l = clamp->next;
clamp->next = NULL;
g_list_free_full (l, (GDestroyNotify) gtk_recent_info_unref);
}
return items;
}

View File

@ -1,60 +0,0 @@
/* gtkrecentchooserutils.h - Private utility functions for implementing a
* GtkRecentChooser interface
*
* Copyright (C) 2006 Emmanuele Bassi
*
* All rights reserved
*
* 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 this library. If not, see <http://www.gnu.org/licenses/>.
*
* Based on gtkfilechooserutils.h:
* Copyright (C) 2003 Red Hat, Inc.
*/
#ifndef __GTK_RECENT_CHOOSER_UTILS_H__
#define __GTK_RECENT_CHOOSER_UTILS_H__
#include "gtkrecentchooserprivate.h"
G_BEGIN_DECLS
#define GTK_RECENT_CHOOSER_DELEGATE_QUARK (_gtk_recent_chooser_delegate_get_quark ())
typedef enum {
GTK_RECENT_CHOOSER_PROP_FIRST = 0x3000,
GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER,
GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE,
GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND,
GTK_RECENT_CHOOSER_PROP_SHOW_TIPS,
GTK_RECENT_CHOOSER_PROP_SHOW_ICONS,
GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE,
GTK_RECENT_CHOOSER_PROP_LIMIT,
GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY,
GTK_RECENT_CHOOSER_PROP_SORT_TYPE,
GTK_RECENT_CHOOSER_PROP_FILTER,
GTK_RECENT_CHOOSER_PROP_LAST
} GtkRecentChooserProp;
void _gtk_recent_chooser_install_properties (GObjectClass *klass);
void _gtk_recent_chooser_delegate_iface_init (GtkRecentChooserIface *iface);
void _gtk_recent_chooser_set_delegate (GtkRecentChooser *receiver,
GtkRecentChooser *delegate);
GQuark _gtk_recent_chooser_delegate_get_quark (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GTK_RECENT_CHOOSER_UTILS_H__ */

View File

@ -1,237 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentchooserwidget.c: embeddable recently used resources chooser widget
* Copyright (C) 2006 Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gtkrecentchooserwidget.h"
#include "gtkrecentchooserdefault.h"
#include "gtkrecentchooserutils.h"
#include "gtkorientable.h"
#include "gtktypebuiltins.h"
/**
* SECTION:gtkrecentchooserwidget
* @Short_description: Displays recently used files
* @Title: GtkRecentChooserWidget
* @See_also:#GtkRecentChooser, #GtkRecentChooserDialog
*
* #GtkRecentChooserWidget is a widget suitable for selecting recently used
* files. It is the main building block of a #GtkRecentChooserDialog. Most
* applications will only need to use the latter; you can use
* #GtkRecentChooserWidget as part of a larger window if you have special needs.
*
* Note that #GtkRecentChooserWidget does not have any methods of its own.
* Instead, you should use the functions that work on a #GtkRecentChooser.
*
* Recently used files are supported since GTK+ 2.10.
*/
struct _GtkRecentChooserWidgetPrivate
{
GtkRecentManager *manager;
GtkWidget *chooser;
};
static void gtk_recent_chooser_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_recent_chooser_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_recent_chooser_widget_finalize (GObject *object);
G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserWidget,
gtk_recent_chooser_widget,
GTK_TYPE_WIDGET,
G_ADD_PRIVATE (GtkRecentChooserWidget)
G_IMPLEMENT_INTERFACE (GTK_TYPE_RECENT_CHOOSER,
_gtk_recent_chooser_delegate_iface_init))
static void
gtk_recent_chooser_widget_constructed (GObject *gobject)
{
GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (gobject);
self->priv->chooser = _gtk_recent_chooser_default_new (self->priv->manager);
gtk_widget_set_parent (self->priv->chooser, GTK_WIDGET (self));
_gtk_recent_chooser_set_delegate (GTK_RECENT_CHOOSER (self),
GTK_RECENT_CHOOSER (self->priv->chooser));
}
static void
gtk_recent_chooser_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkRecentChooserWidgetPrivate *priv;
priv = gtk_recent_chooser_widget_get_instance_private (GTK_RECENT_CHOOSER_WIDGET (object));
switch (prop_id)
{
case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER:
priv->manager = g_value_get_object (value);
break;
default:
g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value);
break;
}
}
static void
gtk_recent_chooser_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkRecentChooserWidgetPrivate *priv;
priv = gtk_recent_chooser_widget_get_instance_private (GTK_RECENT_CHOOSER_WIDGET (object));
g_object_get_property (G_OBJECT (priv->chooser), pspec->name, value);
}
static void
gtk_recent_chooser_widget_finalize (GObject *object)
{
GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (object);
self->priv->manager = NULL;
gtk_widget_unparent (self->priv->chooser);
G_OBJECT_CLASS (gtk_recent_chooser_widget_parent_class)->finalize (object);
}
static void
gtk_recent_chooser_widget_measure (GtkWidget *widget,
GtkOrientation orientation,
int for_size,
int *minimum,
int *natural,
int *minimum_baseline,
int *natural_baseline)
{
GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (widget);
GtkRecentChooserWidgetPrivate *priv = gtk_recent_chooser_widget_get_instance_private (self);
gtk_widget_measure (priv->chooser, orientation, for_size,
minimum, natural,
minimum_baseline, natural_baseline);
}
static void
gtk_recent_chooser_widget_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (widget);
GtkRecentChooserWidgetPrivate *priv = gtk_recent_chooser_widget_get_instance_private (self);
gtk_widget_snapshot_child (widget, priv->chooser, snapshot);
}
static void
gtk_recent_chooser_widget_size_allocate (GtkWidget *widget,
const GtkAllocation *allocation,
int baseline,
GtkAllocation *out_clip)
{
GtkRecentChooserWidget *self = GTK_RECENT_CHOOSER_WIDGET (widget);
GtkRecentChooserWidgetPrivate *priv = gtk_recent_chooser_widget_get_instance_private (self);
GTK_WIDGET_CLASS (gtk_recent_chooser_widget_parent_class)->size_allocate (widget, allocation, -1, out_clip);
gtk_widget_size_allocate (priv->chooser, allocation, -1, out_clip);
}
static void
gtk_recent_chooser_widget_class_init (GtkRecentChooserWidgetClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gobject_class->constructed = gtk_recent_chooser_widget_constructed;
gobject_class->set_property = gtk_recent_chooser_widget_set_property;
gobject_class->get_property = gtk_recent_chooser_widget_get_property;
gobject_class->finalize = gtk_recent_chooser_widget_finalize;
widget_class->measure = gtk_recent_chooser_widget_measure;
widget_class->size_allocate = gtk_recent_chooser_widget_size_allocate;
widget_class->snapshot = gtk_recent_chooser_widget_snapshot;
_gtk_recent_chooser_install_properties (gobject_class);
}
static void
gtk_recent_chooser_widget_init (GtkRecentChooserWidget *widget)
{
widget->priv = gtk_recent_chooser_widget_get_instance_private (widget);
gtk_widget_set_has_window (GTK_WIDGET (widget), FALSE);
}
/*
* Public API
*/
/**
* gtk_recent_chooser_widget_new:
*
* Creates a new #GtkRecentChooserWidget object. This is an embeddable widget
* used to access the recently used resources list.
*
* Returns: a new #GtkRecentChooserWidget
*
* Since: 2.10
*/
GtkWidget *
gtk_recent_chooser_widget_new (void)
{
return g_object_new (GTK_TYPE_RECENT_CHOOSER_WIDGET, NULL);
}
/**
* gtk_recent_chooser_widget_new_for_manager:
* @manager: a #GtkRecentManager
*
* Creates a new #GtkRecentChooserWidget with a specified recent manager.
*
* This is useful if you have implemented your own recent manager, or if you
* have a customized instance of a #GtkRecentManager object.
*
* Returns: a new #GtkRecentChooserWidget
*
* Since: 2.10
*/
GtkWidget *
gtk_recent_chooser_widget_new_for_manager (GtkRecentManager *manager)
{
g_return_val_if_fail (manager == NULL || GTK_IS_RECENT_MANAGER (manager), NULL);
return g_object_new (GTK_TYPE_RECENT_CHOOSER_WIDGET,
"recent-manager", manager,
NULL);
}

View File

@ -1,71 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentchooserwidget.h: embeddable recently used resources chooser widget
* Copyright (C) 2006 Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_RECENT_CHOOSER_WIDGET_H__
#define __GTK_RECENT_CHOOSER_WIDGET_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkrecentchooser.h>
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GTK_TYPE_RECENT_CHOOSER_WIDGET (gtk_recent_chooser_widget_get_type ())
#define GTK_RECENT_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_CHOOSER_WIDGET, GtkRecentChooserWidget))
#define GTK_IS_RECENT_CHOOSER_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_CHOOSER_WIDGET))
#define GTK_RECENT_CHOOSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_RECENT_CHOOSER_WIDGET, GtkRecentChooserWidgetClass))
#define GTK_IS_RECENT_CHOOSER_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_RECENT_CHOOSER_WIDGET))
#define GTK_RECENT_CHOOSER_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RECENT_CHOOSER_WIDGET, GtkRecentChooserWidgetClass))
typedef struct _GtkRecentChooserWidget GtkRecentChooserWidget;
typedef struct _GtkRecentChooserWidgetClass GtkRecentChooserWidgetClass;
typedef struct _GtkRecentChooserWidgetPrivate GtkRecentChooserWidgetPrivate;
struct _GtkRecentChooserWidget
{
GtkWidget parent_instance;
/*< private >*/
GtkRecentChooserWidgetPrivate *priv;
};
struct _GtkRecentChooserWidgetClass
{
GtkWidgetClass parent_class;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GDK_AVAILABLE_IN_ALL
GType gtk_recent_chooser_widget_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_recent_chooser_widget_new (void);
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_recent_chooser_widget_new_for_manager (GtkRecentManager *manager);
G_END_DECLS
#endif /* __GTK_RECENT_CHOOSER_WIDGET_H__ */

View File

@ -1,837 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentfilter.h - Filter object for recently used resources
* Copyright (C) 2006, Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* SECTION:gtkrecentfilter
* @Short_Description: A filter for selecting a subset of recently used files
* @Title: GtkRecentFilter
*
* A #GtkRecentFilter can be used to restrict the files being shown
* in a #GtkRecentChooser. Files can be filtered based on their name
* (with gtk_recent_filter_add_pattern()), on their mime type (with
* gtk_file_filter_add_mime_type()), on the application that has
* registered them (with gtk_recent_filter_add_application()), or by
* a custom filter function (with gtk_recent_filter_add_custom()).
*
* Filtering by mime type handles aliasing and subclassing of mime
* types; e.g. a filter for text/plain also matches a file with mime
* type application/rtf, since application/rtf is a subclass of text/plain.
* Note that #GtkRecentFilter allows wildcards for the subtype of a
* mime type, so you can e.g. filter for image/\*.
*
* Normally, filters are used by adding them to a #GtkRecentChooser,
* see gtk_recent_chooser_add_filter(), but it is also possible to
* manually use a filter on a file with gtk_recent_filter_filter().
*
* Recently used files are supported since GTK+ 2.10.
*
* ## GtkRecentFilter as GtkBuildable
*
* The GtkRecentFilter implementation of the GtkBuildable interface
* supports adding rules using the <mime-types>, <patterns> and
* <applications> elements and listing the rules within. Specifying
* a <mime-type>, <pattern> or <application> has the same effect as
* calling gtk_recent_filter_add_mime_type(),
* gtk_recent_filter_add_pattern() or gtk_recent_filter_add_application().
*
* An example of a UI definition fragment specifying GtkRecentFilter rules:
* |[
* <object class="GtkRecentFilter">
* <mime-types>
* <mime-type>text/plain</mime-type>
* <mime-type>image/png</mime-type>
* </mime-types>
* <patterns>
* <pattern>*.txt</pattern>
* <pattern>*.png</pattern>
* </patterns>
* <applications>
* <application>gimp</application>
* <application>gedit</application>
* <application>glade</application>
* </applications>
* </object>
* ]|
*/
#include "config.h"
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gtkrecentfilter.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkintl.h"
#include "gtkprivate.h"
static void gtk_recent_filter_buildable_init (GtkBuildableIface *iface);
static gboolean gtk_recent_filter_buildable_custom_tag_start (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
GMarkupParser *parser,
gpointer *data);
static void gtk_recent_filter_buildable_custom_tag_end (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
gpointer *data);
typedef struct _GtkRecentFilterClass GtkRecentFilterClass;
typedef struct _FilterRule FilterRule;
typedef enum {
FILTER_RULE_URI,
FILTER_RULE_DISPLAY_NAME,
FILTER_RULE_MIME_TYPE,
FILTER_RULE_PIXBUF_FORMATS,
FILTER_RULE_APPLICATION,
FILTER_RULE_AGE,
FILTER_RULE_GROUP,
FILTER_RULE_CUSTOM
} FilterRuleType;
struct _GtkRecentFilter
{
GInitiallyUnowned parent_instance;
gchar *name;
GSList *rules;
GtkRecentFilterFlags needed;
};
struct _GtkRecentFilterClass
{
GInitiallyUnownedClass parent_class;
};
struct _FilterRule
{
FilterRuleType type;
GtkRecentFilterFlags needed;
union {
gchar *uri;
gchar *pattern;
gchar *mime_type;
GSList *pixbuf_formats;
gchar *application;
gchar *group;
gint age;
struct {
GtkRecentFilterFunc func;
gpointer data;
GDestroyNotify data_destroy;
} custom;
} u;
};
G_DEFINE_TYPE_WITH_CODE (GtkRecentFilter, gtk_recent_filter, G_TYPE_INITIALLY_UNOWNED,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
gtk_recent_filter_buildable_init))
static void
filter_rule_free (FilterRule *rule)
{
switch (rule->type)
{
case FILTER_RULE_MIME_TYPE:
g_free (rule->u.mime_type);
break;
case FILTER_RULE_URI:
g_free (rule->u.uri);
break;
case FILTER_RULE_DISPLAY_NAME:
g_free (rule->u.pattern);
break;
case FILTER_RULE_PIXBUF_FORMATS:
g_slist_free (rule->u.pixbuf_formats);
break;
case FILTER_RULE_AGE:
break;
case FILTER_RULE_APPLICATION:
g_free (rule->u.application);
break;
case FILTER_RULE_GROUP:
g_free (rule->u.group);
break;
case FILTER_RULE_CUSTOM:
if (rule->u.custom.data_destroy)
rule->u.custom.data_destroy (rule->u.custom.data);
break;
default:
g_assert_not_reached ();
break;
}
g_free (rule);
}
static void
gtk_recent_filter_finalize (GObject *object)
{
GtkRecentFilter *filter = GTK_RECENT_FILTER (object);
g_free (filter->name);
g_slist_free_full (filter->rules, (GDestroyNotify) filter_rule_free);
G_OBJECT_CLASS (gtk_recent_filter_parent_class)->finalize (object);
}
static void
gtk_recent_filter_class_init (GtkRecentFilterClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = gtk_recent_filter_finalize;
}
static void
gtk_recent_filter_init (GtkRecentFilter *filter)
{
}
/*
* GtkBuildable implementation
*/
static void
gtk_recent_filter_buildable_init (GtkBuildableIface *iface)
{
iface->custom_tag_start = gtk_recent_filter_buildable_custom_tag_start;
iface->custom_tag_end = gtk_recent_filter_buildable_custom_tag_end;
}
typedef enum {
PARSE_MIME_TYPES,
PARSE_PATTERNS,
PARSE_APPLICATIONS
} ParserType;
typedef struct {
GtkRecentFilter *filter;
GtkBuilder *builder;
ParserType type;
GString *string;
gboolean parsing;
} SubParserData;
static void
parser_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **names,
const gchar **values,
gpointer user_data,
GError **error)
{
SubParserData *data = (SubParserData*)user_data;
if (!g_markup_collect_attributes (element_name, names, values, error,
G_MARKUP_COLLECT_INVALID, NULL, NULL,
G_MARKUP_COLLECT_INVALID))
{
_gtk_builder_prefix_error (data->builder, context, error);
return;
}
if (strcmp (element_name, "mime-types") == 0 ||
strcmp (element_name, "patterns") == 0 ||
strcmp (element_name, "applications") == 0)
{
if (!_gtk_builder_check_parent (data->builder, context, "object", error))
return;
}
else if (strcmp (element_name, "mime-type") == 0)
{
if (!_gtk_builder_check_parent (data->builder, context, "mime-types", error))
return;
data->parsing = TRUE;
}
else if (strcmp (element_name, "pattern") == 0)
{
if (!_gtk_builder_check_parent (data->builder, context, "patterns", error))
return;
data->parsing = TRUE;
}
else if (strcmp (element_name, "application") == 0)
{
if (!_gtk_builder_check_parent (data->builder, context, "applications", error))
return;
data->parsing = TRUE;
}
else
{
_gtk_builder_error_unhandled_tag (data->builder, context,
"GtkRecentFilter", element_name,
error);
}
}
static void
parser_text_element (GMarkupParseContext *context,
const gchar *text,
gsize text_len,
gpointer user_data,
GError **error)
{
SubParserData *data = (SubParserData*)user_data;
if (data->parsing)
g_string_append_len (data->string, text, text_len);
}
static void
parser_end_element (GMarkupParseContext *context,
const gchar *element_name,
gpointer user_data,
GError **error)
{
SubParserData *data = (SubParserData*)user_data;
if (data->string)
{
switch (data->type)
{
case PARSE_MIME_TYPES:
gtk_recent_filter_add_mime_type (data->filter, data->string->str);
break;
case PARSE_PATTERNS:
gtk_recent_filter_add_pattern (data->filter, data->string->str);
break;
case PARSE_APPLICATIONS:
gtk_recent_filter_add_application (data->filter, data->string->str);
break;
default:
break;
}
}
g_string_set_size (data->string, 0);
data->parsing = FALSE;
}
static const GMarkupParser sub_parser =
{
parser_start_element,
parser_end_element,
parser_text_element,
};
static gboolean
gtk_recent_filter_buildable_custom_tag_start (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
GMarkupParser *parser,
gpointer *parser_data)
{
SubParserData *data = NULL;
if (strcmp (tagname, "mime-types") == 0)
{
data = g_slice_new0 (SubParserData);
data->string = g_string_new ("");
data->type = PARSE_MIME_TYPES;
data->filter = GTK_RECENT_FILTER (buildable);
data->builder = builder;
*parser = sub_parser;
*parser_data = data;
}
else if (strcmp (tagname, "patterns") == 0)
{
data = g_slice_new0 (SubParserData);
data->string = g_string_new ("");
data->type = PARSE_PATTERNS;
data->filter = GTK_RECENT_FILTER (buildable);
data->builder = builder;
*parser = sub_parser;
*parser_data = data;
}
else if (strcmp (tagname, "applications") == 0)
{
data = g_slice_new0 (SubParserData);
data->string = g_string_new ("");
data->type = PARSE_APPLICATIONS;
data->filter = GTK_RECENT_FILTER (buildable);
data->builder = builder;
*parser = sub_parser;
*parser_data = data;
}
return data != NULL;
}
static void
gtk_recent_filter_buildable_custom_tag_end (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *child,
const gchar *tagname,
gpointer *parser_data)
{
if (strcmp (tagname, "mime-types") == 0 ||
strcmp (tagname, "patterns") == 0 ||
strcmp (tagname, "applications") == 0)
{
SubParserData *data = (SubParserData*)parser_data;
g_string_free (data->string, TRUE);
g_slice_free (SubParserData, data);
}
}
/*
* Public API
*/
/**
* gtk_recent_filter_new:
*
* Creates a new #GtkRecentFilter with no rules added to it.
* Such filter does not accept any recently used resources, so is not
* particularly useful until you add rules with
* gtk_recent_filter_add_pattern(), gtk_recent_filter_add_mime_type(),
* gtk_recent_filter_add_application(), gtk_recent_filter_add_age().
* To create a filter that accepts any recently used resource, use:
* |[<!-- language="C" -->
* GtkRecentFilter *filter = gtk_recent_filter_new ();
* gtk_recent_filter_add_pattern (filter, "*");
* ]|
*
* Returns: a new #GtkRecentFilter
*
* Since: 2.10
*/
GtkRecentFilter *
gtk_recent_filter_new (void)
{
return g_object_new (GTK_TYPE_RECENT_FILTER, NULL);
}
/**
* gtk_recent_filter_set_name:
* @filter: a #GtkRecentFilter
* @name: then human readable name of @filter
*
* Sets the human-readable name of the filter; this is the string
* that will be displayed in the recently used resources selector
* user interface if there is a selectable list of filters.
*
* Since: 2.10
*/
void
gtk_recent_filter_set_name (GtkRecentFilter *filter,
const gchar *name)
{
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
g_free (filter->name);
if (name)
filter->name = g_strdup (name);
}
/**
* gtk_recent_filter_get_name:
* @filter: a #GtkRecentFilter
*
* Gets the human-readable name for the filter.
* See gtk_recent_filter_set_name().
*
* Returns: (nullable): the name of the filter, or %NULL. The returned string
* is owned by the filter object and should not be freed.
*
* Since: 2.10
*/
const gchar *
gtk_recent_filter_get_name (GtkRecentFilter *filter)
{
g_return_val_if_fail (GTK_IS_RECENT_FILTER (filter), NULL);
return filter->name;
}
/**
* gtk_recent_filter_get_needed:
* @filter: a #GtkRecentFilter
*
* Gets the fields that need to be filled in for the #GtkRecentFilterInfo
* passed to gtk_recent_filter_filter()
*
* This function will not typically be used by applications; it
* is intended principally for use in the implementation of
* #GtkRecentChooser.
*
* Returns: bitfield of flags indicating needed fields when
* calling gtk_recent_filter_filter()
*
* Since: 2.10
*/
GtkRecentFilterFlags
gtk_recent_filter_get_needed (GtkRecentFilter *filter)
{
return filter->needed;
}
static void
recent_filter_add_rule (GtkRecentFilter *filter,
FilterRule *rule)
{
filter->needed |= rule->needed;
filter->rules = g_slist_append (filter->rules, rule);
}
/**
* gtk_recent_filter_add_mime_type:
* @filter: a #GtkRecentFilter
* @mime_type: a MIME type
*
* Adds a rule that allows resources based on their registered MIME type.
*
* Since: 2.10
*/
void
gtk_recent_filter_add_mime_type (GtkRecentFilter *filter,
const gchar *mime_type)
{
FilterRule *rule;
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
g_return_if_fail (mime_type != NULL);
rule = g_new0 (FilterRule, 1);
rule->type = FILTER_RULE_MIME_TYPE;
rule->needed = GTK_RECENT_FILTER_MIME_TYPE;
rule->u.mime_type = g_strdup (mime_type);
recent_filter_add_rule (filter, rule);
}
/**
* gtk_recent_filter_add_pattern:
* @filter: a #GtkRecentFilter
* @pattern: a file pattern
*
* Adds a rule that allows resources based on a pattern matching their
* display name.
*
* Since: 2.10
*/
void
gtk_recent_filter_add_pattern (GtkRecentFilter *filter,
const gchar *pattern)
{
FilterRule *rule;
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
g_return_if_fail (pattern != NULL);
rule = g_new0 (FilterRule, 1);
rule->type = FILTER_RULE_DISPLAY_NAME;
rule->needed = GTK_RECENT_FILTER_DISPLAY_NAME;
rule->u.pattern = g_strdup (pattern);
recent_filter_add_rule (filter, rule);
}
/**
* gtk_recent_filter_add_pixbuf_formats:
* @filter: a #GtkRecentFilter
*
* Adds a rule allowing image files in the formats supported
* by GdkPixbuf.
*
* Since: 2.10
*/
void
gtk_recent_filter_add_pixbuf_formats (GtkRecentFilter *filter)
{
FilterRule *rule;
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
rule = g_new0 (FilterRule, 1);
rule->type = FILTER_RULE_PIXBUF_FORMATS;
rule->needed = GTK_RECENT_FILTER_MIME_TYPE;
rule->u.pixbuf_formats = gdk_pixbuf_get_formats ();
recent_filter_add_rule (filter, rule);
}
/**
* gtk_recent_filter_add_application:
* @filter: a #GtkRecentFilter
* @application: an application name
*
* Adds a rule that allows resources based on the name of the application
* that has registered them.
*
* Since: 2.10
*/
void
gtk_recent_filter_add_application (GtkRecentFilter *filter,
const gchar *application)
{
FilterRule *rule;
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
g_return_if_fail (application != NULL);
rule = g_new0 (FilterRule, 1);
rule->type = FILTER_RULE_APPLICATION;
rule->needed = GTK_RECENT_FILTER_APPLICATION;
rule->u.application = g_strdup (application);
recent_filter_add_rule (filter, rule);
}
/**
* gtk_recent_filter_add_group:
* @filter: a #GtkRecentFilter
* @group: a group name
*
* Adds a rule that allows resources based on the name of the group
* to which they belong
*
* Since: 2.10
*/
void
gtk_recent_filter_add_group (GtkRecentFilter *filter,
const gchar *group)
{
FilterRule *rule;
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
g_return_if_fail (group != NULL);
rule = g_new0 (FilterRule, 1);
rule->type = FILTER_RULE_GROUP;
rule->needed = GTK_RECENT_FILTER_GROUP;
rule->u.group = g_strdup (group);
recent_filter_add_rule (filter, rule);
}
/**
* gtk_recent_filter_add_age:
* @filter: a #GtkRecentFilter
* @days: number of days
*
* Adds a rule that allows resources based on their age - that is, the number
* of days elapsed since they were last modified.
*
* Since: 2.10
*/
void
gtk_recent_filter_add_age (GtkRecentFilter *filter,
gint days)
{
FilterRule *rule;
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
rule = g_new0 (FilterRule, 1);
rule->type = FILTER_RULE_AGE;
rule->needed = GTK_RECENT_FILTER_AGE;
rule->u.age = days;
recent_filter_add_rule (filter, rule);
}
/**
* gtk_recent_filter_add_custom:
* @filter: a #GtkRecentFilter
* @needed: bitfield of flags indicating the information that the custom
* filter function needs.
* @func: callback function; if the function returns %TRUE, then
* the file will be displayed.
* @data: data to pass to @func
* @data_destroy: function to call to free @data when it is no longer needed.
*
* Adds a rule to a filter that allows resources based on a custom callback
* function. The bitfield @needed which is passed in provides information
* about what sorts of information that the filter function needs;
* this allows GTK+ to avoid retrieving expensive information when
* it isnt needed by the filter.
*
* Since: 2.10
**/
void
gtk_recent_filter_add_custom (GtkRecentFilter *filter,
GtkRecentFilterFlags needed,
GtkRecentFilterFunc func,
gpointer data,
GDestroyNotify data_destroy)
{
FilterRule *rule;
g_return_if_fail (GTK_IS_RECENT_FILTER (filter));
g_return_if_fail (func != NULL);
rule = g_new0 (FilterRule, 1);
rule->type = FILTER_RULE_CUSTOM;
rule->needed = needed;
rule->u.custom.func = func;
rule->u.custom.data = data;
rule->u.custom.data_destroy = data_destroy;
recent_filter_add_rule (filter, rule);
}
/**
* gtk_recent_filter_filter:
* @filter: a #GtkRecentFilter
* @filter_info: a #GtkRecentFilterInfo containing information
* about a recently used resource
*
* Tests whether a file should be displayed according to @filter.
* The #GtkRecentFilterInfo @filter_info should include
* the fields returned from gtk_recent_filter_get_needed(), and
* must set the #GtkRecentFilterInfo.contains field of @filter_info
* to indicate which fields have been set.
*
* This function will not typically be used by applications; it
* is intended principally for use in the implementation of
* #GtkRecentChooser.
*
* Returns: %TRUE if the file should be displayed
*
* Since: 2.10
*/
gboolean
gtk_recent_filter_filter (GtkRecentFilter *filter,
const GtkRecentFilterInfo *filter_info)
{
GSList *l;
g_return_val_if_fail (GTK_IS_RECENT_FILTER (filter), FALSE);
g_return_val_if_fail (filter_info != NULL, FALSE);
for (l = filter->rules; l != NULL; l = l->next)
{
FilterRule *rule = (FilterRule *) l->data;
if ((filter_info->contains & rule->needed) != rule->needed)
continue;
switch (rule->type)
{
case FILTER_RULE_MIME_TYPE:
if (filter_info->mime_type != NULL)
{
gchar *filter_content_type, *rule_content_type;
gboolean match;
filter_content_type = g_content_type_from_mime_type (filter_info->mime_type);
rule_content_type = g_content_type_from_mime_type (rule->u.mime_type);
match = g_content_type_is_a (filter_content_type, rule_content_type);
g_free (filter_content_type);
g_free (rule_content_type);
if (match)
return TRUE;
}
break;
case FILTER_RULE_APPLICATION:
if (filter_info->applications)
{
gint i;
for (i = 0; filter_info->applications[i] != NULL; i++)
{
if (strcmp (filter_info->applications[i], rule->u.application) == 0)
return TRUE;
}
}
break;
case FILTER_RULE_GROUP:
if (filter_info->groups)
{
gint i;
for (i = 0; filter_info->groups[i] != NULL; i++)
{
if (strcmp (filter_info->groups[i], rule->u.group) == 0)
return TRUE;
}
}
break;
case FILTER_RULE_PIXBUF_FORMATS:
{
GSList *list;
if (!filter_info->mime_type)
break;
for (list = rule->u.pixbuf_formats; list; list = list->next)
{
gint i;
gchar **mime_types;
mime_types = gdk_pixbuf_format_get_mime_types (list->data);
for (i = 0; mime_types[i] != NULL; i++)
{
if (strcmp (mime_types[i], filter_info->mime_type) == 0)
{
g_strfreev (mime_types);
return TRUE;
}
}
g_strfreev (mime_types);
}
break;
}
case FILTER_RULE_URI:
if ((filter_info->uri != NULL) &&
_gtk_fnmatch (rule->u.uri, filter_info->uri, FALSE))
return TRUE;
break;
case FILTER_RULE_DISPLAY_NAME:
if ((filter_info->display_name != NULL) &&
_gtk_fnmatch (rule->u.pattern, filter_info->display_name, FALSE))
return TRUE;
break;
case FILTER_RULE_AGE:
if ((filter_info->age != -1) &&
(filter_info->age < rule->u.age))
return TRUE;
break;
case FILTER_RULE_CUSTOM:
if (rule->u.custom.func (filter_info, rule->u.custom.data))
return TRUE;
break;
default:
g_assert_not_reached ();
break;
}
}
return FALSE;
}

View File

@ -1,150 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkrecentfilter.h - Filter object for recently used resources
* Copyright (C) 2006, Emmanuele Bassi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_RECENT_FILTER_H__
#define __GTK_RECENT_FILTER_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <glib-object.h>
#include <gdk/gdk.h>
G_BEGIN_DECLS
#define GTK_TYPE_RECENT_FILTER (gtk_recent_filter_get_type ())
#define GTK_RECENT_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_RECENT_FILTER, GtkRecentFilter))
#define GTK_IS_RECENT_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_RECENT_FILTER))
typedef struct _GtkRecentFilter GtkRecentFilter;
typedef struct _GtkRecentFilterInfo GtkRecentFilterInfo;
/**
* GtkRecentFilterFlags:
* @GTK_RECENT_FILTER_URI: the URI of the file being tested
* @GTK_RECENT_FILTER_DISPLAY_NAME: the string that will be used to
* display the file in the recent chooser
* @GTK_RECENT_FILTER_MIME_TYPE: the mime type of the file
* @GTK_RECENT_FILTER_APPLICATION: the list of applications that have
* registered the file
* @GTK_RECENT_FILTER_GROUP: the groups to which the file belongs to
* @GTK_RECENT_FILTER_AGE: the number of days elapsed since the file
* has been registered
*
* These flags indicate what parts of a #GtkRecentFilterInfo struct
* are filled or need to be filled.
*/
typedef enum {
GTK_RECENT_FILTER_URI = 1 << 0,
GTK_RECENT_FILTER_DISPLAY_NAME = 1 << 1,
GTK_RECENT_FILTER_MIME_TYPE = 1 << 2,
GTK_RECENT_FILTER_APPLICATION = 1 << 3,
GTK_RECENT_FILTER_GROUP = 1 << 4,
GTK_RECENT_FILTER_AGE = 1 << 5
} GtkRecentFilterFlags;
/**
* GtkRecentFilterFunc:
* @filter_info: a #GtkRecentFilterInfo that is filled according
* to the @needed flags passed to gtk_recent_filter_add_custom()
* @user_data: user data passed to gtk_recent_filter_add_custom()
*
* The type of function that is used with custom filters,
* see gtk_recent_filter_add_custom().
*
* Returns: %TRUE if the file should be displayed
*/
typedef gboolean (*GtkRecentFilterFunc) (const GtkRecentFilterInfo *filter_info,
gpointer user_data);
/**
* GtkRecentFilterInfo:
* @contains: #GtkRecentFilterFlags to indicate which fields are set.
* @uri: (nullable): The URI of the file being tested.
* @display_name: (nullable): The string that will be used to display
* the file in the recent chooser.
* @mime_type: (nullable): MIME type of the file.
* @applications: (nullable) (array zero-terminated=1): The list of
* applications that have registered the file.
* @groups: (nullable) (array zero-terminated=1): The groups to which
* the file belongs to.
* @age: The number of days elapsed since the file has been
* registered.
*
* A GtkRecentFilterInfo struct is used
* to pass information about the tested file to gtk_recent_filter_filter().
*/
struct _GtkRecentFilterInfo
{
GtkRecentFilterFlags contains;
const gchar *uri;
const gchar *display_name;
const gchar *mime_type;
const gchar **applications;
const gchar **groups;
gint age;
};
GDK_AVAILABLE_IN_ALL
GType gtk_recent_filter_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkRecentFilter * gtk_recent_filter_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_recent_filter_set_name (GtkRecentFilter *filter,
const gchar *name);
GDK_AVAILABLE_IN_ALL
const gchar * gtk_recent_filter_get_name (GtkRecentFilter *filter);
GDK_AVAILABLE_IN_ALL
void gtk_recent_filter_add_mime_type (GtkRecentFilter *filter,
const gchar *mime_type);
GDK_AVAILABLE_IN_ALL
void gtk_recent_filter_add_pattern (GtkRecentFilter *filter,
const gchar *pattern);
GDK_AVAILABLE_IN_ALL
void gtk_recent_filter_add_pixbuf_formats (GtkRecentFilter *filter);
GDK_AVAILABLE_IN_ALL
void gtk_recent_filter_add_application (GtkRecentFilter *filter,
const gchar *application);
GDK_AVAILABLE_IN_ALL
void gtk_recent_filter_add_group (GtkRecentFilter *filter,
const gchar *group);
GDK_AVAILABLE_IN_ALL
void gtk_recent_filter_add_age (GtkRecentFilter *filter,
gint days);
GDK_AVAILABLE_IN_ALL
void gtk_recent_filter_add_custom (GtkRecentFilter *filter,
GtkRecentFilterFlags needed,
GtkRecentFilterFunc func,
gpointer data,
GDestroyNotify data_destroy);
GDK_AVAILABLE_IN_ALL
GtkRecentFilterFlags gtk_recent_filter_get_needed (GtkRecentFilter *filter);
GDK_AVAILABLE_IN_ALL
gboolean gtk_recent_filter_filter (GtkRecentFilter *filter,
const GtkRecentFilterInfo *filter_info);
G_END_DECLS
#endif /* ! __GTK_RECENT_FILTER_H__ */

View File

@ -121,7 +121,6 @@ gtk_private_sources = files([
'gtkprivate.c', 'gtkprivate.c',
'gtkprogresstracker.c', 'gtkprogresstracker.c',
'gtkquery.c', 'gtkquery.c',
'gtkrecentchooserutils.c',
'gtksearchengine.c', 'gtksearchengine.c',
'gtksearchenginemodel.c', 'gtksearchenginemodel.c',
'gtksearchenginesimple.c', 'gtksearchenginesimple.c',
@ -280,12 +279,6 @@ gtk_public_sources = files([
'gtkradiotoolbutton.c', 'gtkradiotoolbutton.c',
'gtkrange.c', 'gtkrange.c',
'gtkrbtree.c', 'gtkrbtree.c',
'gtkrecentchooser.c',
'gtkrecentchooserdefault.c',
'gtkrecentchooserdialog.c',
'gtkrecentchoosermenu.c',
'gtkrecentchooserwidget.c',
'gtkrecentfilter.c',
'gtkrecentmanager.c', 'gtkrecentmanager.c',
'gtkrender.c', 'gtkrender.c',
'gtkrenderbackground.c', 'gtkrenderbackground.c',
@ -377,7 +370,6 @@ gtk_private_type_headers = files([
gtk_private_headers = gtk_private_type_headers + files([ gtk_private_headers = gtk_private_type_headers + files([
'gtkrbtree.h', 'gtkrbtree.h',
'gtkrecentchooserutils.h',
]) ])
gtk_public_headers = files([ gtk_public_headers = files([
@ -521,11 +513,6 @@ gtk_public_headers = files([
'gtkradiomenuitem.h', 'gtkradiomenuitem.h',
'gtkradiotoolbutton.h', 'gtkradiotoolbutton.h',
'gtkrange.h', 'gtkrange.h',
'gtkrecentchooser.h',
'gtkrecentchooserdialog.h',
'gtkrecentchoosermenu.h',
'gtkrecentchooserwidget.h',
'gtkrecentfilter.h',
'gtkrecentmanager.h', 'gtkrecentmanager.h',
'gtkrender.h', 'gtkrender.h',
'gtkrevealer.h', 'gtkrevealer.h',

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk40">
<!-- interface-requires gtk+ 3.10 -->
<object class="GtkListStore" id="recent_store">
<columns>
<!-- column-name uri -->
<column type="gchararray"/>
<!-- column-name display-name -->
<column type="gchararray"/>
<!-- column-name info -->
<column type="GtkRecentInfo"/>
</columns>
</object>
<template class="GtkRecentChooserDefault" parent="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="expand">0</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="can-focus">1</property>
<property name="hscrollbar-policy">never</property>
<property name="shadow-type">in</property>
<property name="vexpand">1</property>
<child>
<object class="GtkTreeView" id="recent_view">
<property name="can-focus">1</property>
<property name="has-tooltip">1</property>
<property name="headers-visible">0</property>
<property name="expand">1</property>
<signal name="drag-begin" handler="recent_view_drag_begin_cb" swapped="no"/>
<signal name="drag-data-get" handler="recent_view_drag_data_get_cb" swapped="no"/>
<signal name="popup-menu" handler="recent_view_popup_menu_cb" swapped="no"/>
<signal name="query-tooltip" handler="recent_view_query_tooltip_cb" swapped="no"/>
<signal name="row-activated" handler="row_activated_cb" swapped="no"/>
<child internal-child="selection">
<object class="GtkTreeSelection" id="selection">
<signal name="changed" handler="selection_changed_cb" swapped="no"/>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="icon_column">
<property name="title">icon</property>
<child>
<object class="GtkCellRendererPixbuf" id="icon_renderer"/>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="meta_column">
<property name="title">meta</property>
<property name="expand">1</property>
<child>
<object class="GtkCellRendererText" id="meta_renderer">
<property name="ellipsize">end</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="filter_combo_hbox">
<property name="spacing">12</property>
<child>
<object class="GtkComboBoxText" id="filter_combo">
<property name="tooltip-text" translatable="yes">Select which type of documents are shown</property>
<property name="focus-on-click">0</property>
<property name="entry-text-column">0</property>
<property name="id-column">1</property>
<signal name="changed" handler="filter_combo_changed_cb" swapped="no"/>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</template>
</interface>

View File

@ -1 +0,0 @@
N_("Select which type of documents are shown");

View File

@ -226,9 +226,6 @@ gtk/gtkradiobutton.c
gtk/gtkradiomenuitem.c gtk/gtkradiomenuitem.c
gtk/gtkradiotoolbutton.c gtk/gtkradiotoolbutton.c
gtk/gtkrange.c gtk/gtkrange.c
gtk/gtkrecentchooser.c
gtk/gtkrecentchooserdefault.c
gtk/gtkrecentchoosermenu.c
gtk/gtkrecentmanager.c gtk/gtkrecentmanager.c
gtk/gtkrevealer.c gtk/gtkrevealer.c
gtk/gtkscalebutton.c gtk/gtkscalebutton.c

View File

@ -145,8 +145,6 @@ gtk/ui/gtkplacesviewrow.ui
gtk/ui/gtkplacesview.ui gtk/ui/gtkplacesview.ui
gtk/ui/gtkprintunixdialog.ui gtk/ui/gtkprintunixdialog.ui
gtk/ui/gtkprintunixdialog.ui.h gtk/ui/gtkprintunixdialog.ui.h
gtk/ui/gtkrecentchooserdefault.ui
gtk/ui/gtkrecentchooserdefault.ui.h
gtk/ui/gtksidebarrow.ui gtk/ui/gtksidebarrow.ui
gtk/ui/gtkvolumebutton.ui gtk/ui/gtkvolumebutton.ui
gtk/ui/gtkvolumebutton.ui.h gtk/ui/gtkvolumebutton.ui.h

View File

@ -72,8 +72,6 @@ gtk_tests = [
['testoverlay'], ['testoverlay'],
['testoverlaystyleclass'], ['testoverlaystyleclass'],
['testprint', ['testprintfileoperation.c']], ['testprint', ['testprintfileoperation.c']],
['testrecentchooser'],
['testrecentchoosermenu'],
['testscale'], ['testscale'],
['testselectionmode'], ['testselectionmode'],
['testspinbutton'], ['testspinbutton'],

View File

@ -2864,27 +2864,6 @@
<property name="tab_fill">False</property> <property name="tab_fill">False</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkRecentChooserWidget" id="recentchooser1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="limit">20</property>
</object>
<packing>
<property name="position">10</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">GtkRecentChooserDefault</property>
</object>
<packing>
<property name="position">10</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child> <child>
<object class="GtkColorButton" id="colorselection1"> <object class="GtkColorButton" id="colorselection1">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -1,200 +0,0 @@
/* testrecentchooser.c
* Copyright (C) 2006 Emmanuele Bassi.
*
* 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 this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <gtk/gtk.h>
#ifdef G_OS_WIN32
# include <io.h>
# define localtime_r(t,b) *(b) = localtime (t)
# ifndef S_ISREG
# define S_ISREG(m) ((m) & _S_IFREG)
# endif
#endif
static void
print_current_item (GtkRecentChooser *chooser)
{
gchar *uri;
uri = gtk_recent_chooser_get_current_uri (chooser);
g_print ("Current item changed :\n %s\n", uri ? uri : "null");
g_free (uri);
}
static void
print_selected (GtkRecentChooser *chooser)
{
gsize uris_len, i;
gchar **uris = gtk_recent_chooser_get_uris (chooser, &uris_len);
g_print ("Selection changed :\n");
for (i = 0; i < uris_len; i++)
g_print (" %s\n", uris[i]);
g_print ("\n");
g_strfreev (uris);
}
static void
response_cb (GtkDialog *dialog,
gint response_id)
{
if (response_id == GTK_RESPONSE_OK)
{
}
else
g_print ("Dialog was closed\n");
gtk_main_quit ();
}
static void
filter_changed (GtkRecentChooserDialog *dialog,
gpointer data)
{
g_print ("recent filter changed\n");
}
static void
notify_multiple_cb (GtkWidget *dialog,
GParamSpec *pspec,
GtkWidget *button)
{
gboolean multiple;
multiple = gtk_recent_chooser_get_select_multiple (GTK_RECENT_CHOOSER (dialog));
gtk_widget_set_sensitive (button, multiple);
}
static void
kill_dependent (GtkWindow *win,
GtkWidget *dep)
{
gtk_widget_destroy (dep);
g_object_unref (dep);
}
int
main (int argc,
char *argv[])
{
GtkWidget *control_window;
GtkWidget *vbbox;
GtkWidget *button;
GtkWidget *dialog;
GtkRecentFilter *filter;
gint i;
gboolean multiple = FALSE;
gtk_init ();
/* to test rtl layout, set RTL=1 in the environment */
if (g_getenv ("RTL"))
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
for (i = 1; i < argc; i++)
{
if (!strcmp ("--multiple", argv[i]))
multiple = TRUE;
}
dialog = g_object_new (GTK_TYPE_RECENT_CHOOSER_DIALOG,
"select-multiple", multiple,
"show-tips", TRUE,
"show-icons", TRUE,
NULL);
gtk_window_set_title (GTK_WINDOW (dialog), "Select a file");
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
"_Cancel", GTK_RESPONSE_CANCEL,
"_Open", GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
g_signal_connect (dialog, "item-activated",
G_CALLBACK (print_current_item), NULL);
g_signal_connect (dialog, "selection-changed",
G_CALLBACK (print_selected), NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (response_cb), NULL);
/* filters */
filter = gtk_recent_filter_new ();
gtk_recent_filter_set_name (filter, "All Files");
gtk_recent_filter_add_pattern (filter, "*");
gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (dialog), filter);
filter = gtk_recent_filter_new ();
gtk_recent_filter_set_name (filter, "Only PDF Files");
gtk_recent_filter_add_mime_type (filter, "application/pdf");
gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (dialog), filter);
g_signal_connect (dialog, "notify::filter",
G_CALLBACK (filter_changed), NULL);
gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (dialog), filter);
filter = gtk_recent_filter_new ();
gtk_recent_filter_set_name (filter, "PNG and JPEG");
gtk_recent_filter_add_mime_type (filter, "image/png");
gtk_recent_filter_add_mime_type (filter, "image/jpeg");
gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (dialog), filter);
gtk_widget_show (dialog);
control_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbbox = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
gtk_container_add (GTK_CONTAINER (control_window), vbbox);
button = gtk_button_new_with_mnemonic ("_Select all");
gtk_widget_set_sensitive (button, multiple);
gtk_container_add (GTK_CONTAINER (vbbox), button);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gtk_recent_chooser_select_all), dialog);
g_signal_connect (dialog, "notify::select-multiple",
G_CALLBACK (notify_multiple_cb), button);
button = gtk_button_new_with_mnemonic ("_Unselect all");
gtk_container_add (GTK_CONTAINER (vbbox), button);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gtk_recent_chooser_unselect_all), dialog);
gtk_widget_show (control_window);
g_object_ref (control_window);
g_signal_connect (dialog, "destroy",
G_CALLBACK (kill_dependent), control_window);
g_object_ref (dialog);
gtk_main ();
gtk_widget_destroy (dialog);
g_object_unref (dialog);
return 0;
}

View File

@ -1,183 +0,0 @@
/* testrecentchoosermenu.c - Test GtkRecentChooserMenu
* Copyright (C) 2007 Emmanuele Bassi <ebassi@gnome.org>
*
* 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 this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
static GtkRecentManager *manager = NULL;
static GtkWidget *window = NULL;
static GtkWidget *label = NULL;
static void
item_activated_cb (GtkRecentChooser *chooser,
gpointer data)
{
GtkRecentInfo *info;
GString *text;
gchar *label_text;
info = gtk_recent_chooser_get_current_item (chooser);
if (!info)
{
g_warning ("Unable to retrieve the current item, aborting...");
return;
}
text = g_string_new ("Selected recent item:\n");
g_string_append_printf (text, " URI: %s\n",
gtk_recent_info_get_uri (info));
g_string_append_printf (text, " MIME Type: %s\n",
gtk_recent_info_get_mime_type (info));
label_text = g_string_free (text, FALSE);
gtk_label_set_text (GTK_LABEL (label), label_text);
gtk_recent_info_unref (info);
g_free (label_text);
}
static GtkWidget *
create_recent_chooser_menu (gint limit)
{
GtkWidget *menu;
GtkRecentFilter *filter;
GtkWidget *menuitem;
menu = gtk_recent_chooser_menu_new_for_manager (manager);
if (limit > 0)
gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (menu), limit);
gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (menu), TRUE);
gtk_recent_chooser_set_show_icons (GTK_RECENT_CHOOSER (menu), TRUE);
gtk_recent_chooser_set_show_tips (GTK_RECENT_CHOOSER (menu), TRUE);
gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu),
GTK_RECENT_SORT_MRU);
gtk_recent_chooser_menu_set_show_numbers (GTK_RECENT_CHOOSER_MENU (menu),
TRUE);
filter = gtk_recent_filter_new ();
gtk_recent_filter_set_name (filter, "Gedit files");
gtk_recent_filter_add_application (filter, "gedit");
gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter);
gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (menu), filter);
g_signal_connect (menu, "item-activated",
G_CALLBACK (item_activated_cb),
NULL);
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_label ("Test prepend");
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_label ("Test append");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic ("Clear");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
return menu;
}
static GtkWidget *
create_file_menu (GtkAccelGroup *accelgroup)
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *recentmenu;
menu = gtk_menu_new ();
menuitem = gtk_menu_item_new_with_mnemonic ("_New");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic ("_Open");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic ("_Open Recent");
recentmenu = create_recent_chooser_menu (-1);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), recentmenu);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
menuitem = gtk_menu_item_new_with_mnemonic ("_Quit");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
return menu;
}
int
main (int argc, char *argv[])
{
GtkWidget *box;
GtkWidget *menubar;
GtkWidget *menuitem;
GtkWidget *menu;
GtkWidget *button;
GtkAccelGroup *accel_group;
gtk_init ();
manager = gtk_recent_manager_get_default ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), -1, -1);
gtk_window_set_title (GTK_WINDOW (window), "Recent Chooser Menu Test");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
menubar = gtk_menu_bar_new ();
gtk_box_pack_start (GTK_BOX (box), menubar);
menu = create_file_menu (accel_group);
menuitem = gtk_menu_item_new_with_mnemonic ("_File");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
menu = create_recent_chooser_menu (4);
menuitem = gtk_menu_item_new_with_mnemonic ("_Recently Used");
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
label = gtk_label_new ("No recent item selected");
gtk_box_pack_start (GTK_BOX (box), label);
button = gtk_button_new_with_label ("Close");
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (gtk_widget_destroy),
window);
gtk_box_pack_end (GTK_BOX (box), button);
gtk_widget_set_can_default (button, TRUE);
gtk_widget_grab_default (button);
gtk_widget_show (window);
gtk_main ();
return 0;
}

View File

@ -303,16 +303,6 @@ test_font_chooser_dialog_basic (void)
gtk_widget_destroy (widget); gtk_widget_destroy (widget);
} }
static void
test_recent_chooser_widget_basic (void)
{
GtkWidget *widget;
widget = gtk_recent_chooser_widget_new ();
g_assert (GTK_IS_RECENT_CHOOSER_WIDGET (widget));
gtk_widget_destroy (widget);
}
#ifdef HAVE_UNIX_PRINT_WIDGETS #ifdef HAVE_UNIX_PRINT_WIDGETS
static void static void
test_page_setup_unix_dialog_basic (void) test_page_setup_unix_dialog_basic (void)
@ -378,7 +368,6 @@ main (int argc, char **argv)
g_test_add_func ("/Template/GtkFontButton/Basic", test_font_button_basic); g_test_add_func ("/Template/GtkFontButton/Basic", test_font_button_basic);
g_test_add_func ("/Template/GtkFontChooserWidget/Basic", test_font_chooser_widget_basic); g_test_add_func ("/Template/GtkFontChooserWidget/Basic", test_font_chooser_widget_basic);
g_test_add_func ("/Template/GtkFontChooserDialog/Basic", test_font_chooser_dialog_basic); g_test_add_func ("/Template/GtkFontChooserDialog/Basic", test_font_chooser_dialog_basic);
g_test_add_func ("/Template/GtkRecentChooserWidget/Basic", test_recent_chooser_widget_basic);
#ifdef HAVE_UNIX_PRINT_WIDGETS #ifdef HAVE_UNIX_PRINT_WIDGETS
g_test_add_func ("/Template/UnixPrint/GtkPageSetupUnixDialog/Basic", test_page_setup_unix_dialog_basic); g_test_add_func ("/Template/UnixPrint/GtkPageSetupUnixDialog/Basic", test_page_setup_unix_dialog_basic);