Commit 056f6db5 authored by Emmanuele Bassi's avatar Emmanuele Bassi Committed by Emmanuele Bassi

Import GtkRecent* from libegg.

2006-03-29  Emmanuele Bassi  <ebassi@cvs.gnome.org>

	Import GtkRecent* from libegg.

	* gtk/gtkrecentmanager.[ch]: Add GtkRecentManager, an object
	for managing a list of recently used resources.

	* gtk/gtkrecentchooser.[ch]:
	* gtk/gtkrecentchooserdefault.[ch]:
	* gtk/gtkrecentchooserdialog.[ch]:
	* gtk/gtkrecentchoosermenu.[ch]:
	* gtk/gtkrecentchooserprivate.h:
	* gtk/gtkrecentchooserutils.[ch]:
	* gtk/gtkrecentchooserwidget.[ch]: Add GtkRecentChooser, a
	GTypeInterface for widgets implementing viewers for recently
	used resources.

	* gtk/gtkrecentfilter.[ch]: GtkRecentFilter, a filter object
	for GtkRecentChooser implementations.

	* gtk/gtk.h:
	* gtk/gtk.symbols:
	* gtk/Makefile.am: Build glue for GtkRecent*.
parent 5f5de68e
......@@ -228,6 +228,12 @@ gtk_public_h_sources = \
gtkradiotoolbutton.h \
gtkrange.h \
gtkrc.h \
gtkrecentchooser.h \
gtkrecentchooserdialog.h \
gtkrecentchoosermenu.h \
gtkrecentchooserwidget.h \
gtkrecentfilter.h \
gtkrecentmanager.h \
gtkruler.h \
gtkscale.h \
gtkscrollbar.h \
......@@ -310,6 +316,9 @@ gtk_private_h_sources = \
gtkpathbar.h \
gtkplugprivate.h \
gtkrbtree.h \
gtkrecentchooserdefault.h \
gtkrecentchooserprivate.h \
gtkrecentchooserutils.h \
gtksequence.h \
gtksocketprivate.h \
gtktextbtree.h \
......@@ -459,6 +468,14 @@ gtk_c_sources = \
gtkrange.c \
gtkrbtree.c \
gtkrc.c \
gtkrecentchooserdefault.c \
gtkrecentchooserdialog.c \
gtkrecentchoosermenu.c \
gtkrecentchooserwidget.c \
gtkrecentchooserutils.c \
gtkrecentchooser.c \
gtkrecentfilter.c \
gtkrecentmanager.c \
gtkruler.c \
gtkscale.c \
gtkscrollbar.c \
......
......@@ -140,6 +140,12 @@
#include <gtk/gtkradiotoolbutton.h>
#include <gtk/gtkrange.h>
#include <gtk/gtkrc.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/gtkruler.h>
#include <gtk/gtkscale.h>
#include <gtk/gtkscrollbar.h>
......
......@@ -2621,6 +2621,134 @@ gtk_rc_style_unref
#endif
#endif
#if IN_HEADER(__GTK_RECENT_CHOOSER_H__)
#if IN_FILE(__GTK_RECENT_CHOOSER_C__))
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
gtk_recent_chooser_set_show_numbers
gtk_recent_chooser_get_show_numbers
gtk_recent_chooser_set_sort_type
gtk_recent_chooser_get_sort_type
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
gtk_recent_chooser_get_type G_GNUC_CONST
gtk_recent_chooser_error_quark
#endif
#endif
#if IN_HEADER(__GTK_RECENT_CHOOSER_DIALOG_H__)
#if IN_FILE(__GTK_RECENT_CHOOSER_DIALOG_C__)
gtk_recent_chooser_dialog_get_type G_GNUC_CONST
gtk_recent_chooser_dialog_new G_GNUC_NULL_TERMINATED
gtk_recent_chooser_dialog_new_for_manager G_GNUC_NULL_TERMINATED
#endif
#endif
#if IN_HEADER(__GTK_RECENT_CHOOSER_MENU_H__)
#if IN_FILE(__GTK_RECENT_CHOOSER_MENU_C__)
gtk_recent_chooser_menu_get_type G_GNUC_CONST
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
#endif
#endif
#if IN_HEADER(__GTK_RECENT_CHOOSER_WIDGET_H__)
#if IN_FILE(__GTK_RECENT_CHOOSER_WIDGET_C__)
gtk_recent_chooser_widget_get_type G_GNUC_CONST
gtk_recent_chooser_widget_new
gtk_recent_chooser_widget_new_for_manager
#endif
#endif
#if IN_HEADER(__GTK_RECENT_FILTER_H__)
#if IN_FILE(__GTK_RECENT_FILTER_C__)
gtk_recent_filter_get_type G_GNUC_CONST
gtk_recent_filter_new
gtk_recent_filter_set_name
gtk_recent_filter_get_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
#endif
#endif
#if IN_HEADER(__GTK_RECENT_MANAGER_H__)
#if IN_FILE(__GTK_RECENT_MANAGER_C__)
gtk_recent_manager_error_quark
gtk_recent_manager_get_type G_GNUC_CONST
gtk_recent_manager_new
gtk_recent_manager_get_default
gtk_recent_manager_get_for_screen
gtk_recent_manager_set_screen
gtk_recent_manager_add_item
gtk_recent_manager_add_full
gtk_recent_manager_remove_item
gtk_recent_manager_lookup_item
gtk_recent_manager_has_item
gtk_recent_manager_move_item
gtk_recent_manager_set_limit
gtk_recent_manager_get_limit
gtk_recent_manager_purge_items
gtk_recent_info_get_type G_GNUC_CONST
gtk_recent_info_ref
gtk_recent_info_unref
gtk_recent_info_get_uri
gtk_recent_info_get_display_name
gtk_recent_info_get_description
gtk_recent_info_get_mime_type
gtk_recent_info_get_added
gtk_recent_info_get_modified
gtk_recent_info_get_visited
gtk_recent_info_get_private_hint
gtk_recent_info_get_application_info
gtk_recent_info_get_applications G_GNUC_MALLOC
gtk_recent_info_last_application G_GNUC_MALLOC
gtk_recent_info_has_application
gtk_recent_info_get_groups G_GNUC_MALLOC
gtk_recent_info_has_group
gtk_recent_info_get_icon
gtk_recent_info_get_short_name G_GNUC_MALLOC
gtk_recent_info_get_uri_display G_GNUC_MALLOC
gtk_recent_info_get_age
gtk_recent_info_is_local
gtk_recent_info_exists
gtk_recent_info_match
#endif
#endif
#if IN_HEADER(__GTK_TEXT_BUFFER_RICH_TEXT_H__)
#if IN_FILE(__GTK_TEXT_BUFFER_RICH_TEXT_C__)
gtk_text_buffer_deserialize
......
This diff is collapsed.
/* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_RECENT_CHOOSER_H__
#define __GTK_RECENT_CHOOSER_H__
#include <gtk/gtkwidget.h>
#include "gtkrecentmanager.h"
#include "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_manager_set_sort_func().
*
* Used to specify the sorting method to be applyed to the recently
* used resource list.
**/
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;
#define GTK_RECENT_CHOOSER_ERROR (gtk_recent_chooser_error_quark ())
typedef enum
{
GTK_RECENT_CHOOSER_ERROR_NOT_FOUND,
GTK_RECENT_CHOOSER_ERROR_INVALID_URI
} GtkRecentChooserError;
GQuark gtk_recent_chooser_error_quark (void);
struct _GtkRecentChooserIface
{
GTypeInterface base_iface;
/*
* 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 data,
GDestroyNotify destroy);
/*
* Signals
*/
void (* item_activated) (GtkRecentChooser *chooser);
void (* selection_changed) (GtkRecentChooser *chooser);
};
GType gtk_recent_chooser_get_type (void) G_GNUC_CONST;
/*
* Configuration
*/
void gtk_recent_chooser_set_show_private (GtkRecentChooser *chooser,
gboolean show_private);
gboolean gtk_recent_chooser_get_show_private (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_show_not_found (GtkRecentChooser *chooser,
gboolean show_not_found);
gboolean gtk_recent_chooser_get_show_not_found (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_select_multiple (GtkRecentChooser *chooser,
gboolean select_multiple);
gboolean gtk_recent_chooser_get_select_multiple (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_limit (GtkRecentChooser *chooser,
gint limit);
gint gtk_recent_chooser_get_limit (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_local_only (GtkRecentChooser *chooser,
gboolean local_only);
gboolean gtk_recent_chooser_get_local_only (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_show_tips (GtkRecentChooser *chooser,
gboolean show_tips);
gboolean gtk_recent_chooser_get_show_tips (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_show_numbers (GtkRecentChooser *chooser,
gboolean show_numbers);
gboolean gtk_recent_chooser_get_show_numbers (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_show_icons (GtkRecentChooser *chooser,
gboolean show_icons);
gboolean gtk_recent_chooser_get_show_icons (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_sort_type (GtkRecentChooser *chooser,
GtkRecentSortType sort_type);
GtkRecentSortType gtk_recent_chooser_get_sort_type (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_sort_func (GtkRecentChooser *chooser,
GtkRecentSortFunc sort_func,
gpointer sort_data,
GDestroyNotify data_destroy);
/*
* Items handling
*/
gboolean gtk_recent_chooser_set_current_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error);
gchar * gtk_recent_chooser_get_current_uri (GtkRecentChooser *chooser);
GtkRecentInfo *gtk_recent_chooser_get_current_item (GtkRecentChooser *chooser);
gboolean gtk_recent_chooser_select_uri (GtkRecentChooser *chooser,
const gchar *uri,
GError **error);
void gtk_recent_chooser_unselect_uri (GtkRecentChooser *chooser,
const gchar *uri);
void gtk_recent_chooser_select_all (GtkRecentChooser *chooser);
void gtk_recent_chooser_unselect_all (GtkRecentChooser *chooser);
GList * gtk_recent_chooser_get_items (GtkRecentChooser *chooser);
gchar ** gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
gsize *length);
/*
* Filters
*/
void gtk_recent_chooser_add_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
void gtk_recent_chooser_remove_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
GSList * gtk_recent_chooser_list_filters (GtkRecentChooser *chooser);
void gtk_recent_chooser_set_filter (GtkRecentChooser *chooser,
GtkRecentFilter *filter);
GtkRecentFilter *gtk_recent_chooser_get_filter (GtkRecentChooser *chooser);
G_END_DECLS
#endif /* __GTK_RECENT_CHOOSER_H__ */
This diff is collapsed.
/* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#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__ */
/* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include "gtkrecentchooserdialog.h"
#include "gtkrecentchooserwidget.h"
#include "gtkrecentchooserutils.h"
#include "gtkrecentmanager.h"
#include "gtktypebuiltins.h"
#include "gtkalias.h"
#include <stdarg.h>
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_class_init (GtkRecentChooserDialogClass *klass);
static void gtk_recent_chooser_dialog_init (GtkRecentChooserDialog *dialog);
static void gtk_recent_chooser_dialog_finalize (GObject *object);
static GObject *gtk_recent_chooser_dialog_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_params);
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);
static void gtk_recent_chooser_dialog_map (GtkWidget *widget);
static void gtk_recent_chooser_dialog_unmap (GtkWidget *widget);
static void gtk_recent_chooser_dialog_style_set (GtkWidget *widget,
GtkStyle *old_style);
G_DEFINE_TYPE_WITH_CODE (GtkRecentChooserDialog,
gtk_recent_chooser_dialog,
GTK_TYPE_DIALOG,
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);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gobject_class->set_property = gtk_recent_chooser_dialog_set_property;
gobject_class->get_property = gtk_recent_chooser_dialog_get_property;
gobject_class->constructor = gtk_recent_chooser_dialog_constructor;
gobject_class->finalize = gtk_recent_chooser_dialog_finalize;
widget_class->map = gtk_recent_chooser_dialog_map;
widget_class->unmap = gtk_recent_chooser_dialog_unmap;
widget_class->style_set = gtk_recent_chooser_dialog_style_set;
_gtk_recent_chooser_install_properties (gobject_class);
g_type_class_add_private (klass, sizeof (GtkRecentChooserDialogPrivate));
}
static void
gtk_recent_chooser_dialog_init (GtkRecentChooserDialog *dialog)
{
GtkRecentChooserDialogPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog,
GTK_TYPE_RECENT_CHOOSER_DIALOG,
GtkRecentChooserDialogPrivate);
dialog->priv = priv;
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
}
/* 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)
{
GtkRecentChooserDialog *dialog;
GList *children, *l;
dialog = GTK_RECENT_CHOOSER_DIALOG (user_data);
if (gtk_window_activate_default (GTK_WINDOW (dialog)))
return;
children = gtk_container_get_children (GTK_CONTAINER (GTK_DIALOG (dialog)->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 (GTK_DIALOG (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 GObject *
gtk_recent_chooser_dialog_constructor (GType type,
guint n_construct_properties,
GObjectConstructParam *construct_params)
{
GObject *object;
GtkRecentChooserDialogPrivate *priv;
object = G_OBJECT_CLASS (gtk_recent_chooser_dialog_parent_class)->constructor (type,
n_construct_properties,
construct_params);
priv = GTK_RECENT_CHOOSER_DIALOG_GET_PRIVATE (object);
gtk_widget_push_composite_child ();
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);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox),
priv->chooser, TRUE, TRUE, 0);
gtk_widget_show (priv->chooser);
_gtk_recent_chooser_set_delegate (GTK_RECENT_CHOOSER (object),
GTK_RECENT_CHOOSER (priv->chooser));
gtk_widget_pop_composite_child ();
return object;
}
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 void
gtk_recent_chooser_dialog_map (GtkWidget *widget)
{
GtkRecentChooserDialog *dialog = GTK_RECENT_CHOOSER_DIALOG (widget);
GtkRecentChooserDialogPrivate *priv = dialog->priv;
if (!GTK_WIDGET_MAPPED (priv->chooser))
gtk_widget_map (priv->chooser);
GTK_WIDGET_CLASS (gtk_recent_chooser_dialog_parent_class)->map (widget);
}
static void
gtk_recent_chooser_dialog_unmap (GtkWidget *widget)
{
GtkRecentChooserDialog *dialog = GTK_RECENT_CHOOSER_DIALOG (widget);
GtkRecentChooserDialogPrivate *priv = dialog->priv;
GTK_WIDGET_CLASS (gtk_recent_chooser_dialog_parent_class)->unmap (widget);
gtk_widget_unmap (priv->chooser);
}
/* taken from gtkfilechooserdialog.c */
static void
gtk_recent_chooser_dialog_style_set (GtkWidget *widget,
GtkStyle *old_style)
{
GtkDialog *dialog;
dialog = GTK_DIALOG (widget);
/* Override the style properties with HIG-compliant spacings. Ugh.
* http://developer.gnome.org/projects/gup/hig/1.0/layout.html#layout-dialogs
* http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-spacing
*/
gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12);
gtk_box_set_spacing (GTK_BOX (dialog->vbox), 24);
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
if (GTK_WIDGET_CLASS (gtk_recent_chooser_dialog_parent_class)->style_set)
GTK_WIDGET_CLASS (gtk_recent_chooser_dialog_parent_class)->style_set (widget, old_style);
}
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: Title of the dialog, or %NULL
* @parent: Transient parent of the dialog, or %NULL,
* @first_button_text: stock ID or text to go in the first button, or %NULL
* @Varargs: 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().
*
* Return value: 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,