23 #include <glib/gi18n.h>
65 ev_sidebar_annotations,
71 #define EV_SIDEBAR_ANNOTATIONS_GET_PRIVATE(object) \
72 (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_SIDEBAR_ANNOTATIONS, EvSidebarAnnotationsPrivate))
75 ev_sidebar_annotations_dispose (GObject *
object)
85 G_OBJECT_CLASS (ev_sidebar_annotations_parent_class)->dispose (
object);
96 retval = (GtkTreeModel *)gtk_list_store_new (
N_COLUMNS,
101 gtk_list_store_append (GTK_LIST_STORE (retval), &iter);
102 markup = g_strdup_printf (
"<span size=\"larger\" style=\"italic\">%s</span>",
104 gtk_list_store_set (GTK_LIST_STORE (retval), &iter,
115 GtkTreeModel *loading_model;
116 GtkCellRenderer *renderer;
117 GtkTreeViewColumn *column;
118 GtkTreeSelection *selection;
122 ev_annots->priv->swindow = gtk_scrolled_window_new (NULL, NULL);
126 ev_annots->priv->tree_view = gtk_tree_view_new_with_model (loading_model);
127 g_object_unref (loading_model);
129 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ev_annots->priv->tree_view),
131 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ev_annots->priv->tree_view));
132 gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
134 column = gtk_tree_view_column_new ();
136 renderer = gtk_cell_renderer_pixbuf_new ();
137 gtk_tree_view_column_pack_start (column, renderer,
FALSE);
138 gtk_tree_view_column_set_attributes (column, renderer,
142 renderer = gtk_cell_renderer_text_new ();
143 gtk_tree_view_column_pack_start (column, renderer,
TRUE);
144 gtk_tree_view_column_set_attributes (column, renderer,
147 gtk_tree_view_append_column (GTK_TREE_VIEW (ev_annots->priv->tree_view),
150 gtk_container_add (GTK_CONTAINER (ev_annots->priv->swindow), ev_annots->priv->tree_view);
151 gtk_widget_show (ev_annots->priv->tree_view);
153 gtk_box_pack_start (GTK_BOX (ev_annots), ev_annots->priv->swindow,
TRUE,
TRUE, 0);
154 gtk_widget_show (ev_annots->priv->swindow);
169 g_value_set_object (value, ev_sidebar_annots->priv->swindow);
172 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
180 GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
183 g_object_class->dispose = ev_sidebar_annotations_dispose;
187 g_object_class_override_property (g_object_class,
PROP_WIDGET,
"main-widget");
190 g_signal_new (
"annot-activated",
191 G_TYPE_FROM_CLASS (g_object_class),
192 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
195 g_cclosure_marshal_VOID__POINTER,
204 "orientation", GTK_ORIENTATION_VERTICAL,
228 if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
231 gtk_tree_model_get (model, &iter,
245 GtkTreeSelection *selection;
247 GdkPixbuf *text_icon = NULL;
248 GdkPixbuf *attachment_icon = NULL;
249 GdkPixbuf *highlight_icon = NULL;
250 GdkPixbuf *strike_out_icon = NULL;
251 GdkPixbuf *underline_icon = NULL;
252 GdkPixbuf *squiggly_icon = NULL;
254 priv = sidebar_annots->priv;
260 gtk_tree_view_set_model (GTK_TREE_VIEW (priv->
tree_view), list);
261 g_object_unref (list);
263 g_object_unref (job);
269 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->
tree_view));
270 gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
273 g_signal_connect (selection,
"changed",
283 for (l = job->
annots; l; l = g_list_next (l)) {
288 gboolean found =
FALSE;
291 page_label = g_strdup_printf (
_(
"Page %d"),
293 gtk_tree_store_append (model, &iter, NULL);
294 gtk_tree_store_set (model, &iter,
302 const gchar *modified;
304 GtkTreeIter child_iter;
305 GdkPixbuf *pixbuf = NULL;
314 markup = g_strdup_printf (
"<span weight=\"bold\">%s</span>\n%s",
317 markup = g_strdup_printf (
"<span weight=\"bold\">%s</span>", label);
323 text_icon = gtk_widget_render_icon_pixbuf (priv->
tree_view,
325 GTK_ICON_SIZE_BUTTON);
329 if (!attachment_icon) {
330 attachment_icon = gtk_widget_render_icon_pixbuf (priv->
tree_view,
332 GTK_ICON_SIZE_BUTTON);
334 pixbuf = attachment_icon;
338 if (!highlight_icon) {
340 highlight_icon = gtk_widget_render_icon_pixbuf (priv->
tree_view,
341 GTK_STOCK_SELECT_ALL,
342 GTK_ICON_SIZE_BUTTON);
344 pixbuf = highlight_icon;
348 if (!strike_out_icon) {
349 strike_out_icon = gtk_widget_render_icon_pixbuf (priv->
tree_view,
350 GTK_STOCK_STRIKETHROUGH,
351 GTK_ICON_SIZE_BUTTON);
353 pixbuf = strike_out_icon;
356 if (!underline_icon) {
357 underline_icon = gtk_widget_render_icon_pixbuf (priv->
tree_view,
359 GTK_ICON_SIZE_BUTTON);
361 pixbuf = underline_icon;
364 if (!squiggly_icon) {
365 squiggly_icon = gtk_widget_render_icon_pixbuf (priv->
tree_view,
367 GTK_ICON_SIZE_BUTTON);
369 pixbuf = squiggly_icon;
374 gtk_tree_store_append (model, &child_iter, &iter);
375 gtk_tree_store_set (model, &child_iter,
385 gtk_tree_store_remove (model, &iter);
388 gtk_tree_view_set_model (GTK_TREE_VIEW (priv->
tree_view),
389 GTK_TREE_MODEL (model));
390 g_object_unref (model);
393 g_object_unref (text_icon);
395 g_object_unref (attachment_icon);
397 g_object_unref (highlight_icon);
399 g_object_unref (strike_out_icon);
401 g_object_unref (underline_icon);
403 g_object_unref (squiggly_icon);
405 g_object_unref (job);
415 g_signal_handlers_disconnect_by_func (priv->
job,
418 g_object_unref (priv->
job);
422 g_signal_connect (priv->
job,
"finished",
442 priv->
document = g_object_ref (document);
452 g_signal_connect (model,
"notify::document",
467 return _(
"Annotations");