Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-history-action.c File Reference
#include "config.h"
#include "ev-history-action.h"
#include <glib/gi18n.h>
+ Include dependency graph for ev-history-action.c:

Go to the source code of this file.

Data Structures

struct  _EvHistoryActionPrivate
 

Enumerations

enum  { PROP_0, PROP_HISTORY }
 
enum  EvHistoryActionButton { EV_HISTORY_ACTION_BUTTON_BACK, EV_HISTORY_ACTION_BUTTON_FORWARD }
 

Functions

static void history_menu_link_activated (GtkMenuItem *item, EvHistoryAction *history_action)
 
static void popup_menu_hide_cb (GtkMenu *menu, EvHistoryAction *history_action)
 
static void ev_history_action_show_popup (EvHistoryAction *history_action, EvHistoryActionButton action_button, guint button, guint32 event_time)
 
static void ev_history_action_finalize (GObject *object)
 
static void ev_history_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 
static void ev_history_action_constructed (GObject *object)
 
static void ev_history_action_class_init (EvHistoryActionClass *class)
 
static gboolean button_pressed (GtkWidget *button, GdkEventButton *event, EvHistoryAction *history_action)
 
static GtkWidget * ev_history_action_create_button (EvHistoryAction *history_action, EvHistoryActionButton action_button)
 
static void ev_history_action_init (EvHistoryAction *history_action)
 
GtkWidget * ev_history_action_new (EvHistory *history)
 
gboolean ev_history_action_get_popup_shown (EvHistoryAction *action)
 

Enumeration Type Documentation

anonymous enum
Enumerator
PROP_0 
PROP_HISTORY 

Definition at line 26 of file ev-history-action.c.

26  {
27  PROP_0,
28 
30 };
Enumerator
EV_HISTORY_ACTION_BUTTON_BACK 
EV_HISTORY_ACTION_BUTTON_FORWARD 

Definition at line 32 of file ev-history-action.c.

Function Documentation

static gboolean button_pressed ( GtkWidget *  button,
GdkEventButton *  event,
EvHistoryAction history_action 
)
static

Definition at line 180 of file ev-history-action.c.

183 {
184  EvHistoryActionPrivate *priv = history_action->priv;
185 
186  /* TODO: Show the popup menu after a long press too */
187  switch (event->button) {
188  case GDK_BUTTON_SECONDARY:
189  ev_history_action_show_popup (history_action,
190  button == priv->back_button ?
193  event->button, event->time);
194  return GDK_EVENT_STOP;
195  default:
196  break;
197  }
198 
199  return GDK_EVENT_PROPAGATE;
200 }

+ Here is the caller graph for this function:

static void ev_history_action_class_init ( EvHistoryActionClass class)
static

Definition at line 158 of file ev-history-action.c.

159 {
160  GObjectClass *object_class = G_OBJECT_CLASS (class);
161 
162  object_class->constructed = ev_history_action_constructed;
163  object_class->finalize = ev_history_action_finalize;
164  object_class->set_property = ev_history_action_set_property;
165 
166  g_object_class_install_property (object_class,
167  PROP_HISTORY,
168  g_param_spec_object ("history",
169  "History",
170  "The History",
172  G_PARAM_WRITABLE |
173  G_PARAM_CONSTRUCT_ONLY |
174  G_PARAM_STATIC_STRINGS));
175 
176  g_type_class_add_private (object_class, sizeof (EvHistoryActionPrivate));
177 }
static void ev_history_action_constructed ( GObject *  object)
static

Definition at line 147 of file ev-history-action.c.

148 {
149  EvHistoryAction *history_action = EV_HISTORY_ACTION (object);
150 
151  G_OBJECT_CLASS (ev_history_action_parent_class)->constructed (object);
152 
153  g_object_add_weak_pointer (G_OBJECT (history_action->priv->history),
154  (gpointer)&history_action->priv->history);
155 }

+ Here is the caller graph for this function:

static GtkWidget* ev_history_action_create_button ( EvHistoryAction history_action,
EvHistoryActionButton  action_button 
)
static

Definition at line 203 of file ev-history-action.c.

205 {
206  GtkWidget *button;
207  GtkWidget *image;
208  const gchar *icon_name = NULL;
209  const gchar *tooltip_text = NULL;
210  const gchar *action_name = NULL;
211 
212  button = gtk_button_new ();
213  gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
214  g_signal_connect (button, "button-press-event",
215  G_CALLBACK (button_pressed),
216  history_action);
217 
218  switch (action_button) {
220  icon_name = "go-previous-symbolic";
221  tooltip_text = _("Go to previous history item");
222  action_name = "win.go-back-history";
223  break;
225  icon_name = "go-next-symbolic";
226  tooltip_text = _("Go to next history item");
227  action_name = "win.go-forward-history";
228  break;
229  }
230 
231  image = gtk_image_new ();
232  gtk_actionable_set_action_name (GTK_ACTIONABLE (button), action_name);
233  gtk_button_set_image (GTK_BUTTON (button), image);
234  gtk_image_set_from_icon_name (GTK_IMAGE (image), icon_name, GTK_ICON_SIZE_MENU);
235  gtk_widget_set_tooltip_text (button, tooltip_text);
236  gtk_widget_set_can_focus (button, FALSE);
237 
238  return button;
239 }

+ Here is the caller graph for this function:

static void ev_history_action_finalize ( GObject *  object)
static

Definition at line 116 of file ev-history-action.c.

117 {
118  EvHistoryAction *history_action = EV_HISTORY_ACTION (object);
119 
120  if (history_action->priv->history) {
121  g_object_remove_weak_pointer (G_OBJECT (history_action->priv->history),
122  (gpointer)&history_action->priv->history);
123  }
124 
125  G_OBJECT_CLASS (ev_history_action_parent_class)->finalize (object);
126 }

+ Here is the caller graph for this function:

gboolean ev_history_action_get_popup_shown ( EvHistoryAction action)

Definition at line 276 of file ev-history-action.c.

277 {
278  g_return_val_if_fail (EV_IS_HISTORY_ACTION (action), FALSE);
279 
280  return action->priv->popup_shown;
281 }

+ Here is the caller graph for this function:

static void ev_history_action_init ( EvHistoryAction history_action)
static

Definition at line 242 of file ev-history-action.c.

243 {
244  GtkWidget *box = GTK_WIDGET (history_action);
245  GtkStyleContext *style_context;
247 
248  history_action->priv = G_TYPE_INSTANCE_GET_PRIVATE (history_action, EV_TYPE_HISTORY_ACTION, EvHistoryActionPrivate);
249  priv = history_action->priv;
250 
251  gtk_orientable_set_orientation (GTK_ORIENTABLE (box), GTK_ORIENTATION_HORIZONTAL);
252  style_context = gtk_widget_get_style_context (box);
253  gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_RAISED);
254  gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_LINKED);
255 
256  priv->back_button = ev_history_action_create_button (history_action,
258  gtk_container_add (GTK_CONTAINER (box), priv->back_button);
259  gtk_widget_show (priv->back_button);
260 
261  priv->forward_button = ev_history_action_create_button (history_action,
263  gtk_container_add (GTK_CONTAINER (box), priv->forward_button);
264  gtk_widget_show (priv->forward_button);
265 }
GtkWidget* ev_history_action_new ( EvHistory history)

Definition at line 268 of file ev-history-action.c.

269 {
270  g_return_val_if_fail (EV_IS_HISTORY (history), NULL);
271 
272  return GTK_WIDGET (g_object_new (EV_TYPE_HISTORY_ACTION, "history", history, NULL));
273 }

+ Here is the caller graph for this function:

static void ev_history_action_set_property ( GObject *  object,
guint  prop_id,
const GValue *  value,
GParamSpec *  pspec 
)
static

Definition at line 129 of file ev-history-action.c.

133 {
134  EvHistoryAction *history_action = EV_HISTORY_ACTION (object);
135 
136  switch (prop_id) {
137  case PROP_HISTORY:
138  history_action->priv->history = g_value_get_object (value);
139  break;
140  default:
141  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
142  break;
143  }
144 }

+ Here is the caller graph for this function:

static void ev_history_action_show_popup ( EvHistoryAction history_action,
EvHistoryActionButton  action_button,
guint  button,
guint32  event_time 
)
static

Definition at line 68 of file ev-history-action.c.

72 {
73  GtkWidget *menu;
74  GList *list = NULL;
75  GList *l;
76 
77  switch (action_button) {
79  list = ev_history_get_back_list (history_action->priv->history);
80  break;
82  list = ev_history_get_forward_list (history_action->priv->history);
83  break;
84  }
85 
86  if (!list)
87  return;
88 
89  menu = gtk_menu_new ();
90 
91  for (l = list; l; l = g_list_next (l)) {
92  EvLink *link = EV_LINK (l->data);
93  GtkWidget *item;
94 
95  item = gtk_menu_item_new_with_label (ev_link_get_title (link));
96  g_object_set_data_full (G_OBJECT (item), "ev-history-menu-item-link",
97  g_object_ref (link), (GDestroyNotify)g_object_unref);
98  g_signal_connect_object (item, "activate",
99  G_CALLBACK (history_menu_link_activated),
100  history_action, 0);
101  gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
102  gtk_widget_show (item);
103  }
104  g_list_free (list);
105 
106  history_action->priv->popup_shown = TRUE;
107  g_signal_connect (menu, "hide",
108  G_CALLBACK (popup_menu_hide_cb),
109  history_action);
110  gtk_menu_popup (GTK_MENU (menu),
111  NULL, NULL, NULL, NULL,
112  button, event_time);
113 }

+ Here is the caller graph for this function:

static void history_menu_link_activated ( GtkMenuItem *  item,
EvHistoryAction history_action 
)
static

Definition at line 48 of file ev-history-action.c.

50 {
51  EvLink *link;
52 
53  link = EV_LINK (g_object_get_data (G_OBJECT (item), "ev-history-menu-item-link"));
54  if (!link)
55  return;
56 
57  ev_history_go_to_link (history_action->priv->history, link);
58 }

+ Here is the caller graph for this function:

static void popup_menu_hide_cb ( GtkMenu *  menu,
EvHistoryAction history_action 
)
static

Definition at line 61 of file ev-history-action.c.

63 {
64  history_action->priv->popup_shown = FALSE;
65 }

+ Here is the caller graph for this function: