static void gtk_recent_action_remove_filter (GtkRecentChooser *chooser, GtkRecentFilter *filter) { GtkRecentAction *action = GTK_RECENT_ACTION (chooser); GtkRecentActionPrivate *priv = action->priv; if (priv->current_filter == filter) set_current_filter (GTK_RECENT_ACTION (chooser), NULL); }
static void gtk_recent_action_set_sort_func (GtkRecentChooser *chooser, GtkRecentSortFunc sort_func, gpointer sort_data, GDestroyNotify data_destroy) { GtkRecentAction *action = GTK_RECENT_ACTION (chooser); GtkRecentActionPrivate *priv = action->priv; GSList *l; if (priv->data_destroy) { priv->data_destroy (priv->sort_data); priv->data_destroy = NULL; } priv->sort_func = NULL; priv->sort_data = NULL; if (sort_func) { priv->sort_func = sort_func; priv->sort_data = sort_data; priv->data_destroy = data_destroy; } for (l = priv->choosers; l; l = l->next) { GtkRecentChooser *chooser_menu = l->data; gtk_recent_chooser_set_sort_func (chooser_menu, priv->sort_func, priv->sort_data, priv->data_destroy); } }
static void gtk_recent_action_connect_proxy (GtkAction *action, GtkWidget *widget) { GtkRecentAction *recent_action = GTK_RECENT_ACTION (action); GtkRecentActionPrivate *priv = recent_action->priv; /* it can only be a recent chooser implementor anyway... */ if (GTK_IS_RECENT_CHOOSER (widget) && !g_slist_find (priv->choosers, widget)) { if (priv->sort_func) { gtk_recent_chooser_set_sort_func (GTK_RECENT_CHOOSER (widget), priv->sort_func, priv->sort_data, priv->data_destroy); } g_signal_connect_swapped (widget, "selection_changed", G_CALLBACK (delegate_selection_changed), action); g_signal_connect_swapped (widget, "item-activated", G_CALLBACK (delegate_item_activated), action); } if (GTK_ACTION_CLASS (gtk_recent_action_parent_class)->connect_proxy) GTK_ACTION_CLASS (gtk_recent_action_parent_class)->connect_proxy (action, widget); }
void _gtk_recent_chooser_sync_action_properties (GtkActivatable *activatable, GtkAction *action) { GtkRecentChooser *recent_chooser; GtkRecentChooser *action_chooser; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; recent_chooser = GTK_RECENT_CHOOSER (activatable); action_chooser = GTK_RECENT_CHOOSER (action); G_GNUC_END_IGNORE_DEPRECATIONS; if (!action) return; if (recent_chooser_has_show_numbers (recent_chooser)) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS; g_object_set (recent_chooser, "show-numbers", gtk_recent_action_get_show_numbers (GTK_RECENT_ACTION (action)), NULL); G_GNUC_END_IGNORE_DEPRECATIONS; } gtk_recent_chooser_set_show_private (recent_chooser, gtk_recent_chooser_get_show_private (action_chooser)); gtk_recent_chooser_set_show_not_found (recent_chooser, gtk_recent_chooser_get_show_not_found (action_chooser)); gtk_recent_chooser_set_show_tips (recent_chooser, gtk_recent_chooser_get_show_tips (action_chooser)); gtk_recent_chooser_set_show_icons (recent_chooser, gtk_recent_chooser_get_show_icons (action_chooser)); gtk_recent_chooser_set_limit (recent_chooser, gtk_recent_chooser_get_limit (action_chooser)); gtk_recent_chooser_set_local_only (recent_chooser, gtk_recent_chooser_get_local_only (action_chooser)); gtk_recent_chooser_set_sort_type (recent_chooser, gtk_recent_chooser_get_sort_type (action_chooser)); gtk_recent_chooser_set_filter (recent_chooser, gtk_recent_chooser_get_filter (action_chooser)); }
static void gtk_recent_action_add_filter (GtkRecentChooser *chooser, GtkRecentFilter *filter) { GtkRecentActionPrivate *priv = GTK_RECENT_ACTION_GET_PRIVATE (chooser); if (priv->current_filter != filter) set_current_filter (GTK_RECENT_ACTION (chooser), filter); }
static gchar * gtk_recent_action_get_current_uri (GtkRecentChooser *chooser) { GtkRecentAction *recent_action = GTK_RECENT_ACTION (chooser); GtkRecentActionPrivate *priv = recent_action->priv; if (priv->current_chooser) return gtk_recent_chooser_get_current_uri (priv->current_chooser); return NULL; }
static GList * gtk_recent_action_get_items (GtkRecentChooser *chooser) { GtkRecentAction *action = GTK_RECENT_ACTION (chooser); GtkRecentActionPrivate *priv = action->priv; return _gtk_recent_chooser_get_items (chooser, priv->current_filter, priv->sort_func, priv->sort_data); }
static void gtk_recent_action_activate (GtkAction *action) { GtkRecentAction *recent_action = GTK_RECENT_ACTION (action); GtkRecentActionPrivate *priv = recent_action->priv; /* we have probably been invoked by a menu tool button or by a * direct call of gtk_action_activate(); since no item has been * selected, we must unset the current recent chooser pointer */ priv->current_chooser = NULL; }
static GSList * gtk_recent_action_list_filters (GtkRecentChooser *chooser) { GtkRecentAction *action = GTK_RECENT_ACTION (chooser); GtkRecentActionPrivate *priv = action->priv; GSList *retval = NULL; GtkRecentFilter *current_filter; current_filter = priv->current_filter; retval = g_slist_prepend (retval, current_filter); return retval; }
static void gtk_recent_action_set_property (GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec) { GtkRecentAction *action = GTK_RECENT_ACTION (gobject); GtkRecentActionPrivate *priv = action->priv; switch (prop_id) { case PROP_SHOW_NUMBERS: priv->show_numbers = g_value_get_boolean (value); break; case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE: priv->show_private = g_value_get_boolean (value); break; case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND: priv->show_not_found = g_value_get_boolean (value); break; case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS: priv->show_tips = g_value_get_boolean (value); break; case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS: priv->show_icons = g_value_get_boolean (value); break; case GTK_RECENT_CHOOSER_PROP_LIMIT: priv->limit = g_value_get_int (value); break; case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY: priv->local_only = g_value_get_boolean (value); break; case GTK_RECENT_CHOOSER_PROP_SORT_TYPE: priv->sort_type = g_value_get_enum (value); break; case GTK_RECENT_CHOOSER_PROP_FILTER: set_current_filter (action, g_value_get_object (value)); break; case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE: g_warning ("%s: Choosers of type `%s' do not support selecting multiple items.", G_STRFUNC, G_OBJECT_TYPE_NAME (gobject)); return; case GTK_RECENT_CHOOSER_PROP_RECENT_MANAGER: set_recent_manager (action, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); return; } }
static void gtk_recent_action_dispose (GObject *gobject) { GtkRecentAction *action = GTK_RECENT_ACTION (gobject); GtkRecentActionPrivate *priv = action->priv; if (priv->current_filter) { g_object_unref (priv->current_filter); priv->current_filter = NULL; } G_OBJECT_CLASS (gtk_recent_action_parent_class)->dispose (gobject); }
static void gtk_recent_action_unselect_uri (GtkRecentChooser *chooser, const gchar *uri) { GtkRecentAction *action = GTK_RECENT_ACTION (chooser); GtkRecentActionPrivate *priv = action->priv; GSList *l; for (l = priv->choosers; l; l = l->next) { GtkRecentChooser *chooser = l->data; gtk_recent_chooser_unselect_uri (chooser, uri); } }
static void gtk_recent_action_disconnect_proxy (GtkAction *action, GtkWidget *widget) { GtkRecentAction *recent_action = GTK_RECENT_ACTION (action); GtkRecentActionPrivate *priv = recent_action->priv; /* if it was one of the recent choosers we created, remove it * from the list */ if (g_slist_find (priv->choosers, widget)) priv->choosers = g_slist_remove (priv->choosers, widget); if (GTK_ACTION_CLASS (gtk_recent_action_parent_class)->disconnect_proxy) GTK_ACTION_CLASS (gtk_recent_action_parent_class)->disconnect_proxy (action, widget); }
static void gtk_recent_action_get_property (GObject *gobject, guint prop_id, GValue *value, GParamSpec *pspec) { GtkRecentAction *action = GTK_RECENT_ACTION (gobject); GtkRecentActionPrivate *priv = action->priv; switch (prop_id) { case PROP_SHOW_NUMBERS: g_value_set_boolean (value, priv->show_numbers); break; case GTK_RECENT_CHOOSER_PROP_SHOW_PRIVATE: g_value_set_boolean (value, priv->show_private); break; case GTK_RECENT_CHOOSER_PROP_SHOW_NOT_FOUND: g_value_set_boolean (value, priv->show_not_found); break; case GTK_RECENT_CHOOSER_PROP_SHOW_TIPS: g_value_set_boolean (value, priv->show_tips); break; case GTK_RECENT_CHOOSER_PROP_SHOW_ICONS: g_value_set_boolean (value, priv->show_icons); break; case GTK_RECENT_CHOOSER_PROP_LIMIT: g_value_set_int (value, priv->limit); break; case GTK_RECENT_CHOOSER_PROP_LOCAL_ONLY: g_value_set_boolean (value, priv->local_only); break; case GTK_RECENT_CHOOSER_PROP_SORT_TYPE: g_value_set_enum (value, priv->sort_type); break; case GTK_RECENT_CHOOSER_PROP_FILTER: g_value_set_object (value, priv->current_filter); break; case GTK_RECENT_CHOOSER_PROP_SELECT_MULTIPLE: g_value_set_boolean (value, FALSE); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; } }
static gboolean gtk_recent_action_set_current_uri (GtkRecentChooser *chooser, const gchar *uri, GError **error) { GtkRecentAction *action = GTK_RECENT_ACTION (chooser); GtkRecentActionPrivate *priv = action->priv; GSList *l; for (l = priv->choosers; l; l = l->next) { GtkRecentChooser *recent_chooser = l->data; if (!gtk_recent_chooser_set_current_uri (recent_chooser, uri, error)) return FALSE; } return TRUE; }
static void gtk_recent_action_finalize (GObject *gobject) { GtkRecentAction *action = GTK_RECENT_ACTION (gobject); GtkRecentActionPrivate *priv = action->priv; priv->manager = NULL; if (priv->data_destroy) { priv->data_destroy (priv->sort_data); priv->data_destroy = NULL; } priv->sort_data = NULL; priv->sort_func = NULL; g_slist_free (priv->choosers); G_OBJECT_CLASS (gtk_recent_action_parent_class)->finalize (gobject); }
static GtkWidget * gtk_recent_action_create_menu (GtkAction *action) { GtkRecentAction *recent_action = GTK_RECENT_ACTION (action); GtkRecentActionPrivate *priv = recent_action->priv; GtkWidget *widget; widget = g_object_new (GTK_TYPE_RECENT_CHOOSER_MENU, "show-private", priv->show_private, "show-not-found", priv->show_not_found, "show-tips", priv->show_tips, "show-icons", priv->show_icons, "show-numbers", priv->show_numbers, "limit", priv->limit, "sort-type", priv->sort_type, "recent-manager", priv->manager, "filter", priv->current_filter, "local-only", priv->local_only, NULL); if (priv->sort_func) { gtk_recent_chooser_set_sort_func (GTK_RECENT_CHOOSER (widget), priv->sort_func, priv->sort_data, priv->data_destroy); } g_signal_connect_swapped (widget, "selection_changed", G_CALLBACK (delegate_selection_changed), recent_action); g_signal_connect_swapped (widget, "item-activated", G_CALLBACK (delegate_item_activated), recent_action); /* keep track of the choosers we create */ priv->choosers = g_slist_prepend (priv->choosers, widget); return widget; }
void _gtk_recent_chooser_update (GtkActivatable *activatable, GtkAction *action, const gchar *property_name) { GtkRecentChooser *recent_chooser; GtkRecentChooser *action_chooser; GtkRecentAction *recent_action; G_GNUC_BEGIN_IGNORE_DEPRECATIONS; recent_chooser = GTK_RECENT_CHOOSER (activatable); action_chooser = GTK_RECENT_CHOOSER (action); recent_action = GTK_RECENT_ACTION (action); G_GNUC_END_IGNORE_DEPRECATIONS; if (strcmp (property_name, "show-numbers") == 0 && recent_chooser_has_show_numbers (recent_chooser)) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS; g_object_set (recent_chooser, "show-numbers", gtk_recent_action_get_show_numbers (recent_action), NULL); G_GNUC_END_IGNORE_DEPRECATIONS; } else if (strcmp (property_name, "show-private") == 0) gtk_recent_chooser_set_show_private (recent_chooser, gtk_recent_chooser_get_show_private (action_chooser)); else if (strcmp (property_name, "show-not-found") == 0) gtk_recent_chooser_set_show_not_found (recent_chooser, gtk_recent_chooser_get_show_not_found (action_chooser)); else if (strcmp (property_name, "show-tips") == 0) gtk_recent_chooser_set_show_tips (recent_chooser, gtk_recent_chooser_get_show_tips (action_chooser)); else if (strcmp (property_name, "show-icons") == 0) gtk_recent_chooser_set_show_icons (recent_chooser, gtk_recent_chooser_get_show_icons (action_chooser)); else if (strcmp (property_name, "limit") == 0) gtk_recent_chooser_set_limit (recent_chooser, gtk_recent_chooser_get_limit (action_chooser)); else if (strcmp (property_name, "local-only") == 0) gtk_recent_chooser_set_local_only (recent_chooser, gtk_recent_chooser_get_local_only (action_chooser)); else if (strcmp (property_name, "sort-type") == 0) gtk_recent_chooser_set_sort_type (recent_chooser, gtk_recent_chooser_get_sort_type (action_chooser)); else if (strcmp (property_name, "filter") == 0) gtk_recent_chooser_set_filter (recent_chooser, gtk_recent_chooser_get_filter (action_chooser)); }
static GtkRecentManager * gtk_recent_action_get_recent_manager (GtkRecentChooser *chooser) { return GTK_RECENT_ACTION (chooser)->priv->manager; }