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-properties-fonts.c File Reference
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "ev-document-fonts.h"
#include "ev-job-scheduler.h"
#include "ev-jobs.h"
#include "ev-properties-fonts.h"
+ Include dependency graph for ev-properties-fonts.c:

Go to the source code of this file.

Data Structures

struct  _EvPropertiesFonts
 
struct  _EvPropertiesFontsClass
 

Functions

static void job_fonts_finished_cb (EvJob *job, EvPropertiesFonts *properties)
 
static void ev_properties_fonts_dispose (GObject *object)
 
static void ev_properties_fonts_class_init (EvPropertiesFontsClass *properties_class)
 
static void font_cell_data_func (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
 
static void ev_properties_fonts_init (EvPropertiesFonts *properties)
 
static void update_progress_label (GtkWidget *label, double progress)
 
static void job_fonts_updated_cb (EvJobFonts *job, gdouble progress, EvPropertiesFonts *properties)
 
void ev_properties_fonts_set_document (EvPropertiesFonts *properties, EvDocument *document)
 
GtkWidget * ev_properties_fonts_new (void)
 

Function Documentation

static void ev_properties_fonts_class_init ( EvPropertiesFontsClass properties_class)
static

Definition at line 72 of file ev-properties-fonts.c.

73 {
74  GObjectClass *g_object_class = G_OBJECT_CLASS (properties_class);
75 
76  g_object_class->dispose = ev_properties_fonts_dispose;
77 }
static void ev_properties_fonts_dispose ( GObject *  object)
static

Definition at line 54 of file ev-properties-fonts.c.

55 {
57 
58  if (properties->fonts_job) {
59  g_signal_handlers_disconnect_by_func (properties->fonts_job,
61  properties);
62  ev_job_cancel (properties->fonts_job);
63 
64  g_object_unref (properties->fonts_job);
65  properties->fonts_job = NULL;
66  }
67 
68  G_OBJECT_CLASS (ev_properties_fonts_parent_class)->dispose (object);
69 }

+ Here is the caller graph for this function:

static void ev_properties_fonts_init ( EvPropertiesFonts properties)
static

Definition at line 107 of file ev-properties-fonts.c.

108 {
109  GtkWidget *swindow;
110  GtkCellRenderer *renderer;
111  GtkTreeViewColumn *column;
112 
113  gtk_container_set_border_width (GTK_CONTAINER (properties), 12);
114  gtk_box_set_spacing (GTK_BOX (properties), 6);
115 
116  properties->fonts_summary = gtk_label_new (NULL);
117  g_object_set (G_OBJECT (properties->fonts_summary),
118  "xalign", 0.0,
119  NULL);
120  gtk_label_set_line_wrap (GTK_LABEL (properties->fonts_summary), TRUE);
121  gtk_box_pack_start (GTK_BOX (properties),
122  properties->fonts_summary,
123  FALSE, FALSE, 0);
124 
125  swindow = gtk_scrolled_window_new (NULL, NULL);
126  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow),
127  GTK_SHADOW_IN);
128 
129  properties->fonts_treeview = gtk_tree_view_new ();
130  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (properties->fonts_treeview),
131  FALSE);
132  column = gtk_tree_view_column_new ();
133  gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
134  gtk_tree_view_append_column (GTK_TREE_VIEW (properties->fonts_treeview),
135  column);
136 
137  renderer = GTK_CELL_RENDERER (g_object_new (GTK_TYPE_CELL_RENDERER_TEXT,
138  "ypad", 6, NULL));
139  gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column),
140  renderer, FALSE);
141  gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN (column),
142  _("Font"));
143  gtk_tree_view_column_set_cell_data_func (column, renderer,
145  NULL, NULL);
146 
147  gtk_container_add (GTK_CONTAINER (swindow), properties->fonts_treeview);
148  gtk_widget_show (properties->fonts_treeview);
149 
150  gtk_box_pack_start (GTK_BOX (properties), swindow,
151  TRUE, TRUE, 0);
152  gtk_widget_show (swindow);
153 
154  properties->fonts_progress_label = gtk_label_new (NULL);
155  g_object_set (G_OBJECT (properties->fonts_progress_label),
156  "xalign", 0.0,
157  NULL);
158  gtk_box_pack_start (GTK_BOX (properties),
159  properties->fonts_progress_label,
160  FALSE, FALSE, 0);
161  gtk_widget_show (properties->fonts_progress_label);
162 }
GtkWidget* ev_properties_fonts_new ( void  )

