From: Marco Pesenti Gritti Date: Mon, 4 Jul 2005 11:58:56 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: EVINCE_0_3_3~179 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=2ad5c80aafe43d53698e1084db86e34bf15290a9;p=evince.git *** empty log message *** --- diff --git a/shell/ev-properties-dialog.c b/shell/ev-properties-dialog.c new file mode 100644 index 00000000..aa6142af --- /dev/null +++ b/shell/ev-properties-dialog.c @@ -0,0 +1,116 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2005 Red Hat, Inc + * + * Evince is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Evince is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ev-properties-view.h" +#include "ev-properties-fonts.h" +#include "ev-properties-dialog.h" +#include "ev-page-cache.h" +#include "ev-document-fonts.h" + +#include +#include +#include +#include +#include +#include + +struct _EvPropertiesDialog { + GtkDialog base_instance; + + EvDocument *document; + GtkWidget *notebook; + GtkWidget *general_page; + GtkWidget *fonts_page; +}; + +struct _EvPropertiesDialogClass { + GtkDialogClass base_class; +}; + +G_DEFINE_TYPE (EvPropertiesDialog, ev_properties_dialog, GTK_TYPE_DIALOG) + +static void +ev_properties_dialog_class_init (EvPropertiesDialogClass *properties_class) +{ +} + +static void +ev_properties_dialog_init (EvPropertiesDialog *properties) +{ + gtk_window_set_title (GTK_WINDOW (properties), _("Properties")); + gtk_window_set_destroy_with_parent (GTK_WINDOW (properties), TRUE); + gtk_dialog_set_has_separator (GTK_DIALOG (properties), FALSE); + gtk_container_set_border_width (GTK_CONTAINER (properties), 5); + + gtk_dialog_add_button (GTK_DIALOG (properties), GTK_STOCK_CLOSE, + GTK_RESPONSE_ACCEPT); + + properties->notebook = gtk_notebook_new (); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (properties)->vbox), + properties->notebook, TRUE, TRUE, 0); + gtk_widget_show (properties->notebook); + + g_signal_connect (properties, "response", + G_CALLBACK (gtk_widget_destroy), NULL); +} + +void +ev_properties_dialog_set_document (EvPropertiesDialog *properties, + EvDocument *document) +{ + GtkWidget *label; + const EvDocumentInfo *info; + + properties->document = document; + + info = ev_page_cache_get_info (ev_page_cache_get (document)); + + if (properties->general_page == NULL) { + label = gtk_label_new (_("General")); + properties->general_page = ev_properties_view_new (); + gtk_notebook_append_page (GTK_NOTEBOOK (properties->notebook), + properties->general_page, label); + gtk_widget_show (properties->general_page); + } + ev_properties_view_set_info (EV_PROPERTIES_VIEW (properties->general_page), info); + + if (properties->fonts_page == NULL && EV_IS_DOCUMENT_FONTS (document)) { + label = gtk_label_new (_("Fonts")); + properties->fonts_page = ev_properties_fonts_new (); + gtk_notebook_append_page (GTK_NOTEBOOK (properties->notebook), + properties->fonts_page, label); + gtk_widget_show (properties->fonts_page); + } + ev_properties_fonts_set_document (EV_PROPERTIES_FONTS (properties->fonts_page), document); +} + +GtkWidget * +ev_properties_dialog_new () +{ + EvPropertiesDialog *properties; + + properties = g_object_new (EV_TYPE_PROPERTIES_DIALOG, NULL); + + return GTK_WIDGET (properties); +} diff --git a/shell/ev-properties-dialog.h b/shell/ev-properties-dialog.h new file mode 100644 index 00000000..8a3eafcb --- /dev/null +++ b/shell/ev-properties-dialog.h @@ -0,0 +1,46 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2005 Red Hat, Inc + * + * Evince is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Evince is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __EV_PROPERTIES_DIALOG_H__ +#define __EV_PROPERTIES_DIALOG_H__ + +#include "ev-document.h" + +G_BEGIN_DECLS + +typedef struct _EvPropertiesDialog EvPropertiesDialog; +typedef struct _EvPropertiesDialogClass EvPropertiesDialogClass; +typedef struct _EvPropertiesDialogPrivate EvPropertiesDialogPrivate; + +#define EV_TYPE_PROPERTIES_DIALOG (ev_properties_dialog_get_type()) +#define EV_PROPERTIES_DIALOG(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PROPERTIES_DIALOG, EvPropertiesDialog)) +#define EV_PROPERTIES_DIALOG_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), EV_TYPE_PROPERTIES_DIALOG, EvPropertiesDialogClass)) +#define EV_IS_PROPERTIES_DIALOG(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PROPERTIES_DIALOG)) +#define EV_IS_PROPERTIES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_PROPERTIES_DIALOG)) +#define EV_PROPERTIES_DIALOG_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_PROPERTIES_DIALOG, EvPropertiesDialogClass)) + +GType ev_properties_dialog_get_type (void); +GtkWidget *ev_properties_dialog_new (void); +void ev_properties_dialog_set_document (EvPropertiesDialog *properties, + EvDocument *document); + +G_END_DECLS + +#endif /* __EV_PROPERTIES_DIALOG_H__ */ diff --git a/shell/ev-properties-fonts.c b/shell/ev-properties-fonts.c new file mode 100644 index 00000000..ce510911 --- /dev/null +++ b/shell/ev-properties-fonts.c @@ -0,0 +1,178 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2005 Red Hat, Inc + * + * Evince is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Evince is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ev-properties-fonts.h" +#include "ev-document-fonts.h" +#include "ev-jobs.h" +#include "ev-job-queue.h" + +#include +#include +#include + +enum +{ + FONT_NAME_COL, + NUM_COLS +}; + +struct _EvPropertiesFonts { + GtkVBox base_instance; + + GladeXML *xml; + + GtkWidget *fonts_treeview; + GtkWidget *fonts_progress_label; + + EvDocument *document; +}; + +struct _EvPropertiesFontsClass { + GtkVBoxClass base_class; +}; + +G_DEFINE_TYPE (EvPropertiesFonts, ev_properties_fonts, GTK_TYPE_VBOX) + +static void +ev_properties_fonts_dispose (GObject *object) +{ + EvPropertiesFonts *properties = EV_PROPERTIES_FONTS (object); + + if (properties->xml) { + g_object_unref (properties->xml); + properties->xml = NULL; + } +} + +static void +ev_properties_fonts_class_init (EvPropertiesFontsClass *properties_class) +{ + GObjectClass *g_object_class = G_OBJECT_CLASS (properties_class); + + g_object_class->dispose = ev_properties_fonts_dispose; +} + +static void +ev_properties_fonts_init (EvPropertiesFonts *properties) +{ + GladeXML *xml; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + + /* Create a new GladeXML object from XML file glade_file */ + xml = glade_xml_new (DATADIR "/evince-properties.glade", "fonts_page_root", NULL); + properties->xml = xml; + g_assert (xml != NULL); + + gtk_box_pack_start (GTK_BOX (properties), + glade_xml_get_widget (xml, "fonts_page_root"), + TRUE, TRUE, 0); + + properties->fonts_treeview = glade_xml_get_widget (xml, "fonts_treeview"); + properties->fonts_progress_label = glade_xml_get_widget (xml, "font_progress_label"); + + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (properties->fonts_treeview), column); + + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start (GTK_TREE_VIEW_COLUMN (column), renderer, FALSE); + gtk_tree_view_column_set_title (GTK_TREE_VIEW_COLUMN (column), _("Name")); + gtk_tree_view_column_set_attributes (GTK_TREE_VIEW_COLUMN (column), renderer, + "text", EV_DOCUMENT_FONTS_COLUMN_NAME, + NULL); +} + +static void +update_progress_label (GtkWidget *label, double progress) +{ + if (progress > 0) { + char *progress_text; + progress_text = g_strdup_printf (_("Gathering font information... %3d%%"), + (int) (progress * 100)); + gtk_label_set_text (GTK_LABEL (label), progress_text); + g_free (progress_text); + gtk_widget_show (label); + } else { + gtk_widget_hide (label); + } +} + +static void +job_fonts_finished_cb (EvJob *job, EvPropertiesFonts *properties) +{ + EvDocumentFonts *document_fonts = EV_DOCUMENT_FONTS (job->document); + double progress; + + progress = ev_document_fonts_get_progress (document_fonts); + update_progress_label (properties->fonts_progress_label, progress); + + if (EV_JOB_FONTS (job)->scan_completed) { + g_signal_handlers_disconnect_by_func + (job, job_fonts_finished_cb, properties); + } else { + GtkTreeModel *model; + EvJob *new_job; + + model = gtk_tree_view_get_model + (GTK_TREE_VIEW (properties->fonts_treeview)); + ev_document_doc_mutex_lock (); + ev_document_fonts_fill_model (document_fonts, model); + ev_document_doc_mutex_unlock (); + new_job = ev_job_fonts_new (job->document); + ev_job_queue_add_job (job, EV_JOB_PRIORITY_LOW); + g_object_unref (new_job); + } +} + +void +ev_properties_fonts_set_document (EvPropertiesFonts *properties, + EvDocument *document) +{ + GtkTreeView *tree_view = GTK_TREE_VIEW (properties->fonts_treeview); + GtkListStore *list_store; + EvJob *job; + + properties->document = document; + + list_store = gtk_list_store_new (NUM_COLS, G_TYPE_STRING); + gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (list_store)); + + job = ev_job_fonts_new (properties->document); + g_signal_connect_object (job, "finished", + G_CALLBACK (job_fonts_finished_cb), + properties, 0); + ev_job_queue_add_job (job, EV_JOB_PRIORITY_LOW); + g_object_unref (job); +} + +GtkWidget * +ev_properties_fonts_new () +{ + EvPropertiesFonts *properties; + + properties = g_object_new (EV_TYPE_PROPERTIES_FONTS, NULL); + + return GTK_WIDGET (properties); +} diff --git a/shell/ev-properties-fonts.h b/shell/ev-properties-fonts.h new file mode 100644 index 00000000..852887fc --- /dev/null +++ b/shell/ev-properties-fonts.h @@ -0,0 +1,48 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */ +/* this file is part of evince, a gnome document viewer + * + * Copyright (C) 2005 Red Hat, Inc + * + * Evince is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Evince is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __EV_PROPERTIES_FONTS_H__ +#define __EV_PROPERTIES_FONTS_H__ + +#include "ev-document.h" + +#include + +G_BEGIN_DECLS + +typedef struct _EvPropertiesFonts EvPropertiesFonts; +typedef struct _EvPropertiesFontsClass EvPropertiesFontsClass; +typedef struct _EvPropertiesFontsPrivate EvPropertiesFontsPrivate; + +#define EV_TYPE_PROPERTIES_FONTS (ev_properties_fonts_get_type()) +#define EV_PROPERTIES_FONTS(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PROPERTIES_FONTS, EvPropertiesFonts)) +#define EV_PROPERTIES_FONTS_CLASS(klass) (G_TYPE_CHACK_CLASS_CAST((klass), EV_TYPE_PROPERTIES_FONTS, EvPropertiesFontsClass)) +#define EV_IS_PROPERTIES(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PROPERTIES_FONTS)) +#define EV_IS_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_PROPERTIES_FONTS)) +#define EV_PROPERTIES_FONTS_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_PROPERTIES_FONTS, EvPropertiesFontsClass)) + +GType ev_properties_fonts_get_type (void); +GtkWidget *ev_properties_fonts_new (void); +void ev_properties_fonts_set_document (EvPropertiesFonts *properties, + EvDocument *document); + +G_END_DECLS + +#endif /* __EV_PROPERTIES_FONTS_H__ */