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-password-view.h File Reference
#include <gtk/gtk.h>
#include <gio/gio.h>
+ Include dependency graph for ev-password-view.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _EvPasswordView
 
struct  _EvPasswordViewClass
 

Macros

#define EV_TYPE_PASSWORD_VIEW   (ev_password_view_get_type ())
 
#define EV_PASSWORD_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_PASSWORD_VIEW, EvPasswordView))
 
#define EV_IS_PASSWORD_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EV_TYPE_PASSWORD_VIEW))
 

Typedefs

typedef struct _EvPasswordView EvPasswordView
 
typedef struct _EvPasswordViewClass EvPasswordViewClass
 
typedef struct
_EvPasswordViewPrivate 
EvPasswordViewPrivate
 

Functions

GType ev_password_view_get_type (void) G_GNUC_CONST
 
GtkWidget * ev_password_view_new (GtkWindow *parent)
 
void ev_password_view_set_uri (EvPasswordView *password_view, const char *uri)
 
void ev_password_view_ask_password (EvPasswordView *password_view)
 
const gchar * ev_password_view_get_password (EvPasswordView *password_view)
 
GPasswordSave ev_password_view_get_password_save_flags (EvPasswordView *password_view)
 

Macro Definition Documentation

#define EV_IS_PASSWORD_VIEW (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EV_TYPE_PASSWORD_VIEW))

Definition at line 30 of file ev-password-view.h.

#define EV_PASSWORD_VIEW (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_PASSWORD_VIEW, EvPasswordView))

Definition at line 29 of file ev-password-view.h.

#define EV_TYPE_PASSWORD_VIEW   (ev_password_view_get_type ())

Definition at line 28 of file ev-password-view.h.

Typedef Documentation

Definition at line 32 of file ev-password-view.h.

Definition at line 33 of file ev-password-view.h.

Definition at line 34 of file ev-password-view.h.

Function Documentation

void ev_password_view_ask_password ( EvPasswordView password_view)

Definition at line 239 of file ev-password-view.c.

240 {
241  GtkDialog *dialog;
242  GtkWidget *content_area, *action_area;
243  GtkWidget *entry_container;
244  GtkWidget *hbox, *main_vbox, *vbox, *icon;
245  GtkWidget *grid;
246  GtkWidget *label;
247  gchar *text, *markup, *file_name;
248 
249  gtk_widget_set_sensitive (GTK_WIDGET (password_view), FALSE);
250 
251  dialog = GTK_DIALOG (gtk_dialog_new ());
252  content_area = gtk_dialog_get_content_area (dialog);
253  action_area = gtk_dialog_get_action_area (dialog);
254 
255  /* Set the dialog up with HIG properties */
256  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
257  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
258  gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
259  gtk_box_set_spacing (GTK_BOX (action_area), 6);
260 
261  gtk_window_set_title (GTK_WINDOW (dialog), _("Enter password"));
262  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
263  gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_DIALOG_AUTHENTICATION);
264  gtk_window_set_transient_for (GTK_WINDOW (dialog), password_view->priv->parent_window);
265  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
266 
267  gtk_dialog_add_buttons (dialog,
268  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
269  _("_Unlock Document"), GTK_RESPONSE_OK,
270  NULL);
271  gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
272  gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog),
273  GTK_RESPONSE_OK, FALSE);
274  gtk_dialog_set_alternative_button_order (dialog,
275  GTK_RESPONSE_OK,
276  GTK_RESPONSE_CANCEL,
277  -1);
278 
279  /* Build contents */
280  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
281  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
282  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
283  gtk_widget_show (hbox);
284 
285  icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_AUTHENTICATION,
286  GTK_ICON_SIZE_DIALOG);
287 
288  gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0.0);
289  gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
290  gtk_widget_show (icon);
291 
292  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
293  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
294  gtk_widget_show (main_vbox);
295 
296  label = gtk_label_new (NULL);
297  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
298  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
299  file_name = g_file_get_basename (password_view->priv->uri_file);
300  text = g_markup_printf_escaped (_("The document ā€œ%sā€ is locked and requires a password before it can be opened."),
301  file_name);
302  markup = g_strdup_printf ("<span size=\"larger\" weight=\"bold\">%s</span>\n\n%s",
303  _("Password required"),
304  text);
305  gtk_label_set_markup (GTK_LABEL (label), markup);
306  g_free (text);
307  g_free (markup);
308  g_free (file_name);
309  gtk_box_pack_start (GTK_BOX (main_vbox), label,
310  FALSE, FALSE, 0);
311  gtk_widget_show (label);
312 
313  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
314  gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
315  gtk_widget_show (vbox);
316 
317  /* The table that holds the entries */
318  entry_container = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
319 
320  gtk_alignment_set_padding (GTK_ALIGNMENT (entry_container),
321  0, 0, 0, 0);
322 
323  gtk_box_pack_start (GTK_BOX (vbox), entry_container,
324  FALSE, FALSE, 0);
325  gtk_widget_show (entry_container);
326 
327  grid = gtk_grid_new ();
328  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
329  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
330  gtk_container_add (GTK_CONTAINER (entry_container), grid);
331  gtk_widget_show (grid);
332 
333  label = gtk_label_new_with_mnemonic (_("_Password:"));
334  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
335 
336  password_view->priv->password_entry = gtk_entry_new ();
337  gtk_entry_set_visibility (GTK_ENTRY (password_view->priv->password_entry), FALSE);
338  g_signal_connect (password_view->priv->password_entry, "changed",
340  dialog);
341  g_signal_connect (password_view->priv->password_entry, "activate",
343  dialog);
344  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
345  gtk_widget_show (label);
346 
347  gtk_grid_attach (GTK_GRID (grid), password_view->priv->password_entry, 1, 0, 1, 1);
348  gtk_widget_set_hexpand (password_view->priv->password_entry, TRUE);
349  gtk_widget_show (password_view->priv->password_entry);
350 
351  gtk_label_set_mnemonic_widget (GTK_LABEL (label),
352  password_view->priv->password_entry);
353 
354  if (ev_keyring_is_available ()) {
355  GtkWidget *choice;
356  GtkWidget *remember_box;
357  GSList *group;
358 
359  remember_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
360  gtk_box_pack_start (GTK_BOX (vbox), remember_box,
361  FALSE, FALSE, 0);
362  gtk_widget_show (remember_box);
363 
364  choice = gtk_radio_button_new_with_mnemonic (NULL, _("Forget password _immediately"));
365  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (choice),
366  password_view->priv->password_save == G_PASSWORD_SAVE_NEVER);
367  g_object_set_data (G_OBJECT (choice), "password-save",
368  GINT_TO_POINTER (G_PASSWORD_SAVE_NEVER));
369  g_signal_connect (choice, "toggled",
371  password_view);
372  gtk_box_pack_start (GTK_BOX (remember_box), choice, FALSE, FALSE, 0);
373  gtk_widget_show (choice);
374 
375  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (choice));
376  choice = gtk_radio_button_new_with_mnemonic (group, _("Remember password until you _log out"));
377  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (choice),
378  password_view->priv->password_save == G_PASSWORD_SAVE_FOR_SESSION);
379  g_object_set_data (G_OBJECT (choice), "password-save",
380  GINT_TO_POINTER (G_PASSWORD_SAVE_FOR_SESSION));
381  g_signal_connect (choice, "toggled",
383  password_view);
384  gtk_box_pack_start (GTK_BOX (remember_box), choice, FALSE, FALSE, 0);
385  gtk_widget_show (choice);
386 
387  group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (choice));
388  choice = gtk_radio_button_new_with_mnemonic (group, _("Remember _forever"));
389  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (choice),
390  password_view->priv->password_save == G_PASSWORD_SAVE_PERMANENTLY);
391  g_object_set_data (G_OBJECT (choice), "password-save",
392  GINT_TO_POINTER (G_PASSWORD_SAVE_PERMANENTLY));
393  g_signal_connect (choice, "toggled",
395  password_view);
396  gtk_box_pack_start (GTK_BOX (remember_box), choice, FALSE, FALSE, 0);
397  gtk_widget_show (choice);
398  }
399 
400  g_signal_connect (dialog, "response",
401  G_CALLBACK (ev_password_dialog_got_response),
402  password_view);
403 
404  gtk_widget_show (GTK_WIDGET (dialog));
405 }

+ Here is the caller graph for this function:

const gchar* ev_password_view_get_password ( EvPasswordView password_view)

Definition at line 408 of file ev-password-view.c.

409 {
410  return password_view->priv->password;
411 }

+ Here is the caller graph for this function:

GPasswordSave ev_password_view_get_password_save_flags ( EvPasswordView password_view)

Definition at line 414 of file ev-password-view.c.

415 {
416  return password_view->priv->password_save;
417 }

+ Here is the caller graph for this function:

GType ev_password_view_get_type ( void  )
GtkWidget* ev_password_view_new ( GtkWindow *  parent)

Definition at line 420 of file ev-password-view.c.

421 {
422  EvPasswordView *retval;
423 
424  retval = EV_PASSWORD_VIEW (g_object_new (EV_TYPE_PASSWORD_VIEW, NULL));
425 
426  retval->priv->parent_window = parent;
427 
428  return GTK_WIDGET (retval);
429 }

+ Here is the caller graph for this function:

void ev_password_view_set_uri ( EvPasswordView password_view,
const char *  uri 
)

Definition at line 161 of file ev-password-view.c.

163 {
164  gchar *markup, *file_name;
165  GFile *file;
166 
167  g_return_if_fail (EV_IS_PASSWORD_VIEW (password_view));
168  g_return_if_fail (uri != NULL);
169 
170  file = g_file_new_for_uri (uri);
171  if (password_view->priv->uri_file &&
172  g_file_equal (file, password_view->priv->uri_file)) {
173  g_object_unref (file);
174  return;
175  }
176  if (password_view->priv->uri_file)
177  g_object_unref (password_view->priv->uri_file);
178  password_view->priv->uri_file = file;
179 
180  file_name = g_file_get_basename (password_view->priv->uri_file);
181  markup = g_markup_printf_escaped ("<span size=\"x-large\" weight=\"bold\">%s</span>",
182  file_name);
183  g_free (file_name);
184 
185  gtk_label_set_markup (GTK_LABEL (password_view->priv->label), markup);
186  g_free (markup);
187 }

+ Here is the caller graph for this function: