Added MooFontSelection back

master
Yevgen Muntyan 2006-06-14 10:02:17 -05:00
parent d1b8b9fd1d
commit bacb3131fe
5 changed files with 2525 additions and 5 deletions

View File

@ -20,6 +20,7 @@
#include "mooutils/moocompat.h"
#include "mooutils/moostock.h"
#include "mooutils/mooglade.h"
#include "mooutils/moofontsel.h"
#include "mooutils/mooutils-treeview.h"
#include <string.h>
@ -66,6 +67,7 @@ moo_edit_prefs_page_new (MooEditor *editor)
_moo_edit_init_settings ();
xml = moo_glade_xml_new_empty ();
moo_glade_xml_map_id (xml, "fontbutton", MOO_TYPE_FONT_BUTTON);
moo_glade_xml_set_property (xml, "fontbutton", "monospace", "True");
page_widget = moo_prefs_dialog_page_new_from_xml ("Editor", GTK_STOCK_EDIT, xml,
MOO_EDIT_PREFS_GLADE_UI, -1, "page",

View File

@ -61,12 +61,14 @@ mooutils_sources = \
$(mooutils)/mooconfig.c \
$(mooutils)/moodialogs.c \
$(mooutils)/moodialogs.h \
$(mooutils)/mooentry.c \
$(mooutils)/moofiledialog.c \
$(mooutils)/moofiledialog.h \
$(mooutils)/mooentry.c \
$(mooutils)/moofilewatch.c \
$(mooutils)/moofilewatch.h \
$(mooutils)/moofiltermgr.c \
$(mooutils)/moofontsel.c \
$(mooutils)/moofontsel.h \
$(mooutils)/mooglade.c \
$(mooutils)/moohistoryentry.c \
$(mooutils)/moohistorylist.c \

2259
moo/mooutils/moofontsel.c Normal file

File diff suppressed because it is too large Load Diff

255
moo/mooutils/moofontsel.h Normal file
View File

@ -0,0 +1,255 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* GtkFontSelection widget for Gtk+, by Damon Chaplin, May 1998.
* Based on the GnomeFontSelector widget, by Elliot Lee, but major changes.
* The GnomeFontSelector was derived from app/text_tool.c in the GIMP.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
/*
* gtkfontsel.* copied and modified to allow choosing monospace fonts
*/
#ifndef __MOO_FONTSEL_H__
#define __MOO_FONTSEL_H__
#include <gdk/gdk.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtkvbox.h>
G_BEGIN_DECLS
#define MOO_TYPE_FONT_SELECTION (moo_font_selection_get_type ())
#define MOO_FONT_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOO_TYPE_FONT_SELECTION, MooFontSelection))
#define MOO_FONT_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_FONT_SELECTION, MooFontSelectionClass))
#define MOO_IS_FONT_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOO_TYPE_FONT_SELECTION))
#define MOO_IS_FONT_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_FONT_SELECTION))
#define MOO_FONT_SELECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_FONT_SELECTION, MooFontSelectionClass))
#define MOO_TYPE_FONT_SELECTION_DIALOG (moo_font_selection_dialog_get_type ())
#define MOO_FONT_SELECTION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOO_TYPE_FONT_SELECTION_DIALOG, MooFontSelectionDialog))
#define MOO_FONT_SELECTION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_FONT_SELECTION_DIALOG, MooFontSelectionDialogClass))
#define MOO_IS_FONT_SELECTION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOO_TYPE_FONT_SELECTION_DIALOG))
#define MOO_IS_FONT_SELECTION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_FONT_SELECTION_DIALOG))
#define MOO_FONT_SELECTION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_FONT_SELECTION_DIALOG, MooFontSelectionDialogClass))
typedef struct _MooFontSelection MooFontSelection;
typedef struct _MooFontSelectionClass MooFontSelectionClass;
typedef struct _MooFontSelectionDialog MooFontSelectionDialog;
typedef struct _MooFontSelectionDialogClass MooFontSelectionDialogClass;
struct _MooFontSelection
{
GtkVBox parent_instance;
gboolean monospace;
GtkWidget *font_entry;
GtkWidget *family_list;
GtkWidget *font_style_entry;
GtkWidget *face_list;
GtkWidget *size_entry;
GtkWidget *size_list;
GtkWidget *pixels_button;
GtkWidget *points_button;
GtkWidget *filter_button;
GtkWidget *preview_entry;
PangoFontFamily *family; /* Current family */
PangoFontFace *face; /* Current face */
gint size;
};
struct _MooFontSelectionClass
{
GtkVBoxClass parent_class;
/* Padding for future expansion */
void (*_moo_reserved1) (void);
void (*_moo_reserved2) (void);
void (*_moo_reserved3) (void);
void (*_moo_reserved4) (void);
};
struct _MooFontSelectionDialog
{
GtkDialog parent_instance;
/*< private >*/
GtkWidget *fontsel;
GtkWidget *main_vbox;
GtkWidget *action_area;
/*< public >*/
GtkWidget *ok_button;
GtkWidget *apply_button;
GtkWidget *cancel_button;
/*< private >*/
/* If the user changes the width of the dialog, we turn auto-shrink off.
* (Unused now, autoshrink doesn't mean anything anymore -Yosh)
*/
gint dialog_width;
gboolean auto_resize;
};
struct _MooFontSelectionDialogClass
{
GtkDialogClass parent_class;
/* Padding for future expansion */
void (*_moo_reserved1) (void);
void (*_moo_reserved2) (void);
void (*_moo_reserved3) (void);
void (*_moo_reserved4) (void);
};
/*****************************************************************************
* MooFontSelection functions.
* see the comments in the MooFontSelectionDialog functions.
*****************************************************************************/
GType moo_font_selection_get_type (void) G_GNUC_CONST;
GtkWidget* moo_font_selection_new (void);
gchar* moo_font_selection_get_font_name (MooFontSelection *fontsel);
gboolean moo_font_selection_set_font_name (MooFontSelection *fontsel,
const gchar *fontname);
G_CONST_RETURN gchar* moo_font_selection_get_preview_text (MooFontSelection *fontsel);
void moo_font_selection_set_preview_text (MooFontSelection *fontsel,
const gchar *text);
void moo_font_selection_set_monospace (MooFontSelection *fontsel,
gboolean monospace);
/*****************************************************************************
* MooFontSelectionDialog functions.
* most of these functions simply call the corresponding function in the
* MooFontSelection.
*****************************************************************************/
GType moo_font_selection_dialog_get_type (void) G_GNUC_CONST;
GtkWidget* moo_font_selection_dialog_new (const gchar *title);
/* This returns the X Logical Font Description fontname, or NULL if no font
is selected. Note that there is a slight possibility that the font might not
have been loaded OK. You should call moo_font_selection_dialog_get_font()
to see if it has been loaded OK.
You should g_free() the returned font name after you're done with it. */
gchar* moo_font_selection_dialog_get_font_name (MooFontSelectionDialog *fsd);
/* This sets the currently displayed font. It should be a valid X Logical
Font Description font name (anything else will be ignored), e.g.
"-adobe-courier-bold-o-normal--25-*-*-*-*-*-*-*"
It returns TRUE on success. */
gboolean moo_font_selection_dialog_set_font_name (MooFontSelectionDialog *fsd,
const gchar *fontname);
/* This returns the text in the preview entry. You should copy the returned
text if you need it. */
G_CONST_RETURN gchar* moo_font_selection_dialog_get_preview_text (MooFontSelectionDialog *fsd);
/* This sets the text in the preview entry. It will be copied by the entry,
so there's no need to g_strdup() it first. */
void moo_font_selection_dialog_set_preview_text (MooFontSelectionDialog *fsd,
const gchar *text);
/* MooFontButton is a button widget that allow user to select a font.
*/
#define MOO_TYPE_FONT_BUTTON (moo_font_button_get_type ())
#define MOO_FONT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOO_TYPE_FONT_BUTTON, MooFontButton))
#define MOO_FONT_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_FONT_BUTTON, MooFontButtonClass))
#define MOO_IS_FONT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOO_TYPE_FONT_BUTTON))
#define MOO_IS_FONT_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_FONT_BUTTON))
#define MOO_FONT_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_FONT_BUTTON, MooFontButtonClass))
typedef struct _MooFontButton MooFontButton;
typedef struct _MooFontButtonClass MooFontButtonClass;
typedef struct _MooFontButtonPrivate MooFontButtonPrivate;
struct _MooFontButton {
GtkButton button;
/*< private >*/
MooFontButtonPrivate *priv;
};
struct _MooFontButtonClass {
GtkButtonClass parent_class;
/* font_set signal is emitted when font is chosen */
void (* font_set) (MooFontButton *gfp);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GType moo_font_button_get_type (void) G_GNUC_CONST;
GtkWidget *moo_font_button_new (void);
GtkWidget *moo_font_button_new_with_font (const gchar *fontname);
G_CONST_RETURN gchar *moo_font_button_get_title (MooFontButton *font_button);
void moo_font_button_set_title (MooFontButton *font_button,
const gchar *title);
gboolean moo_font_button_get_use_font (MooFontButton *font_button);
void moo_font_button_set_use_font (MooFontButton *font_button,
gboolean use_font);
gboolean moo_font_button_get_use_size (MooFontButton *font_button);
void moo_font_button_set_use_size (MooFontButton *font_button,
gboolean use_size);
G_CONST_RETURN gchar* moo_font_button_get_font_name (MooFontButton *font_button);
gboolean moo_font_button_set_font_name (MooFontButton *font_button,
const gchar *fontname);
gboolean moo_font_button_get_show_style (MooFontButton *font_button);
void moo_font_button_set_show_style (MooFontButton *font_button,
gboolean show_style);
gboolean moo_font_button_get_show_size (MooFontButton *font_button);
void moo_font_button_set_show_size (MooFontButton *font_button,
gboolean show_size);
gboolean moo_font_button_get_monospace (MooFontButton *font_button);
void moo_font_button_set_monospace (MooFontButton *font_button,
gboolean monospace);
G_END_DECLS
#endif /* __MOO_FONTSEL_H__ */

View File

@ -18,6 +18,7 @@
#include "mooutils/mooprefs.h"
#include "mooutils/mooprefsdialogpage.h"
#include "mooutils/mooutils-gobject.h"
#include "mooutils/moofontsel.h"
#include <string.h>
@ -541,12 +542,13 @@ setting_get_value (GtkWidget *widget,
return TRUE;
}
}
else if (GTK_IS_FONT_BUTTON (widget))
else if (GTK_IS_FONT_BUTTON (widget) || MOO_IS_FONT_BUTTON (widget))
{
if (value->g_type == G_TYPE_STRING)
{
const char *val = gtk_font_button_get_font_name (GTK_FONT_BUTTON (widget));
g_value_set_string (value, val);
char *val = NULL;
g_object_get (widget, "font-name", &val, NULL);
g_value_take_string (value, val);
return TRUE;
}
}
@ -622,7 +624,7 @@ static void setting_set_value (GtkWidget *widget,
return;
}
}
else if (GTK_IS_FONT_BUTTON (widget))
else if (GTK_IS_FONT_BUTTON (widget) || MOO_IS_FONT_BUTTON (widget))
{
if (value->g_type == G_TYPE_STRING)
{