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
4 * Copyright (C) 2005 Red Hat, Inc
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #include <glib/gi18n.h>
28 #include "ev-document-fonts.h"
29 #include "ev-properties-dialog.h"
30 #include "ev-properties-fonts.h"
31 #include "ev-properties-view.h"
32 #include "ev-properties-license.h"
34 struct _EvPropertiesDialog {
35 GtkDialog base_instance;
39 GtkWidget *general_page;
40 GtkWidget *fonts_page;
41 GtkWidget *license_page;
44 struct _EvPropertiesDialogClass {
45 GtkDialogClass base_class;
48 G_DEFINE_TYPE (EvPropertiesDialog, ev_properties_dialog, GTK_TYPE_DIALOG)
51 ev_properties_dialog_class_init (EvPropertiesDialogClass *properties_class)
56 ev_properties_dialog_init (EvPropertiesDialog *properties)
60 content_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (properties)));
62 gtk_window_set_title (GTK_WINDOW (properties), _("Properties"));
63 gtk_window_set_destroy_with_parent (GTK_WINDOW (properties), TRUE);
64 gtk_container_set_border_width (GTK_CONTAINER (properties), 5);
65 gtk_box_set_spacing (content_area, 2);
67 gtk_dialog_add_button (GTK_DIALOG (properties), GTK_STOCK_CLOSE,
69 gtk_dialog_set_default_response (GTK_DIALOG (properties),
72 properties->notebook = gtk_notebook_new ();
73 gtk_container_set_border_width (GTK_CONTAINER (properties->notebook), 5);
74 gtk_box_pack_start (content_area, properties->notebook, TRUE, TRUE, 0);
75 gtk_widget_show (properties->notebook);
77 g_signal_connect (properties, "response",
78 G_CALLBACK (gtk_widget_destroy), NULL);
82 ev_properties_dialog_set_document (EvPropertiesDialog *properties,
87 const EvDocumentInfo *info;
89 properties->document = document;
91 info = ev_document_get_info (document);
93 if (properties->general_page == NULL) {
94 label = gtk_label_new (_("General"));
95 properties->general_page = ev_properties_view_new (uri);
96 gtk_notebook_append_page (GTK_NOTEBOOK (properties->notebook),
97 properties->general_page, label);
98 gtk_widget_show (properties->general_page);
100 ev_properties_view_set_info (EV_PROPERTIES_VIEW (properties->general_page), info);
102 if (EV_IS_DOCUMENT_FONTS (document)) {
103 if (properties->fonts_page == NULL) {
104 label = gtk_label_new (_("Fonts"));
105 properties->fonts_page = ev_properties_fonts_new ();
106 gtk_notebook_append_page (GTK_NOTEBOOK (properties->notebook),
107 properties->fonts_page, label);
108 gtk_widget_show (properties->fonts_page);
111 ev_properties_fonts_set_document
112 (EV_PROPERTIES_FONTS (properties->fonts_page), document);
115 if (info->fields_mask & EV_DOCUMENT_INFO_LICENSE && info->license) {
116 if (properties->license_page == NULL) {
117 label = gtk_label_new (_("Document License"));
118 properties->license_page = ev_properties_license_new ();
119 gtk_notebook_append_page (GTK_NOTEBOOK (properties->notebook),
120 properties->license_page, label);
121 gtk_widget_show (properties->license_page);
124 ev_properties_license_set_license
125 (EV_PROPERTIES_LICENSE (properties->license_page), info->license);
130 ev_properties_dialog_new ()
132 EvPropertiesDialog *properties;
134 properties = g_object_new (EV_TYPE_PROPERTIES_DIALOG, NULL);
136 return GTK_WIDGET (properties);