Definition at line 236 of file ev-properties-fonts.c.

237 {
239 
240  properties = g_object_new (EV_TYPE_PROPERTIES_FONTS,
241  "orientation", GTK_ORIENTATION_VERTICAL,
242  NULL);
243 
244  return GTK_WIDGET (properties);
245 }

+ Here is the caller graph for this function:

void ev_properties_fonts_set_document ( EvPropertiesFonts properties,
EvDocument document 
)

Definition at line 213 of file ev-properties-fonts.c.

215 {
216  GtkTreeView *tree_view = GTK_TREE_VIEW (properties->fonts_treeview);
217  GtkListStore *list_store;
218 
219  properties->document = document;
220 
221  list_store = gtk_list_store_new (EV_DOCUMENT_FONTS_COLUMN_NUM_COLUMNS,
222  G_TYPE_STRING, G_TYPE_STRING);
223  gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (list_store));
224 
225  properties->fonts_job = ev_job_fonts_new (properties->document);
226  g_signal_connect (properties->fonts_job, "updated",
227  G_CALLBACK (job_fonts_updated_cb),
228  properties);
229  g_signal_connect (properties->fonts_job, "finished",
230  G_CALLBACK (job_fonts_finished_cb),
231  properties);
233 }

+ Here is the caller graph for this function:

static void font_cell_data_func ( GtkTreeViewColumn *  col,
GtkCellRenderer *  renderer,
GtkTreeModel *  model,
GtkTreeIter *  iter,
gpointer  user_data 
)
static

Definition at line 80 of file ev-properties-fonts.c.

82 {
83  char *name;
84  char *details;
85  char *markup;
86 
87  gtk_tree_model_get (model, iter,
90  -1);
91 
92  if (details) {
93  markup = g_strdup_printf ("<b><big>%s</big></b>\n<small>%s</small>",
94  name, details);
95  } else {
96  markup = g_strdup_printf ("<b><big>%s</big></b>", name);
97  }
98 
99  g_object_set (renderer, "markup", markup, NULL);
100 
101  g_free (markup);
102  g_free (details);
103  g_free (name);
104 }

+ Here is the caller graph for this function:

static void job_fonts_finished_cb ( EvJob job,
EvPropertiesFonts properties 
)
static

Definition at line 180 of file ev-properties-fonts.c.

181 {
182  EvDocumentFonts *document_fonts = EV_DOCUMENT_FONTS (properties->document);
183  const gchar *font_summary;
184 
185  g_signal_handlers_disconnect_by_func (job, job_fonts_finished_cb, properties);
186  g_object_unref (properties->fonts_job);
187  properties->fonts_job = NULL;
188 
189  font_summary = ev_document_fonts_get_fonts_summary (document_fonts);
190  if (font_summary) {
191  gtk_label_set_text (GTK_LABEL (properties->fonts_summary),
192  font_summary);
193  /* show the label only when fonts are scanned, so the label
194  * does not take space while it is loading */
195  gtk_widget_show (properties->fonts_summary);
196  }
197 }

+ Here is the caller graph for this function:

static void job_fonts_updated_cb ( EvJobFonts job,
gdouble  progress,
EvPropertiesFonts properties 
)
static

Definition at line 200 of file ev-properties-fonts.c.

201 {
202  GtkTreeModel *model;
203  EvDocumentFonts *document_fonts = EV_DOCUMENT_FONTS (properties->document);
204 
205  update_progress_label (properties->fonts_progress_label, progress);
206 
207  model = gtk_tree_view_get_model (GTK_TREE_VIEW (properties->fonts_treeview));
208  /* Documen lock is already held by the jop */
209  ev_document_fonts_fill_model (document_fonts, model);
210 }

+ Here is the caller graph for this function:

static void update_progress_label ( GtkWidget *  label,
double  progress 
)
static

Definition at line 165 of file ev-properties-fonts.c.

166 {
167  if (progress > 0) {
168  char *progress_text;
169  progress_text = g_strdup_printf (_("Gathering font information… %3d%%"),
170  (int) (progress * 100));
171  gtk_label_set_text (GTK_LABEL (label), progress_text);
172  g_free (progress_text);
173  gtk_widget_show (label);
174  } else {
175  gtk_widget_hide (label);
176  }
177 }

+ Here is the caller graph for this function: