[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][TOP]
PATCH: add the printing fonts to preference for gedit
- To: gnome-devel@xxxxxxxxxxx
- Subject: PATCH: add the printing fonts to preference for gedit
- From: Akira TAGOH <tagoh@xxxxxxxxxxx>
- Date: Thu, 14 Feb 2002 00:51:34 +0900 (JST)
- Organization: Japan GNOME Users Group
たごうです.
geditの中でHelveticaとCourierがハードコーディングされてるた
めに日本語とかが印刷/プレビューできないので,設定から変えら
れるようにするためのパッチを書いてみました.
CVS用とちょっと古いですが0.9.4用と作ってみましたが,一応CVS
用だけ流しときます.
--
Akira TAGOH : tagoh@xxxxxxxxxxx / Japan GNOME Users Group
at@xxxxxxxxx : tagoh@xxxxxxxxxxxx / GNOME-DB Project
: tagoh@xxxxxxxxxx / Red Hat, Inc.
: tagoh@xxxxxxxxxx / Debian Project
Index: src/prefs.c
===================================================================
RCS file: /cvs/gnome/gedit/src/Attic/prefs.c,v
retrieving revision 1.41
diff -u -r1.41 prefs.c
--- src/prefs.c 2001/09/11 04:52:32 1.41
+++ src/prefs.c 2002/02/13 12:38:35
@@ -41,6 +41,8 @@
#define DEFAULT_FONT (const gchar*) N_("-adobe-courier-medium-r-normal-*-*-120-*-*-m-*-iso8859-1")
#define DEFAULT_FONTSET "-*-*-medium-r-normal-*-14-*-*-*-*-*-*-*,*"
+#define GEDIT_PRINT_BODY_FONT _("Courier")
+#define GEDIT_PRINT_HEADER_FONT _("Helvetica")
void
gedit_prefs_save_settings (void)
@@ -92,6 +94,8 @@
gnome_config_set_int ("height", (gint) settings->height);
}
+ gnome_config_set_string ("header_font", settings->header_font);
+ gnome_config_set_string ("body_font", settings->body_font);
gnome_config_set_bool ("printwrap", settings->print_wrap_lines);
gnome_config_set_bool ("printheader", settings->print_header);
gnome_config_set_int ("printlines", settings->print_lines);
@@ -157,6 +161,14 @@
settings->width = gnome_config_get_int ("width=600");
settings->height = gnome_config_get_int ("height=400");
+ settings->header_font = gnome_config_get_string ("header_font");
+ settings->body_font = gnome_config_get_string ("body_font");
+ if (settings->header_font == NULL) {
+ settings->font = g_strdup (GEDIT_PRINT_HEADER_FONT);
+ }
+ if (settings->body_font == NULL) {
+ settings->font = g_strdup (GEDIT_PRINT_BODY_FONT);
+ }
settings->print_wrap_lines = gnome_config_get_bool ("printwrap=TRUE");
settings->print_header = gnome_config_get_bool ("printheader=TRUE");
settings->print_lines = gnome_config_get_int ("printlines=0");
Index: src/prefs.h
===================================================================
RCS file: /cvs/gnome/gedit/src/Attic/prefs.h,v
retrieving revision 1.20
diff -u -r1.20 prefs.h
--- src/prefs.h 2001/05/10 10:11:03 1.20
+++ src/prefs.h 2002/02/13 12:38:35
@@ -70,6 +70,8 @@
gint print_header;
gint print_orientation;
gchar *papersize;
+ gchar *header_font;
+ gchar *body_font;
};
extern Preferences *settings;
Index: src/print-util.c
===================================================================
RCS file: /cvs/gnome/gedit/src/Attic/print-util.c,v
retrieving revision 1.4
diff -u -r1.4 print-util.c
--- src/print-util.c 2001/06/04 12:17:24 1.4
+++ src/print-util.c 2002/02/13 12:38:35
@@ -31,6 +31,7 @@
#include "window.h"
#include "print.h" /* for the defined fontnames */
#include "print-util.h"
+#include "prefs.h"
#define _PROPER_I18N
@@ -215,8 +216,10 @@
gedit_debug (DEBUG_PRINT, "");
/* Courier */
- test_font_name = g_strdup (GEDIT_PRINT_FONT_BODY);
- test_font = gnome_font_new (test_font_name, 10);
+ test_font_name = g_strdup (settings->body_font);
+ test_font = gnome_font_new_closest (test_font_name,
+ GNOME_FONT_BOOK,
+ FALSE, 10);
if (test_font==NULL)
{
gchar *errstr = g_strdup_printf (_("gedit could not find the font \"%s\".\n"
@@ -230,8 +233,10 @@
g_free (test_font_name);
/* Helvetica */
- test_font_name = g_strdup (GEDIT_PRINT_FONT_HEADER);
- test_font = gnome_font_new (test_font_name, 10);
+ test_font_name = g_strdup (settings->header_font);
+ test_font = gnome_font_new_closest (test_font_name,
+ GNOME_FONT_BOOK,
+ FALSE, 10);
if (test_font==NULL)
{
gchar *errstr = g_strdup_printf (_("gedit could not find the font \"%s\".\n"
Index: src/print.c
===================================================================
RCS file: /cvs/gnome/gedit/src/Attic/print.c,v
retrieving revision 1.55
diff -u -r1.55 print.c
--- src/print.c 2001/05/15 13:02:15 1.55
+++ src/print.c 2002/02/13 12:38:35
@@ -133,12 +133,18 @@
pji->font_char_width = 0.0808 * 72; /* Get this from the font itself !! */
pji->font_char_height = .14 * 72;
- pji->font_body = gnome_font_new (GEDIT_PRINT_FONT_BODY,
- GEDIT_PRINT_FONT_SIZE_BODY);
- pji->font_header = gnome_font_new (GEDIT_PRINT_FONT_HEADER,
- GEDIT_PRINT_FONT_SIZE_HEADER);
- pji->font_numbers = gnome_font_new (GEDIT_PRINT_FONT_BODY,
- GEDIT_PRINT_FONT_SIZE_NUMBERS);
+ pji->font_body = gnome_font_new_closest (settings->body_font,
+ GNOME_FONT_BOOK,
+ FALSE,
+ GEDIT_PRINT_FONT_SIZE_BODY);
+ pji->font_header = gnome_font_new_closest (settings->header_font,
+ GNOME_FONT_BOOK,
+ FALSE,
+ GEDIT_PRINT_FONT_SIZE_HEADER);
+ pji->font_numbers = gnome_font_new_closest (settings->body_font,
+ GNOME_FONT_BOOK,
+ FALSE,
+ GEDIT_PRINT_FONT_SIZE_NUMBERS);
g_return_val_if_fail (GNOME_IS_FONT (pji->font_body), NULL);
g_return_val_if_fail (GNOME_IS_FONT (pji->font_header), NULL);
Index: src/print.h
===================================================================
RCS file: /cvs/gnome/gedit/src/Attic/print.h,v
retrieving revision 1.7
diff -u -r1.7 print.h
--- src/print.h 2001/02/27 02:55:42 1.7
+++ src/print.h 2002/02/13 12:38:35
@@ -30,8 +30,6 @@
PRINT_ORIENT_PORTRAIT
} GeditPrintOrientation;
-#define GEDIT_PRINT_FONT_BODY "Courier"
-#define GEDIT_PRINT_FONT_HEADER "Helvetica"
#define GEDIT_PRINT_FONT_SIZE_BODY 10
#define GEDIT_PRINT_FONT_SIZE_HEADER 12
#define GEDIT_PRINT_FONT_SIZE_NUMBERS 6
Index: src/dialogs/dialog-prefs.c
===================================================================
RCS file: /cvs/gnome/gedit/src/dialogs/Attic/dialog-prefs.c,v
retrieving revision 1.37
diff -u -r1.37 dialog-prefs.c
--- src/dialogs/dialog-prefs.c 2001/02/12 03:07:58 1.37
+++ src/dialogs/dialog-prefs.c 2002/02/13 12:38:35
@@ -24,11 +24,13 @@
#include <config.h>
#include <glib.h>
#include <gtk/gtkwidget.h>
+#include <gtk/gtkcombo.h>
#include <libgnome/libgnome.h>
#include <libgnomeui/gnome-font-picker.h>
#include <libgnomeui/gnome-paper-selector.h>
#include <libgnomeui/gnome-color-picker.h>
#include <libgnomeui/gnome-propertybox.h>
+#include <libgnomeprint/gnome-font.h>
#include <glade/glade.h>
#include <string.h> /* For strcmp */
@@ -62,12 +64,16 @@
static GtkWidget *print_orientation_portrait_radio_button;
static GtkWidget *print_lines_spin_button;
static GtkWidget *lines_label;
+static GtkWidget *print_headerfont;
+static GtkWidget *print_bodyfont;
static GtkWidget *paperselector;
static GtkWidget *undo_levels;
static GtkWidget *undo_levels_spin_button;
static GtkWidget *undo_levels_label;
+static GList *gedit_font_family_list = NULL;
+
static gint
gtk_option_menu_get_active_index (GtkWidget *omenu)
{
@@ -102,7 +108,15 @@
static void
destroy_cb (void)
{
+ GList *l;
+
gedit_debug (DEBUG_PREFS, "");
+
+ for (l = gedit_font_family_list; l; l = l->next)
+ g_free (l->data);
+ g_list_free (gedit_font_family_list);
+ gedit_font_family_list = NULL;
+
gtk_widget_destroy (GTK_WIDGET (propertybox));
propertybox = NULL;
}
@@ -155,6 +169,8 @@
else
settings->print_orientation = PRINT_ORIENT_LANDSCAPE;
+ settings->header_font = g_strdup (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (print_headerfont)->entry)));
+ settings->body_font = g_strdup (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (print_bodyfont)->entry)));
settings->print_header = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (print_header));
settings->print_wrap_lines = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (print_wrap));
@@ -476,6 +492,8 @@
static void
prepare_printing_page (GladeXML *gui)
{
+ GList *l, *ll;
+
gedit_debug (DEBUG_PREFS, "");
print_header = glade_xml_get_widget (gui, "printheader");
@@ -485,18 +503,30 @@
print_wrap = glade_xml_get_widget (gui, "printwrap");
print_orientation_portrait_radio_button = glade_xml_get_widget (gui,
"print_orientation_portrait_radio_button");
+ print_headerfont = glade_xml_get_widget (gui, "headerfont");
+ print_bodyfont = glade_xml_get_widget (gui, "bodyfont");
if ( !print_header ||
!print_lines ||
!print_lines_spin_button ||
!lines_label ||
!print_wrap ||
- !print_orientation_portrait_radio_button)
+ !print_orientation_portrait_radio_button ||
+ !print_headerfont ||
+ !print_bodyfont)
{
g_warning ("Could not load the widgets for the print page.");
return;
}
+ /* initialize family name lists */
+ l = gnome_font_family_list ();
+ for (ll = l; ll; ll = ll->next) {
+ gedit_font_family_list = g_list_insert_sorted (
+ gedit_font_family_list, g_strdup (ll->data), (GCompareFunc)strcmp);
+ }
+ gnome_font_family_list_free (l);
+
/* set initial button states */
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (print_header),
settings->print_header);
@@ -517,7 +547,36 @@
}
else
gtk_spin_button_set_value(GTK_SPIN_BUTTON( print_lines_spin_button), (gint)settings->print_lines);
-
+
+ gtk_combo_set_popdown_strings (GTK_COMBO (print_headerfont),
+ gedit_font_family_list);
+ gtk_combo_set_popdown_strings (GTK_COMBO (print_bodyfont),
+ gedit_font_family_list);
+ gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (print_headerfont)->entry),
+ FALSE);
+ gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (print_bodyfont)->entry),
+ FALSE);
+
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (print_headerfont)->entry),
+ "Helvetica");
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (print_bodyfont)->entry),
+ "Courier");
+ if (settings->header_font) {
+ if (g_list_find_custom (gedit_font_family_list,
+ settings->header_font,
+ (GCompareFunc)strcmp)) {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (print_headerfont)->entry),
+ settings->header_font);
+ }
+ }
+ if (settings->body_font) {
+ if (g_list_find_custom (gedit_font_family_list,
+ settings->body_font,
+ (GCompareFunc)strcmp)) {
+ gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (print_bodyfont)->entry),
+ settings->body_font);
+ }
+ }
/* connect signals */
gtk_signal_connect (GTK_OBJECT (print_header), "toggled",
@@ -530,6 +589,10 @@
"value_changed", GTK_SIGNAL_FUNC (prefs_changed), NULL);
gtk_signal_connect (GTK_OBJECT (print_orientation_portrait_radio_button),
"toggled", GTK_SIGNAL_FUNC (prefs_changed), NULL);
+ gtk_signal_connect (GTK_OBJECT (GTK_EDITABLE (GTK_COMBO (print_headerfont)->entry)), "changed",
+ GTK_SIGNAL_FUNC (prefs_changed), NULL);
+ gtk_signal_connect (GTK_OBJECT (GTK_EDITABLE (GTK_COMBO (print_bodyfont)->entry)), "changed",
+ GTK_SIGNAL_FUNC (prefs_changed), NULL);
}
static void
Index: src/dialogs/prefs.glade
===================================================================
RCS file: /cvs/gnome/gedit/src/dialogs/Attic/prefs.glade,v
retrieving revision 1.17
diff -u -r1.17 prefs.glade
--- src/dialogs/prefs.glade 2001/11/13 14:01:40 1.17
+++ src/dialogs/prefs.glade 2002/02/13 12:38:36
@@ -884,6 +884,153 @@
</widget>
</widget>
</widget>
+
+ <widget>
+ <class>GtkFrame</class>
+ <name>frame10</name>
+ <label>Font</label>
+ <label_xalign>0</label_xalign>
+ <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkTable</class>
+ <name>table6</name>
+ <rows>2</rows>
+ <columns>2</columns>
+ <homogeneous>False</homogeneous>
+ <row_spacing>0</row_spacing>
+ <column_spacing>0</column_spacing>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label15</name>
+ <label>Header Font: </label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>1</right_attach>
+ <top_attach>0</top_attach>
+ <bottom_attach>1</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>False</xexpand>
+ <yexpand>False</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>False</yfill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label16</name>
+ <label>Body Font: </label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <left_attach>0</left_attach>
+ <right_attach>1</right_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>False</xexpand>
+ <yexpand>False</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>False</yfill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkCombo</class>
+ <name>headerfont</name>
+ <value_in_list>False</value_in_list>
+ <ok_if_empty>False</ok_if_empty>
+ <case_sensitive>False</case_sensitive>
+ <use_arrows>True</use_arrows>
+ <use_arrows_always>False</use_arrows_always>
+ <items></items>
+ <child>
+ <left_attach>1</left_attach>
+ <right_attach>2</right_attach>
+ <top_attach>0</top_attach>
+ <bottom_attach>1</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>False</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>False</yfill>
+ </child>
+
+ <widget>
+ <class>GtkEntry</class>
+ <child_name>GtkCombo:entry</child_name>
+ <name>combo-entry1</name>
+ <can_focus>True</can_focus>
+ <editable>True</editable>
+ <text_visible>True</text_visible>
+ <text_max_length>0</text_max_length>
+ <text></text>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkCombo</class>
+ <name>bodyfont</name>
+ <value_in_list>False</value_in_list>
+ <ok_if_empty>False</ok_if_empty>
+ <case_sensitive>False</case_sensitive>
+ <use_arrows>True</use_arrows>
+ <use_arrows_always>False</use_arrows_always>
+ <items></items>
+ <child>
+ <left_attach>1</left_attach>
+ <right_attach>2</right_attach>
+ <top_attach>1</top_attach>
+ <bottom_attach>2</bottom_attach>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <xexpand>True</xexpand>
+ <yexpand>False</yexpand>
+ <xshrink>False</xshrink>
+ <yshrink>False</yshrink>
+ <xfill>True</xfill>
+ <yfill>False</yfill>
+ </child>
+
+ <widget>
+ <class>GtkEntry</class>
+ <child_name>GtkCombo:entry</child_name>
+ <name>combo-entry2</name>
+ <can_focus>True</can_focus>
+ <editable>True</editable>
+ <text_visible>True</text_visible>
+ <text_max_length>0</text_max_length>
+ <text></text>
+ </widget>
+ </widget>
+ </widget>
+ </widget>
</widget>
<widget>