[evince] shell: Modernize access to private members on ev-zoom-action
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] shell: Modernize access to private members on ev-zoom-action
- Date: Tue, 13 Nov 2018 16:25:34 +0000 (UTC)
commit 683dd799bc4cd6a609e8f4bca6882ee49b3835d2
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Tue Nov 13 12:05:14 2018 -0300
shell: Modernize access to private members on ev-zoom-action
shell/ev-history.c | 111 +++++++++++++++++++++++++++------------------
shell/ev-history.h | 4 --
shell/ev-sidebar.c | 59 ++++++++++++++----------
shell/ev-sidebar.h | 3 --
shell/ev-zoom-action.c | 119 ++++++++++++++++++++++++++++---------------------
shell/ev-zoom-action.h | 3 --
6 files changed, 171 insertions(+), 128 deletions(-)
---
diff --git a/shell/ev-history.c b/shell/ev-history.c
index 182ad08c..e3e03df8 100644
--- a/shell/ev-history.c
+++ b/shell/ev-history.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2005 Marco Pesenti Gritti
+ * Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,7 +36,7 @@ enum {
static guint signals[N_SIGNALS] = {0, };
-struct _EvHistoryPrivate {
+typedef struct {
GList *list;
GList *current;
@@ -43,9 +44,11 @@ struct _EvHistoryPrivate {
gulong page_changed_handler_id;
guint frozen;
-};
+} EvHistoryPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (EvHistory, ev_history, G_TYPE_OBJECT)
-G_DEFINE_TYPE (EvHistory, ev_history, G_TYPE_OBJECT)
+#define GET_PRIVATE(o) ev_history_get_instance_private (o);
static void ev_history_set_model (EvHistory *history,
EvDocumentModel *model);
@@ -59,16 +62,18 @@ clear_list (GList *list)
static void
ev_history_clear (EvHistory *history)
{
- clear_list (history->priv->list);
- history->priv->list = NULL;
+ EvHistoryPrivate *priv = GET_PRIVATE (history);
- history->priv->current = NULL;
+ clear_list (priv->list);
+ priv->list = NULL;
+
+ priv->current = NULL;
}
static void
ev_history_prune (EvHistory *history)
{
- EvHistoryPrivate *priv = history->priv;
+ EvHistoryPrivate *priv = GET_PRIVATE (history);
GList *l;
guint i;
@@ -127,20 +132,19 @@ ev_history_class_init (EvHistoryClass *class)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
-
- g_type_class_add_private (object_class, sizeof (EvHistoryPrivate));
}
static void
ev_history_init (EvHistory *history)
{
- history->priv = G_TYPE_INSTANCE_GET_PRIVATE (history, EV_TYPE_HISTORY, EvHistoryPrivate);
}
gboolean
ev_history_is_frozen (EvHistory *history)
{
- return history->priv->frozen > 0;
+ EvHistoryPrivate *priv = GET_PRIVATE (history);
+
+ return priv->frozen > 0;
}
void
@@ -155,7 +159,7 @@ ev_history_add_link (EvHistory *history,
if (ev_history_is_frozen (history))
return;
- priv = history->priv;
+ priv = GET_PRIVATE (history);
if (priv->current) {
/* Truncate forward history at @current */
@@ -175,12 +179,14 @@ ev_history_add_link (EvHistory *history,
static void
ev_history_activate_current_link (EvHistory *history)
{
- g_assert (history->priv->current);
+ EvHistoryPrivate *priv = GET_PRIVATE (history);
+
+ g_assert (priv->current);
ev_history_freeze (history);
- g_signal_handler_block (history->priv->model, history->priv->page_changed_handler_id);
- g_signal_emit (history, signals[ACTIVATE_LINK], 0, history->priv->current->data);
- g_signal_handler_unblock (history->priv->model, history->priv->page_changed_handler_id);
+ g_signal_handler_block (priv->model, priv->page_changed_handler_id);
+ g_signal_emit (history, signals[ACTIVATE_LINK], 0, priv->current->data);
+ g_signal_handler_unblock (priv->model, priv->page_changed_handler_id);
ev_history_thaw (history);
g_signal_emit (history, signals[CHANGED], 0);
@@ -196,7 +202,7 @@ ev_history_can_go_back (EvHistory *history)
if (ev_history_is_frozen (history))
return FALSE;
- priv = history->priv;
+ priv = GET_PRIVATE (history);
return priv->current && priv->current->prev;
}
@@ -210,7 +216,7 @@ ev_history_go_back (EvHistory *history)
if (!ev_history_can_go_back (history))
return;
- priv = history->priv;
+ priv = GET_PRIVATE (history);
/* Move current back one step */
priv->current = priv->current->prev;
@@ -228,7 +234,7 @@ ev_history_can_go_forward (EvHistory *history)
if (ev_history_is_frozen (history))
return FALSE;
- priv = history->priv;
+ priv = GET_PRIVATE (history);
return priv->current && priv->current->next;
}
@@ -242,7 +248,7 @@ ev_history_go_forward (EvHistory *history)
if (!ev_history_can_go_forward (history))
return;
- priv = history->priv;
+ priv = GET_PRIVATE (history);
/* Move current forward one step */
priv->current = priv->current->next;
@@ -282,7 +288,7 @@ ev_history_go_to_link (EvHistory *history,
if (ev_history_is_frozen (history))
return FALSE;
- priv = history->priv;
+ priv = GET_PRIVATE (history);
l = g_list_find_custom (priv->list, link, (GCompareFunc) compare_link);
if (l == NULL)
@@ -310,7 +316,7 @@ ev_history_get_back_list (EvHistory *history)
g_return_val_if_fail (EV_IS_HISTORY (history), NULL);
- priv = history->priv;
+ priv = GET_PRIVATE (history);
if (priv->current == NULL)
return NULL;
@@ -331,40 +337,54 @@ ev_history_get_back_list (EvHistory *history)
GList *
ev_history_get_forward_list (EvHistory *history)
{
+ EvHistoryPrivate *priv;
+
g_return_val_if_fail (EV_IS_HISTORY (history), NULL);
- return g_list_copy (history->priv->current->next);
+ priv = GET_PRIVATE (history);
+
+ return g_list_copy (priv->current->next);
}
void
ev_history_freeze (EvHistory *history)
{
+ EvHistoryPrivate *priv;
+
g_return_if_fail (EV_IS_HISTORY (history));
- history->priv->frozen++;
+ priv = GET_PRIVATE (history);
+
+ priv->frozen++;
}
void
ev_history_thaw (EvHistory *history)
{
+ EvHistoryPrivate *priv;
+
g_return_if_fail (EV_IS_HISTORY (history));
- g_return_if_fail (history->priv->frozen > 0);
- history->priv->frozen--;
+ priv = GET_PRIVATE (history);
+
+ g_return_if_fail (priv->frozen > 0);
+
+ priv->frozen--;
}
static gint
ev_history_get_current_page (EvHistory *history)
{
+ EvHistoryPrivate *priv = GET_PRIVATE (history);
EvLink *link;
EvDocument *document;
EvLinkDest *dest;
EvLinkAction *action;
- if (!history->priv->current)
+ if (!priv->current)
return -1;
- link = history->priv->current->data;
+ link = priv->current->data;
action = ev_link_get_action (link);
if (!action)
return -1;
@@ -375,7 +395,7 @@ ev_history_get_current_page (EvHistory *history)
switch (ev_link_dest_get_dest_type (dest)) {
case EV_LINK_DEST_TYPE_NAMED:
- document = ev_document_model_get_document (history->priv->model);
+ document = ev_document_model_get_document (priv->model);
if (!EV_IS_DOCUMENT_LINKS (document))
return -1;
@@ -384,7 +404,7 @@ ev_history_get_current_page (EvHistory *history)
case EV_LINK_DEST_TYPE_PAGE_LABEL: {
gint page = -1;
- document = ev_document_model_get_document (history->priv->model);
+ document = ev_document_model_get_document (priv->model);
ev_document_find_page_by_label (document,
ev_link_dest_get_page_label (dest),
&page);
@@ -402,6 +422,7 @@ static void
ev_history_add_link_for_page (EvHistory *history,
gint page)
{
+ EvHistoryPrivate *priv = GET_PRIVATE (history);
EvDocument *document;
EvLinkDest *dest;
EvLinkAction *action;
@@ -415,7 +436,7 @@ ev_history_add_link_for_page (EvHistory *history,
if (ev_history_get_current_page (history) == page)
return;
- document = ev_document_model_get_document (history->priv->model);
+ document = ev_document_model_get_document (priv->model);
if (!document)
return;
@@ -461,32 +482,34 @@ static void
ev_history_set_model (EvHistory *history,
EvDocumentModel *model)
{
- if (history->priv->model == model)
+ EvHistoryPrivate *priv = GET_PRIVATE (history);
+
+ if (priv->model == model)
return;
- if (history->priv->model) {
- g_object_remove_weak_pointer (G_OBJECT (history->priv->model),
- (gpointer)&history->priv->model);
+ if (priv->model) {
+ g_object_remove_weak_pointer (G_OBJECT (priv->model),
+ (gpointer)&priv->model);
- if (history->priv->page_changed_handler_id) {
- g_signal_handler_disconnect (history->priv->model,
- history->priv->page_changed_handler_id);
- history->priv->page_changed_handler_id = 0;
+ if (priv->page_changed_handler_id) {
+ g_signal_handler_disconnect (priv->model,
+ priv->page_changed_handler_id);
+ priv->page_changed_handler_id = 0;
}
}
- history->priv->model = model;
+ priv->model = model;
if (!model)
return;
g_object_add_weak_pointer (G_OBJECT (model),
- (gpointer)&history->priv->model);
+ (gpointer)&priv->model);
- g_signal_connect (history->priv->model, "notify::document",
+ g_signal_connect (priv->model, "notify::document",
G_CALLBACK (document_changed_cb),
history);
- history->priv->page_changed_handler_id =
- g_signal_connect (history->priv->model, "page-changed",
+ priv->page_changed_handler_id =
+ g_signal_connect (priv->model, "page-changed",
G_CALLBACK (page_changed_cb),
history);
}
diff --git a/shell/ev-history.h b/shell/ev-history.h
index f3d6f89b..62bbb892 100644
--- a/shell/ev-history.h
+++ b/shell/ev-history.h
@@ -34,15 +34,11 @@ G_BEGIN_DECLS
#define EV_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EV_TYPE_HISTORY, EvHistoryClass))
typedef struct _EvHistory EvHistory;
-typedef struct _EvHistoryPrivate EvHistoryPrivate;
typedef struct _EvHistoryClass EvHistoryClass;
struct _EvHistory
{
GObject parent;
-
- /*< private >*/
- EvHistoryPrivate *priv;
};
struct _EvHistoryClass
diff --git a/shell/ev-sidebar.c b/shell/ev-sidebar.c
index 412d3bf1..a053c0df 100644
--- a/shell/ev-sidebar.c
+++ b/shell/ev-sidebar.c
@@ -52,27 +52,27 @@ enum
PAGE_COLUMN_NUM_COLS
};
-struct _EvSidebarPrivate {
+typedef struct {
GtkWidget *stack;
GtkWidget *switcher;
EvDocumentModel *model;
GtkTreeModel *page_model;
-};
+} EvSidebarPrivate;
-G_DEFINE_TYPE (EvSidebar, ev_sidebar, GTK_TYPE_BOX)
+G_DEFINE_TYPE_WITH_PRIVATE (EvSidebar, ev_sidebar, GTK_TYPE_BOX)
-#define EV_SIDEBAR_GET_PRIVATE(object) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR, EvSidebarPrivate))
+#define GET_PRIVATE(o) ev_sidebar_get_instance_private (o)
static void
ev_sidebar_dispose (GObject *object)
{
EvSidebar *ev_sidebar = EV_SIDEBAR (object);
+ EvSidebarPrivate *priv = GET_PRIVATE (ev_sidebar);
- if (ev_sidebar->priv->page_model) {
- g_object_unref (ev_sidebar->priv->page_model);
- ev_sidebar->priv->page_model = NULL;
+ if (priv->page_model) {
+ g_object_unref (priv->page_model);
+ priv->page_model = NULL;
}
G_OBJECT_CLASS (ev_sidebar_parent_class)->dispose (object);
@@ -99,7 +99,9 @@ ev_sidebar_set_property (GObject *object,
static GtkWidget *
ev_sidebar_get_current_page (EvSidebar *ev_sidebar)
{
- return gtk_stack_get_visible_child (GTK_STACK (ev_sidebar->priv->stack));
+ EvSidebarPrivate *priv = GET_PRIVATE (ev_sidebar);
+
+ return gtk_stack_get_visible_child (GTK_STACK (priv->stack));
}
static gchar *
@@ -108,8 +110,9 @@ ev_sidebar_get_visible_icon_name (EvSidebar *ev_sidebar)
GtkStack *stack;
GtkWidget *widget;
gchar *icon_name;
+ EvSidebarPrivate *priv = GET_PRIVATE (ev_sidebar);
- stack = GTK_STACK (ev_sidebar->priv->stack);
+ stack = GTK_STACK (priv->stack);
widget = gtk_stack_get_visible_child (stack);
gtk_container_child_get (GTK_CONTAINER (stack), widget,
"icon-name", &icon_name,
@@ -147,8 +150,6 @@ ev_sidebar_class_init (EvSidebarClass *ev_sidebar_class)
{
GObjectClass *g_object_class = G_OBJECT_CLASS (ev_sidebar_class);
- g_type_class_add_private (g_object_class, sizeof (EvSidebarPrivate));
-
g_object_class->dispose = ev_sidebar_dispose;
g_object_class->get_property = ev_sidebar_get_property;
g_object_class->set_property = ev_sidebar_set_property;
@@ -176,7 +177,8 @@ ev_sidebar_child_change_cb (GObject *gobject,
GParamSpec *pspec,
EvSidebar *ev_sidebar)
{
- GtkStack *stack = GTK_STACK (ev_sidebar->priv->stack);
+ EvSidebarPrivate *priv = GET_PRIVATE (ev_sidebar);
+ GtkStack *stack = GTK_STACK (priv->stack);
const gchar *name;
name = gtk_stack_get_visible_child_name (stack);
@@ -187,13 +189,14 @@ ev_sidebar_child_change_cb (GObject *gobject,
static void
ev_sidebar_init (EvSidebar *ev_sidebar)
{
+ EvSidebarPrivate *priv;
GtkWidget *switcher;
GtkWidget *stack;
- ev_sidebar->priv = EV_SIDEBAR_GET_PRIVATE (ev_sidebar);
+ priv = GET_PRIVATE (ev_sidebar);
/* data model */
- ev_sidebar->priv->page_model = (GtkTreeModel *)
+ priv->page_model = (GtkTreeModel *)
gtk_list_store_new (PAGE_COLUMN_NUM_COLS,
G_TYPE_STRING,
GTK_TYPE_WIDGET,
@@ -201,22 +204,22 @@ ev_sidebar_init (EvSidebar *ev_sidebar)
G_TYPE_STRING);
switcher = gtk_stack_switcher_new ();
- ev_sidebar->priv->switcher = switcher;
+ priv->switcher = switcher;
gtk_box_pack_end (GTK_BOX (ev_sidebar), switcher, FALSE, TRUE, 0);
g_object_set (switcher, "icon-size", 1, NULL);
gtk_container_set_border_width (GTK_CONTAINER (switcher), 6);
gtk_widget_set_halign (switcher, GTK_ALIGN_FILL);
gtk_widget_set_hexpand (switcher, TRUE);
gtk_box_set_homogeneous (GTK_BOX (switcher), TRUE);
- gtk_widget_show (ev_sidebar->priv->switcher);
+ gtk_widget_show (priv->switcher);
stack = gtk_stack_new ();
- ev_sidebar->priv->stack = stack;
+ priv->stack = stack;
gtk_stack_set_homogeneous (GTK_STACK (stack), TRUE);
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher),
GTK_STACK (stack));
gtk_box_pack_end (GTK_BOX (ev_sidebar), stack, TRUE, TRUE, 0);
- gtk_widget_show (ev_sidebar->priv->stack);
+ gtk_widget_show (priv->stack);
g_signal_connect (stack, "notify::visible-child",
G_CALLBACK (ev_sidebar_child_change_cb),
@@ -238,7 +241,7 @@ ev_sidebar_document_changed_cb (EvDocumentModel *model,
GParamSpec *pspec,
EvSidebar *ev_sidebar)
{
- EvSidebarPrivate *priv = ev_sidebar->priv;
+ EvSidebarPrivate *priv = GET_PRIVATE (ev_sidebar);
EvDocument *document = ev_document_model_get_document (model);
GtkTreeIter iter;
gboolean valid;
@@ -315,7 +318,7 @@ ev_sidebar_add_page (EvSidebar *ev_sidebar,
g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
g_return_if_fail (GTK_IS_WIDGET (widget));
- priv = ev_sidebar->priv;
+ priv = GET_PRIVATE (ev_sidebar);
ev_sidebar_page_set_model (EV_SIDEBAR_PAGE (widget), priv->model);
@@ -341,13 +344,17 @@ void
ev_sidebar_set_model (EvSidebar *ev_sidebar,
EvDocumentModel *model)
{
+ EvSidebarPrivate *priv;
+
g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
g_return_if_fail (EV_IS_DOCUMENT_MODEL (model));
- if (model == ev_sidebar->priv->model)
+ priv = GET_PRIVATE (ev_sidebar);
+
+ if (model == priv->model)
return;
- ev_sidebar->priv->model = model;
+ priv->model = model;
g_signal_connect (model, "notify::document",
G_CALLBACK (ev_sidebar_document_changed_cb),
@@ -358,10 +365,14 @@ void
ev_sidebar_set_page (EvSidebar *ev_sidebar,
GtkWidget *main_widget)
{
+ EvSidebarPrivate *priv;
+
g_return_if_fail (EV_IS_SIDEBAR (ev_sidebar));
g_return_if_fail (GTK_IS_WIDGET (main_widget));
- gtk_stack_set_visible_child (GTK_STACK (ev_sidebar->priv->stack),
+ priv = GET_PRIVATE (ev_sidebar);
+
+ gtk_stack_set_visible_child (GTK_STACK (priv->stack),
main_widget);
g_object_notify (G_OBJECT (ev_sidebar), "current-page");
}
diff --git a/shell/ev-sidebar.h b/shell/ev-sidebar.h
index d4cda917..d8ad90f1 100644
--- a/shell/ev-sidebar.h
+++ b/shell/ev-sidebar.h
@@ -34,7 +34,6 @@ G_BEGIN_DECLS
typedef struct _EvSidebar EvSidebar;
typedef struct _EvSidebarClass EvSidebarClass;
-typedef struct _EvSidebarPrivate EvSidebarPrivate;
#define EV_TYPE_SIDEBAR (ev_sidebar_get_type())
#define EV_SIDEBAR(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_SIDEBAR, EvSidebar))
@@ -45,8 +44,6 @@ typedef struct _EvSidebarPrivate EvSidebarPrivate;
struct _EvSidebar {
GtkBox base_instance;
-
- EvSidebarPrivate *priv;
};
struct _EvSidebarClass {
diff --git a/shell/ev-zoom-action.c b/shell/ev-zoom-action.c
index c6ef0af3..91f4c4c7 100644
--- a/shell/ev-zoom-action.c
+++ b/shell/ev-zoom-action.c
@@ -2,6 +2,7 @@
* this file is part of evince, a gnome document viewer
*
* Copyright (C) 2012 Carlos Garcia Campos <carlosgc gnome org>
+ * Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
*
* Evince is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
@@ -61,7 +62,7 @@ static const struct {
{ N_("6400%"), 64.0 }
};
-struct _EvZoomActionPrivate {
+typedef struct {
GtkWidget *entry;
EvDocumentModel *model;
@@ -70,9 +71,11 @@ struct _EvZoomActionPrivate {
GMenuModel *zoom_free_section;
GtkPopover *popup;
gboolean popup_shown;
-};
+} EvZoomActionPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (EvZoomAction, ev_zoom_action, GTK_TYPE_BOX)
-G_DEFINE_TYPE (EvZoomAction, ev_zoom_action, GTK_TYPE_BOX)
+#define GET_PRIVATE(o) ev_zoom_action_get_instance_private (o)
static guint signals[LAST_SIGNAL] = { 0 };
@@ -82,13 +85,14 @@ static void
ev_zoom_action_set_zoom_level (EvZoomAction *zoom_action,
float zoom)
{
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
gchar *zoom_str;
float zoom_perc;
guint i;
for (i = 0; i < G_N_ELEMENTS (zoom_levels); i++) {
if (ABS (zoom - zoom_levels[i].level) < EPSILON) {
- gtk_entry_set_text (GTK_ENTRY (zoom_action->priv->entry),
+ gtk_entry_set_text (GTK_ENTRY (priv->entry),
zoom_levels[i].name);
return;
}
@@ -99,14 +103,16 @@ ev_zoom_action_set_zoom_level (EvZoomAction *zoom_action,
zoom_str = g_strdup_printf ("%d%%", (gint)zoom_perc);
else
zoom_str = g_strdup_printf ("%.1f%%", zoom_perc);
- gtk_entry_set_text (GTK_ENTRY (zoom_action->priv->entry), zoom_str);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), zoom_str);
g_free (zoom_str);
}
static void
ev_zoom_action_update_zoom_level (EvZoomAction *zoom_action)
{
- float zoom = ev_document_model_get_scale (zoom_action->priv->model);
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
+
+ float zoom = ev_document_model_get_scale (priv->model);
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (zoom_action));
zoom *= 72.0 / ev_document_misc_get_screen_dpi (screen);
@@ -141,18 +147,21 @@ static void
ev_zoom_action_set_width_chars (EvZoomAction *zoom_action,
gint width)
{
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
+
/* width + 2 (one decimals and the comma) + 3 (for the icon) */
- gtk_entry_set_width_chars (GTK_ENTRY (zoom_action->priv->entry), width + 2 + 3);
+ gtk_entry_set_width_chars (GTK_ENTRY (priv->entry), width + 2 + 3);
}
static void
ev_zoom_action_populate_free_zoom_section (EvZoomAction *zoom_action)
{
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
gdouble max_scale;
guint i;
gint width = 0;
- max_scale = ev_document_model_get_max_scale (zoom_action->priv->model);
+ max_scale = ev_document_model_get_max_scale (priv->model);
for (i = 0; i < G_N_ELEMENTS (zoom_levels); i++) {
GMenuItem *item;
@@ -168,7 +177,7 @@ ev_zoom_action_populate_free_zoom_section (EvZoomAction *zoom_action)
item = g_menu_item_new (zoom_levels[i].name, NULL);
g_menu_item_set_action_and_target (item, "win.zoom",
"d", zoom_levels[i].level);
- g_menu_append_item (G_MENU (zoom_action->priv->zoom_free_section), item);
+ g_menu_append_item (G_MENU (priv->zoom_free_section), item);
g_object_unref (item);
}
@@ -180,8 +189,10 @@ max_zoom_changed_cb (EvDocumentModel *model,
GParamSpec *pspec,
EvZoomAction *zoom_action)
{
- g_menu_remove_all (G_MENU (zoom_action->priv->zoom_free_section));
- g_clear_pointer (&zoom_action->priv->popup, (GDestroyNotify)gtk_widget_destroy);
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
+
+ g_menu_remove_all (G_MENU (priv->zoom_free_section));
+ g_clear_pointer (&priv->popup, (GDestroyNotify)gtk_widget_destroy);
ev_zoom_action_populate_free_zoom_section (zoom_action);
}
@@ -189,6 +200,8 @@ static void
entry_activated_cb (GtkEntry *entry,
EvZoomAction *zoom_action)
{
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
+
GdkScreen *screen;
double zoom_perc;
float zoom;
@@ -210,8 +223,8 @@ entry_activated_cb (GtkEntry *entry,
screen = gtk_widget_get_screen (GTK_WIDGET (zoom_action));
zoom = zoom_perc / 100.;
- ev_document_model_set_sizing_mode (zoom_action->priv->model, EV_SIZING_FREE);
- ev_document_model_set_scale (zoom_action->priv->model,
+ ev_document_model_set_sizing_mode (priv->model, EV_SIZING_FREE);
+ ev_document_model_set_scale (priv->model,
zoom * ev_document_misc_get_screen_dpi (screen) / 72.0);
g_signal_emit (zoom_action, signals[ACTIVATED], 0, NULL);
}
@@ -228,32 +241,35 @@ static void
popup_menu_closed (GtkPopover *popup,
EvZoomAction *zoom_action)
{
- if (zoom_action->priv->popup != popup)
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
+
+ if (priv->popup != popup)
return;
- zoom_action->priv->popup_shown = FALSE;
- zoom_action->priv->popup = NULL;
+ priv->popup_shown = FALSE;
+ priv->popup = NULL;
}
static GtkPopover *
get_popup (EvZoomAction *zoom_action)
{
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
GdkRectangle rect;
- if (zoom_action->priv->popup)
- return zoom_action->priv->popup;
+ if (priv->popup)
+ return priv->popup;
- zoom_action->priv->popup = GTK_POPOVER (gtk_popover_new_from_model (GTK_WIDGET (zoom_action),
- G_MENU_MODEL
(zoom_action->priv->menu)));
- g_signal_connect (zoom_action->priv->popup, "closed",
+ priv->popup = GTK_POPOVER (gtk_popover_new_from_model (GTK_WIDGET (zoom_action),
+ G_MENU_MODEL (priv->menu)));
+ g_signal_connect (priv->popup, "closed",
G_CALLBACK (popup_menu_closed),
zoom_action);
- gtk_entry_get_icon_area (GTK_ENTRY (zoom_action->priv->entry),
+ gtk_entry_get_icon_area (GTK_ENTRY (priv->entry),
GTK_ENTRY_ICON_SECONDARY, &rect);
- gtk_popover_set_pointing_to (zoom_action->priv->popup, &rect);
- gtk_popover_set_position (zoom_action->priv->popup, GTK_POS_BOTTOM);
+ gtk_popover_set_pointing_to (priv->popup, &rect);
+ gtk_popover_set_position (priv->popup, GTK_POS_BOTTOM);
- return zoom_action->priv->popup;
+ return priv->popup;
}
static void
@@ -262,6 +278,7 @@ entry_icon_press_callback (GtkEntry *entry,
GdkEvent *event,
EvZoomAction *zoom_action)
{
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
guint button = 0;
if (gdk_event_get_button (event, &button) &&
@@ -269,21 +286,22 @@ entry_icon_press_callback (GtkEntry *entry,
return;
gtk_popover_popup (get_popup (zoom_action));
- zoom_action->priv->popup_shown = TRUE;
+ priv->popup_shown = TRUE;
}
static void
ev_zoom_action_finalize (GObject *object)
{
EvZoomAction *zoom_action = EV_ZOOM_ACTION (object);
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
- if (zoom_action->priv->model) {
- g_object_remove_weak_pointer (G_OBJECT (zoom_action->priv->model),
- (gpointer)&zoom_action->priv->model);
+ if (priv->model) {
+ g_object_remove_weak_pointer (G_OBJECT (priv->model),
+ (gpointer)&priv->model);
}
- g_clear_object (&zoom_action->priv->menu);
- g_clear_object (&zoom_action->priv->zoom_free_section);
+ g_clear_object (&priv->menu);
+ g_clear_object (&priv->zoom_free_section);
G_OBJECT_CLASS (ev_zoom_action_parent_class)->finalize (object);
}
@@ -295,13 +313,14 @@ ev_zoom_action_set_property (GObject *object,
GParamSpec *pspec)
{
EvZoomAction *zoom_action = EV_ZOOM_ACTION (object);
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
switch (prop_id) {
case PROP_DOCUMENT_MODEL:
- zoom_action->priv->model = g_value_get_object (value);
+ priv->model = g_value_get_object (value);
break;
case PROP_MENU:
- zoom_action->priv->menu = g_value_dup_object (value);
+ priv->menu = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -332,30 +351,31 @@ static void
ev_zoom_action_constructed (GObject *object)
{
EvZoomAction *zoom_action = EV_ZOOM_ACTION (object);
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
G_OBJECT_CLASS (ev_zoom_action_parent_class)->constructed (object);
- zoom_action->priv->zoom_free_section =
- g_menu_model_get_item_link (G_MENU_MODEL (zoom_action->priv->menu),
+ priv->zoom_free_section =
+ g_menu_model_get_item_link (G_MENU_MODEL (priv->menu),
ZOOM_FREE_SECTION, G_MENU_LINK_SECTION);
ev_zoom_action_populate_free_zoom_section (zoom_action);
- g_object_add_weak_pointer (G_OBJECT (zoom_action->priv->model),
- (gpointer)&zoom_action->priv->model);
- if (ev_document_model_get_document (zoom_action->priv->model)) {
+ g_object_add_weak_pointer (G_OBJECT (priv->model),
+ (gpointer)&priv->model);
+ if (ev_document_model_get_document (priv->model)) {
ev_zoom_action_update_zoom_level (zoom_action);
} else {
ev_zoom_action_set_zoom_level (zoom_action, 1.);
gtk_widget_set_sensitive (GTK_WIDGET (zoom_action), FALSE);
}
- g_signal_connect_object (zoom_action->priv->model, "notify::document",
+ g_signal_connect_object (priv->model, "notify::document",
G_CALLBACK (document_changed_cb),
zoom_action, 0);
- g_signal_connect_object (zoom_action->priv->model, "notify::scale",
+ g_signal_connect_object (priv->model, "notify::scale",
G_CALLBACK (zoom_changed_cb),
zoom_action, 0);
- g_signal_connect_object (zoom_action->priv->model, "notify::max-scale",
+ g_signal_connect_object (priv->model, "notify::max-scale",
G_CALLBACK (max_zoom_changed_cb),
zoom_action, 0);
@@ -401,17 +421,12 @@ ev_zoom_action_class_init (EvZoomActionClass *klass)
0, NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
-
- g_type_class_add_private (object_class, sizeof (EvZoomActionPrivate));
}
static void
ev_zoom_action_init (EvZoomAction *zoom_action)
{
- EvZoomActionPrivate *priv;
-
- zoom_action->priv = G_TYPE_INSTANCE_GET_PRIVATE (zoom_action, EV_TYPE_ZOOM_ACTION,
EvZoomActionPrivate);
- priv = zoom_action->priv;
+ EvZoomActionPrivate *priv = GET_PRIVATE (zoom_action);
gtk_orientable_set_orientation (GTK_ORIENTABLE (zoom_action), GTK_ORIENTATION_VERTICAL);
@@ -448,9 +463,13 @@ ev_zoom_action_new (EvDocumentModel *model,
}
gboolean
-ev_zoom_action_get_popup_shown (EvZoomAction *action)
+ev_zoom_action_get_popup_shown (EvZoomAction *zoom_action)
{
- g_return_val_if_fail (EV_IS_ZOOM_ACTION (action), FALSE);
+ EvZoomActionPrivate *priv;
+
+ g_return_val_if_fail (EV_IS_ZOOM_ACTION (zoom_action), FALSE);
+
+ priv = GET_PRIVATE (zoom_action);
- return action->priv->popup_shown;
+ return priv->popup_shown;
}
diff --git a/shell/ev-zoom-action.h b/shell/ev-zoom-action.h
index 8da4ff8a..0d962176 100644
--- a/shell/ev-zoom-action.h
+++ b/shell/ev-zoom-action.h
@@ -36,12 +36,9 @@ G_BEGIN_DECLS
typedef struct _EvZoomAction EvZoomAction;
typedef struct _EvZoomActionClass EvZoomActionClass;
-typedef struct _EvZoomActionPrivate EvZoomActionPrivate;
struct _EvZoomAction {
GtkBox parent;
-
- EvZoomActionPrivate *priv;
};
struct _EvZoomActionClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]