[poppler] glib/demo
Carlos Garcia Campos
carlosgc at kemper.freedesktop.org
Thu Aug 21 11:41:37 PDT 2008
glib/demo/attachments.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
New commits:
commit b5a7987a50b3d28fbfa219e2cef85b9e53aaf079
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date: Thu Aug 21 20:40:18 2008 +0200
[glib-demo] Fix attachments demo with documents that don't contain attachments
diff --git a/glib/demo/attachments.c b/glib/demo/attachments.c
index 4324e94..72754b2 100644
--- a/glib/demo/attachments.c
+++ b/glib/demo/attachments.c
@@ -144,7 +144,6 @@ pgd_attachments_save_dialog_response (GtkFileChooser *file_chooser,
gtk_widget_destroy (GTK_WIDGET (file_chooser));
}
-
static void
pgd_attachments_save_button_clicked (GtkButton *button,
GtkTreeView *treeview)
@@ -279,6 +278,7 @@ pgd_attachments_create_widget (PopplerDocument *document)
GtkListStore *model;
GtkWidget *swindow;
GtkWidget *hbox, *button;
+ gboolean has_attachments;
vbox = gtk_vbox_new (FALSE, 12);
@@ -286,26 +286,36 @@ pgd_attachments_create_widget (PopplerDocument *document)
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- if (poppler_document_has_attachments (document)) {
+ has_attachments = poppler_document_has_attachments (document);
+ if (has_attachments) {
model = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_OBJECT);
pgd_attachments_fill_model (model, document);
+ treeview = pgd_attachments_create_list (GTK_TREE_MODEL (model));
} else {
- GtkTreeIter iter;
- gchar *markup;
+ GtkCellRenderer *renderer;
+ GtkTreeIter iter;
+ gchar *markup;
model = gtk_list_store_new (1, G_TYPE_STRING);
gtk_list_store_append (model, &iter);
markup = g_strdup_printf ("<span size=\"larger\" style=\"italic\">%s</span>",
- "The document doesn't contain outline");
+ "The document doesn't contain attachments");
gtk_list_store_set (model, &iter, 0, markup, -1);
g_free (markup);
+
+ treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
+ 0, "Name",
+ renderer,
+ "markup", 0,
+ NULL);
}
-
- treeview = pgd_attachments_create_list (GTK_TREE_MODEL (model));
g_object_unref (model);
gtk_container_add (GTK_CONTAINER (swindow), treeview);
@@ -314,6 +324,9 @@ pgd_attachments_create_widget (PopplerDocument *document)
gtk_box_pack_start (GTK_BOX (vbox), swindow, TRUE, TRUE, 0);
gtk_widget_show (swindow);
+ if (!has_attachments)
+ return vbox;
+
hbox = gtk_hbutton_box_new ();
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD);
More information about the poppler
mailing list