From fa65a5177e3045d1ddd3f0c7d60b831a5134d57a Mon Sep 17 00:00:00 2001 From: Jonathan Blandford Date: Fri, 08 Apr 2005 05:28:38 +0000 Subject: Big reworking to make completions work iff we have >= GTK-2.7.0 Fri Apr 8 01:12:24 2005 Jonathan Blandford * shell/ev-page-action.h: * shell/ev-page-action.c: (ev_page_action_widget_init), (ev_page_action_widget_class_init), (page_changed_cb), (create_tool_item), (update_page_cache), (build_new_tree_cb), (get_filter_model_from_model), (match_selected_cb), (display_completion_text), (match_completion), (update_model), (connect_proxy), (ev_page_action_set_property), (ev_page_action_get_property), (ev_page_action_set_document), (ev_page_action_set_model), (ev_page_action_class_init): Big reworking to make completions work iff we have >= GTK-2.7.0 * shell/ev-sidebar-links.c: (ev_sidebar_links_set_property), (ev_sidebar_links_get_property), (ev_sidebar_links_class_init), (job_finished_cb): We now have a 'model' property that is set when the links are loaded. This can be caught with "notify::model" * shell/ev-window.c: (sidebar_widget_model_set), (ev_window_init): listen for the model to be set, and propagate it to the action. --- (limited to 'shell/ev-sidebar-links.c') diff --git a/shell/ev-sidebar-links.c b/shell/ev-sidebar-links.c index 8e85068..e663fc9 100644 --- a/shell/ev-sidebar-links.c +++ b/shell/ev-sidebar-links.c @@ -46,6 +46,11 @@ struct _EvSidebarLinksPrivate { EvPageCache *page_cache; }; +enum { + PROP_0, + PROP_MODEL, +}; + static void links_page_num_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, @@ -72,6 +77,53 @@ ev_sidebar_links_destroy (GtkObject *object) } static void +ev_sidebar_links_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + EvSidebarLinks *ev_sidebar_links; + GtkTreeModel *model; + + ev_sidebar_links = EV_SIDEBAR_LINKS (object); + + switch (prop_id) + { + case PROP_MODEL: + model = ev_sidebar_links->priv->model; + ev_sidebar_links->priv->model = GTK_TREE_MODEL (g_value_dup_object (value)); + if (model) + g_object_unref (model); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +ev_sidebar_links_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EvSidebarLinks *ev_sidebar_links; + + ev_sidebar_links = EV_SIDEBAR_LINKS (object); + + switch (prop_id) + { + case PROP_MODEL: + g_value_set_object (value, ev_sidebar_links->priv->model); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + + +static void ev_sidebar_links_class_init (EvSidebarLinksClass *ev_sidebar_links_class) { GObjectClass *g_object_class; @@ -80,8 +132,19 @@ ev_sidebar_links_class_init (EvSidebarLinksClass *ev_sidebar_links_class) g_object_class = G_OBJECT_CLASS (ev_sidebar_links_class); gtk_object_class = GTK_OBJECT_CLASS (ev_sidebar_links_class); + g_object_class->set_property = ev_sidebar_links_set_property; + g_object_class->get_property = ev_sidebar_links_get_property; + gtk_object_class->destroy = ev_sidebar_links_destroy; + g_object_class_install_property (g_object_class, + PROP_MODEL, + g_param_spec_object ("model", + "Model", + "Current Model", + GTK_TYPE_TREE_MODEL, + G_PARAM_READWRITE)); + g_type_class_add_private (g_object_class, sizeof (EvSidebarLinksPrivate)); } @@ -335,6 +398,8 @@ job_finished_cb (EvJobLinks *job, priv = sidebar_links->priv; priv->model = g_object_ref (job->model); + g_object_notify (G_OBJECT (sidebar_links), "model"); + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->tree_view), job->model); g_object_unref (job); -- cgit v0.9.1