From: Nickolay V. Shmyrev Date: Sat, 27 May 2006 11:25:00 +0000 (+0000) Subject: Fix page-label command line option. Bug #342070. X-Git-Tag: EVINCE_0_5_4~48 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=872101b786854841e6b32cac322f08d3dde6b946;p=evince.git Fix page-label command line option. Bug #342070. * backend/ev-link-dest.c: (ev_link_dest_type_get_type), (ev_link_dest_get_page_label), (ev_link_dest_get_property), (ev_link_dest_set_property), (ev_link_dest_finalize), (ev_link_dest_class_init), (ev_link_dest_new_named), (ev_link_dest_new_page_label): * backend/ev-link-dest.h: * shell/ev-application.c: (ev_application_open_uri): * shell/ev-view.c: (goto_dest): * shell/ev-window.c: * shell/ev-window.h: Fix page-label command line option. Bug #342070. --- diff --git a/ChangeLog b/ChangeLog index 47e86c0b..0e08e1b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2006-05-27 Nickolay V. Shmyrev + + * backend/ev-link-dest.c: (ev_link_dest_type_get_type), + (ev_link_dest_get_page_label), (ev_link_dest_get_property), + (ev_link_dest_set_property), (ev_link_dest_finalize), + (ev_link_dest_class_init), (ev_link_dest_new_named), + (ev_link_dest_new_page_label): + * backend/ev-link-dest.h: + * shell/ev-application.c: (ev_application_open_uri): + * shell/ev-view.c: (goto_dest): + * shell/ev-window.c: + * shell/ev-window.h: + + Fix page-label command line option. Bug #342070. + 2006-05-27 Ricardo Markiewicz * shell/ev-view.c: (ev_view_expose_event), (draw_one_page): diff --git a/backend/ev-link-dest.c b/backend/ev-link-dest.c index 2fd2f4d5..09f840af 100644 --- a/backend/ev-link-dest.c +++ b/backend/ev-link-dest.c @@ -29,7 +29,8 @@ enum { PROP_BOTTOM, PROP_RIGHT, PROP_ZOOM, - PROP_NAMED + PROP_NAMED, + PROP_PAGE_LABEL }; struct _EvLinkDest { @@ -51,6 +52,7 @@ struct _EvLinkDestPrivate { double right; double zoom; gchar *named; + gchar *page_label; }; G_DEFINE_TYPE (EvLinkDest, ev_link_dest, G_TYPE_OBJECT) @@ -72,6 +74,7 @@ ev_link_dest_type_get_type (void) { EV_LINK_DEST_TYPE_FITV, "EV_LINK_DEST_TYPE_FITV", "fitv" }, { EV_LINK_DEST_TYPE_FITR, "EV_LINK_DEST_TYPE_FITR", "fitr" }, { EV_LINK_DEST_TYPE_NAMED, "EV_LINK_DEST_TYPE_NAMED", "named" }, + { EV_LINK_DEST_TYPE_PAGE_LABEL, "EV_LINK_DEST_TYPE_PAGE_LABEL", "page_label" }, { EV_LINK_DEST_TYPE_UNKNOWN, "EV_LINK_DEST_TYPE_UNKNOWN", "unknown" }, { 0, NULL, NULL } }; @@ -146,6 +149,14 @@ ev_link_dest_get_named_dest (EvLinkDest *self) return self->priv->named; } +const gchar * +ev_link_dest_get_page_label (EvLinkDest *self) +{ + g_return_val_if_fail (EV_IS_LINK_DEST (self), NULL); + + return self->priv->page_label; +} + static void ev_link_dest_get_property (GObject *object, guint prop_id, @@ -181,6 +192,9 @@ ev_link_dest_get_property (GObject *object, case PROP_NAMED: g_value_set_string (value, self->priv->named); break; + case PROP_PAGE_LABEL: + g_value_set_string (value, self->priv->page_label); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, @@ -222,6 +236,9 @@ ev_link_dest_set_property (GObject *object, case PROP_NAMED: self->priv->named = g_value_dup_string (value); break; + case PROP_PAGE_LABEL: + self->priv->page_label = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, @@ -241,6 +258,10 @@ ev_link_dest_finalize (GObject *object) g_free (priv->named); priv->named = NULL; } + if (priv->page_label) { + g_free (priv->page_label); + priv->page_label = NULL; + } G_OBJECT_CLASS (ev_link_dest_parent_class)->finalize (object); } @@ -345,6 +366,14 @@ ev_link_dest_class_init (EvLinkDestClass *ev_link_dest_class) NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property (g_object_class, + PROP_PAGE_LABEL, + g_param_spec_string ("page_label", + "Label of the page", + "The label of the destination page", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); } EvLinkDest * @@ -427,3 +456,12 @@ ev_link_dest_new_named (const gchar *named_dest) "type", EV_LINK_DEST_TYPE_NAMED, NULL)); } + +EvLinkDest * +ev_link_dest_new_page_label (const gchar *page_label) +{ + return EV_LINK_DEST (g_object_new (EV_TYPE_LINK_DEST, + "page_label", page_label, + "type", EV_LINK_DEST_TYPE_PAGE_LABEL, + NULL)); +} diff --git a/backend/ev-link-dest.h b/backend/ev-link-dest.h index 40a8a9b0..a0c96f58 100644 --- a/backend/ev-link-dest.h +++ b/backend/ev-link-dest.h @@ -46,6 +46,7 @@ typedef enum { EV_LINK_DEST_TYPE_FITV, EV_LINK_DEST_TYPE_FITR, EV_LINK_DEST_TYPE_NAMED, + EV_LINK_DEST_TYPE_PAGE_LABEL, EV_LINK_DEST_TYPE_UNKNOWN } EvLinkDestType; @@ -60,6 +61,7 @@ gdouble ev_link_dest_get_bottom (EvLinkDest *self); gdouble ev_link_dest_get_right (EvLinkDest *self); gdouble ev_link_dest_get_zoom (EvLinkDest *self); const gchar *ev_link_dest_get_named_dest (EvLinkDest *self); +const gchar *ev_link_dest_get_page_label (EvLinkDest *self); EvLinkDest *ev_link_dest_new_page (gint page); EvLinkDest *ev_link_dest_new_xyz (gint page, @@ -77,6 +79,7 @@ EvLinkDest *ev_link_dest_new_fitr (gint page, gdouble right, gdouble top); EvLinkDest *ev_link_dest_new_named (const gchar *named_dest); +EvLinkDest *ev_link_dest_new_page_label (const gchar *page_label); G_END_DECLS diff --git a/shell/ev-application.c b/shell/ev-application.c index 01bf5a2f..381b4e36 100644 --- a/shell/ev-application.c +++ b/shell/ev-application.c @@ -278,13 +278,16 @@ ev_application_open_uri (EvApplication *application, guint timestamp, GError **error) { - ev_application_open_uri_at_dest (application, uri, NULL, timestamp); if (page_label && strcmp (page_label, "") != 0) { - EvWindow *window; - - window = ev_application_get_uri_window (application, uri); - ev_window_open_page_label (window, page_label); + EvLinkDest *dest; + + dest = ev_link_dest_new_page_label (page_label); + + ev_application_open_uri_at_dest (application, uri, dest, timestamp); + g_object_unref (dest); + } else { + ev_application_open_uri_at_dest (application, uri, NULL, timestamp); } return TRUE; diff --git a/shell/ev-view.c b/shell/ev-view.c index d883ecf0..32ba7c3e 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -1237,6 +1237,9 @@ goto_dest (EvView *view, EvLinkDest *dest) case EV_LINK_DEST_TYPE_XYZ: goto_xyz_dest (view, dest); break; + case EV_LINK_DEST_TYPE_PAGE_LABEL: + ev_page_cache_set_page_label (view->page_cache, ev_link_dest_get_page_label (dest)); + break; default: g_assert_not_reached (); } diff --git a/shell/ev-window.c b/shell/ev-window.c index 29b6a039..1131b35c 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -516,16 +516,6 @@ update_sizing_buttons (EvWindow *window) } } -void -ev_window_open_page_label (EvWindow *ev_window, - const char *label) -{ - if (ev_window->priv->page_cache) { - ev_page_cache_set_page_label (ev_window->priv->page_cache, - label); - } -} - gboolean ev_window_is_empty (const EvWindow *ev_window) { diff --git a/shell/ev-window.h b/shell/ev-window.h index 2551073e..e54a62ee 100644 --- a/shell/ev-window.h +++ b/shell/ev-window.h @@ -59,8 +59,6 @@ void ev_window_open_uri (EvWindow *ev_window, EvLinkDest *dest); void ev_window_goto_dest (EvWindow *ev_window, EvLinkDest *dest); -void ev_window_open_page_label (EvWindow *ev_window, - const char *label); gboolean ev_window_is_empty (const EvWindow *ev_window); #ifdef WITH_GNOME_PRINT void ev_window_print_range (EvWindow *ev_window,