[goffice] GOFontSelDialog: new dialog.



commit 7dba4af6d28a59ecfef6c1cfd7aa7a2f1dc21de5
Author: Morten Welinder <terra gnome org>
Date:   Wed Mar 13 16:50:49 2013 -0400

    GOFontSelDialog: new dialog.
    
    I intend to change the font selector, but that should not affect this
    dialog.

 NEWS                             |    1 +
 goffice/Makefile.am              |    2 +
 goffice/gtk/go-font-sel-dialog.c |  187 ++++++++++++++++++++++++++++++++++++++
 goffice/gtk/go-font-sel-dialog.h |   37 ++++++++
 goffice/gtk/goffice-gtk.h        |    1 +
 5 files changed, 228 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3cda262..7d59721 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Morten:
        * Fix problems with cspline boxed type. [#695550]
        * Fix gtk-doc problems --without-long-double.  [#695550]
        * Widget cleanups.
+       * Add dialog version of the font selector.
 
 --------------------------------------------------------------------------
 goffice 0.10.1:
diff --git a/goffice/Makefile.am b/goffice/Makefile.am
index d01bd97..110c918 100644
--- a/goffice/Makefile.am
+++ b/goffice/Makefile.am
@@ -262,6 +262,7 @@ gtk_SOURCES =                                       \
        gtk/goffice-gtk.c                       \
                                                \
        gtk/go-font-sel.c                       \
+       gtk/go-font-sel-dialog.c                \
        gtk/go-format-sel.c                     \
        gtk/go-rotation-sel.c                   \
        gtk/go-charmap-sel.c                    \
@@ -297,6 +298,7 @@ gtk_HEADERS =                                       \
        gtk/goffice-gtk.h                       \
                                                \
        gtk/go-font-sel.h                       \
+       gtk/go-font-sel-dialog.h                \
        gtk/go-format-sel.h                     \
        gtk/go-rotation-sel.h                   \
        gtk/go-charmap-sel.h                    \
diff --git a/goffice/gtk/go-font-sel-dialog.c b/goffice/gtk/go-font-sel-dialog.c
new file mode 100644
index 0000000..0cc8499
--- /dev/null
+++ b/goffice/gtk/go-font-sel-dialog.c
@@ -0,0 +1,187 @@
+/*
+ * A font selector dialog.
+ *
+ * Authors:
+ *   Morten Welinder (terra gnome org)
+ *
+ * This library 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) version 3.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+ * USA.
+ */
+#include <goffice/goffice-config.h>
+#include <goffice/goffice.h>
+
+#include <gsf/gsf-impl-utils.h>
+#include <glib/gi18n-lib.h>
+
+struct GOFontSelDialog_ {
+       GtkDialog parent;
+       GOFontSel *gfs;
+};
+
+typedef struct GOFontSelDialogClass_ {
+       GtkDialogClass base;
+} GOFontSelDialogClass;
+
+static GObjectClass *gfsd_parent_class;
+
+enum {
+       PROP_0,
+
+       GFSD_GTK_FONT_CHOOSER_PROP_FIRST           = 0x4000,
+       GFSD_GTK_FONT_CHOOSER_PROP_FONT,
+       GFSD_GTK_FONT_CHOOSER_PROP_FONT_DESC,
+       GFSD_GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT,
+       GFSD_GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
+       GFSD_GTK_FONT_CHOOSER_PROP_LAST
+};
+
+static void
+gfsd_set_property (GObject         *object,
+                  guint            prop_id,
+                  const GValue    *value,
+                  GParamSpec      *pspec)
+{
+       GOFontSelDialog *gfsd = GO_FONT_SEL_DIALOG (object);
+
+       switch (prop_id) {
+       case GFSD_GTK_FONT_CHOOSER_PROP_FONT:
+               break;
+       case GFSD_GTK_FONT_CHOOSER_PROP_FONT_DESC:
+               break;
+
+       case GFSD_GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT:
+               go_font_sel_set_sample_text (gfsd->gfs,
+                                            g_value_get_string (value));
+               break;
+       case GFSD_GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY:
+               break;
+
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+gfsd_get_property (GObject         *object,
+                  guint            prop_id,
+                  GValue          *value,
+                  GParamSpec      *pspec)
+{
+       GOFontSelDialog *gfsd = GO_FONT_SEL_DIALOG (object);
+
+       switch (prop_id) {
+       case GFSD_GTK_FONT_CHOOSER_PROP_FONT:
+               break;
+
+       case GFSD_GTK_FONT_CHOOSER_PROP_FONT_DESC:
+               break;
+
+       case GFSD_GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT:
+
+               break;
+
+       case GFSD_GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY:
+               break;
+
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+gfsd_init (GOFontSelDialog *gfsd)
+{
+       GtkDialog *dialog = GTK_DIALOG (gfsd);
+       GtkWidget *gfs = go_font_sel_new ();
+       gfsd->gfs = GO_FONT_SEL (gfs);
+       gtk_widget_show (gfs);
+       gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)),
+                          gfs);
+       gtk_dialog_add_button (dialog, GTK_STOCK_OK, GTK_RESPONSE_OK);
+       gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+}
+
+static void
+gfsd_class_init (GObjectClass *klass)
+{
+       // klass->dispose = gfsd_dispose;
+       klass->set_property = gfsd_set_property;
+       klass->get_property = gfsd_get_property;
+
+       gfsd_parent_class = g_type_class_peek_parent (klass);
+
+       g_object_class_override_property (klass,
+                                         GFSD_GTK_FONT_CHOOSER_PROP_FONT,
+                                         "font");
+       g_object_class_override_property (klass,
+                                         GFSD_GTK_FONT_CHOOSER_PROP_FONT_DESC,
+                                         "font-desc");
+       g_object_class_override_property (klass,
+                                         GFSD_GTK_FONT_CHOOSER_PROP_PREVIEW_TEXT,
+                                         "preview-text");
+       g_object_class_override_property (klass,
+                                         GFSD_GTK_FONT_CHOOSER_PROP_SHOW_PREVIEW_ENTRY,
+                                         "show-preview-entry");
+}
+
+static void
+gfsd_font_chooser_set_filter_func (GtkFontChooser    *chooser,
+                                 GtkFontFilterFunc  filter_func,
+                                 gpointer           filter_data,
+                                 GDestroyNotify     data_destroy)
+{
+}
+
+static PangoFontFamily *
+gfsd_font_chooser_get_font_family (GtkFontChooser *chooser)
+{
+       return NULL;
+}
+
+static int
+gfsd_font_chooser_get_font_size (GtkFontChooser *chooser)
+{
+       return 0;
+}
+
+static PangoFontFace *
+gfsd_font_chooser_get_font_face (GtkFontChooser *chooser)
+{
+       return NULL;
+}
+
+
+static void
+gfsd_font_chooser_iface_init (GtkFontChooserIface *iface)
+{
+       iface->get_font_family = gfsd_font_chooser_get_font_family;
+       iface->get_font_face = gfsd_font_chooser_get_font_face;
+       iface->get_font_size = gfsd_font_chooser_get_font_size;
+       iface->set_filter_func = gfsd_font_chooser_set_filter_func;
+}
+
+
+
+
+GSF_CLASS_FULL (GOFontSelDialog, go_font_sel_dialog,
+               NULL, NULL, gfsd_class_init, NULL,
+               gfsd_init, GTK_TYPE_DIALOG, 0,
+               GSF_INTERFACE (gfsd_font_chooser_iface_init, GTK_TYPE_FONT_CHOOSER);
+       )
+#if 0
+;
+#endif
diff --git a/goffice/gtk/go-font-sel-dialog.h b/goffice/gtk/go-font-sel-dialog.h
new file mode 100644
index 0000000..18d6e6f
--- /dev/null
+++ b/goffice/gtk/go-font-sel-dialog.h
@@ -0,0 +1,37 @@
+/*
+ * go-font-sel-dialog.h - font selector dialog
+ *
+ * This library 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) version 3.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+ * USA.
+ */
+#ifndef _GO_FONT_SEL_DIALOG_H_
+#define _GO_FONT_SEL_DIALOG_H_
+
+#include <goffice/goffice.h>
+
+G_BEGIN_DECLS
+
+#define GO_TYPE_FONT_SEL_DIALOG        (go_font_sel_dialog_get_type ())
+#define GO_FONT_SEL_DIALOG(obj)        (G_TYPE_CHECK_INSTANCE_CAST((obj), GO_TYPE_FONT_SEL_DIALOG, 
GOFontSelDialog))
+#define GO_IS_FONT_SEL_DIALOG(obj)     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GO_TYPE_FONT_SEL_DIALOG))
+
+typedef struct GOFontSelDialog_ GOFontSelDialog;
+
+GType         go_font_sel_dialog_get_type (void);
+GtkWidget    *go_font_sel_dialog_new      (void);
+
+G_END_DECLS
+
+#endif /* _GO_FONT_SEL_DIALOG_H_ */
diff --git a/goffice/gtk/goffice-gtk.h b/goffice/gtk/goffice-gtk.h
index 1c774a6..e25a399 100644
--- a/goffice/gtk/goffice-gtk.h
+++ b/goffice/gtk/goffice-gtk.h
@@ -39,6 +39,7 @@
 #include <goffice/gtk/go-combo-color.h>
 #include <goffice/gtk/go-combo-pixmaps.h>
 #include <goffice/gtk/go-font-sel.h>
+#include <goffice/gtk/go-font-sel-dialog.h>
 #include <goffice/gtk/go-format-sel.h>
 #include <goffice/gtk/go-gradient-selector.h>
 #include <goffice/gtk/go-graph-widget.h>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]