]> www.fi.muni.cz Git - evince.git/blob - shell/ev-properties-dialog.c
f48b96778c79f52233df525c2ac522dde7f86a28
[evince.git] / shell / ev-properties-dialog.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
2 /* this file is part of evince, a gnome document viewer
3  *
4  *  Copyright (C) 2005 Red Hat, Inc
5  *
6  * Evince is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * Evince is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <glib/gi18n.h>
26 #include <gtk/gtk.h>
27
28 #include "ev-document-fonts.h"
29 #include "ev-page-cache.h"
30 #include "ev-properties-dialog.h"
31 #include "ev-properties-fonts.h"
32 #include "ev-properties-view.h"
33
34 struct _EvPropertiesDialog {
35         GtkDialog base_instance;
36
37         EvDocument *document;
38         GtkWidget *notebook;
39         GtkWidget *general_page;
40         GtkWidget *fonts_page;
41 };
42
43 struct _EvPropertiesDialogClass {
44         GtkDialogClass base_class;
45 };
46
47 G_DEFINE_TYPE (EvPropertiesDialog, ev_properties_dialog, GTK_TYPE_DIALOG)
48
49 static void
50 ev_properties_dialog_class_init (EvPropertiesDialogClass *properties_class)
51 {
52 }
53
54 static void
55 ev_properties_dialog_init (EvPropertiesDialog *properties)
56 {
57         gtk_window_set_title (GTK_WINDOW (properties), _("Properties"));
58         gtk_window_set_destroy_with_parent (GTK_WINDOW (properties), TRUE);
59         gtk_dialog_set_has_separator (GTK_DIALOG (properties), FALSE);
60         gtk_container_set_border_width (GTK_CONTAINER (properties), 5);
61         gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (properties)->vbox), 2);
62
63         gtk_dialog_add_button (GTK_DIALOG (properties), GTK_STOCK_CLOSE,
64                                GTK_RESPONSE_CANCEL);
65         gtk_dialog_set_default_response (GTK_DIALOG (properties), 
66                                          GTK_RESPONSE_CANCEL);
67
68         properties->notebook = gtk_notebook_new ();
69         gtk_container_set_border_width (GTK_CONTAINER (properties->notebook), 5);
70         gtk_box_pack_start (GTK_BOX (GTK_DIALOG (properties)->vbox),
71                             properties->notebook, TRUE, TRUE, 0);
72         gtk_widget_show (properties->notebook);
73
74         g_signal_connect (properties, "response",
75                           G_CALLBACK (gtk_widget_destroy), NULL);
76 }
77
78 void
79 ev_properties_dialog_set_document (EvPropertiesDialog *properties,
80                                    const gchar        *uri,
81                                    EvDocument         *document)
82 {
83         GtkWidget *label;
84         const EvDocumentInfo *info;
85
86         properties->document = document;
87
88         info = ev_page_cache_get_info (ev_page_cache_get (document));
89
90         if (properties->general_page == NULL) {
91                 label = gtk_label_new (_("General"));
92                 properties->general_page = ev_properties_view_new (uri);
93                 gtk_notebook_append_page (GTK_NOTEBOOK (properties->notebook),
94                                           properties->general_page, label);
95                 gtk_widget_show (properties->general_page);
96         }
97         ev_properties_view_set_info (EV_PROPERTIES_VIEW (properties->general_page), info);
98
99         if (EV_IS_DOCUMENT_FONTS (document)) {
100                 if (properties->fonts_page == NULL) {
101                         label = gtk_label_new (_("Fonts"));
102                         properties->fonts_page = ev_properties_fonts_new ();
103                         gtk_notebook_append_page (GTK_NOTEBOOK (properties->notebook),
104                                                   properties->fonts_page, label);
105                         gtk_widget_show (properties->fonts_page);
106                 }
107
108                 ev_properties_fonts_set_document
109                         (EV_PROPERTIES_FONTS (properties->fonts_page), document);
110         }
111 }
112
113 GtkWidget *
114 ev_properties_dialog_new ()
115 {
116         EvPropertiesDialog *properties;
117
118         properties = g_object_new (EV_TYPE_PROPERTIES_DIALOG, NULL);
119
120         return GTK_WIDGET (properties);
121 }