Moved font capplet backt o original GUI and made it to work otherwise

This commit is contained in:
Lauris Kaplinski 2002-03-26 22:56:20 +00:00
parent c8d6823d9c
commit ff128913a4
3 changed files with 194 additions and 195 deletions

View file

@ -1,6 +1,17 @@
2002-03-17 Jonathan Blandford <set EMAIL_ADDRESS environment variable>
2002-03-27 Lauris Kaplinski <lauris@ximian.com>
reviewed by: <delete if not using a buddy>
* main.c (response_cb): No responses here
(font_capplet_custom_toggled): New signal handler
(font_capplet_font_set): Ditto
(font_capplet_value_notify): Ditto
(setup_dialog): Removed peditor stuff, as I do not know, how to
mix it with NULL == unset, string == set
(main): Get GConfClient and activate directory
* font-properties.glade: Reverted to original version,
added label telling about applying
2002-03-17 Jonathan Blandford <jrb@redhat.com>
* font-properties.glade:
* main.c: (setup_dialog):

View file

@ -1,177 +1,69 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd" >
<!DOCTYPE glade-interface SYSTEM "../glade-2.0.dtd" >
<glade-interface>
<requires lib="gnome" />
<requires lib="gnome"/>
<widget class="GtkDialog" id="window1">
<property name="title" translatable="yes">Font Preferences</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="modal">no</property>
<property name="allow_shrink">no</property>
<property name="allow_grow">no</property>
<property name="title" translatable="yes">Font properties</property>
<property name="visible">yes</property>
<property name="window-position">GTK_WIN_POS_NONE</property>
<signal name="destroy" handler="gtk_main_quit" />
<signal name="response" handler="response_cb" />
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="homogeneous">no</property>
<property name="spacing">0</property>
<property name="visible">yes</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">8</property>
<property name="visible">yes</property>
<child>
<widget class="GtkButton" id="button2">
<property name="can_default">yes</property>
<property name="can_focus">yes</property>
<property name="visible">yes</property>
<property name="label">gtk-close</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">yes</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<widget class="GtkVBox" id="vbox1">
<property name="spacing">4</property>
<child>
<widget class="GtkVBox" id="vbox5">
<property name="border_width">10</property>
<property name="homogeneous">no</property>
<property name="spacing">10</property>
<widget class="GtkCheckButton" id="custom_check">
<property name="label" translatable="yes">Use a custom font.</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="expand">no</property>
</packing>
</child>
<child>
<widget class="GnomeFontPicker" id="font_picker">
<property name="mode">font-info</property>
<property name="use-font-in-label">yes</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="expand">no</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="label" translatable="yes">Font settings only apply to new programs.</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">yes</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="fill">yes</property>
<property name="expand">yes</property>
</packing>
</child>
</widget>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="buttonbox1">
<child>
<widget class="GtkButton" id="button2">
<property name="label">gtk-close</property>
<property name="use_stock">yes</property>
<property name="use_underline">yes</property>
<property name="response_id">2</property>
<property name="visible">yes</property>
<child>
<widget class="GtkFrame" id="frame1">
<property name="label" translatable="yes">Desktop Font</property>
<property name="label_xalign">0</property>
<property name="width-request">250</property>
<property name="shadow">GTK_SHADOW_NONE</property>
<property name="visible">yes</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="homogeneous">no</property>
<property name="spacing">10</property>
<property name="visible">yes</property>
<child>
<widget class="GnomeFontPicker" id="font_picker">
<property name="can_focus">yes</property>
<property name="title" translatable="yes">Select the desktop font</property>
<property name="preview_text" translatable="yes">AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz</property>
<property name="mode">GNOME_FONT_PICKER_MODE_FONT_INFO</property>
<property name="show_size">yes</property>
<property name="label-font-size">14</property>
<property name="use-font-in-label">yes</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button3">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Set to Default</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame2">
<property name="label" translatable="yes">File Manager Font</property>
<property name="label_xalign">0</property>
<property name="shadow">GTK_SHADOW_NONE</property>
<property name="visible">yes</property>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="homogeneous">no</property>
<property name="spacing">10</property>
<property name="visible">yes</property>
<child>
<widget class="GnomeFontPicker" id="fontpicker2">
<property name="can_focus">yes</property>
<property name="title" translatable="yes">Pick a Font</property>
<property name="preview_text" translatable="yes">AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz</property>
<property name="mode">GNOME_FONT_PICKER_MODE_FONT_INFO</property>
<property name="show_size">yes</property>
<property name="label-font-size">14</property>
<property name="use-font-in-label">yes</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button4">
<property name="can_focus">yes</property>
<property name="label" translatable="yes">Set to Default</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="visible">yes</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">no</property>
<property name="fill">no</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">4</property>
<property name="expand">yes</property>
<property name="fill">yes</property>
</packing>
</child>
</widget>
</glade-interface>

View file

@ -1,56 +1,150 @@
#define __GPM_PRINTER_C__
/*
* GNOME Print Manager
*
* This program 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.
*
* This program 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.
*
* Authors:
* <Write your name here if you are>
* Lauris Kaplinski <lauris@ximian.com>
*
* Copyright (C) 2002 Ximian, Inc. and authors
*/
#include <config.h>
#include <gnome.h>
#include <string.h>
#include <gconf/gconf-client.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-program.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtktogglebutton.h>
#include <libgnomeui/gnome-ui-init.h>
#include <libgnomeui/gnome-font-picker.h>
#include <glade/glade.h>
#include "gconf-property-editor.h"
#include "activate-settings-daemon.h"
static GladeXML *xml;
static GConfChangeSet *changeset;
#define FONT_CAPPLET_DIR "/desktop/gnome/interface"
#define FONT_CAPPLET_KEY_FONT_NAME "/desktop/gnome/interface/font_name"
#define WID(w) (glade_xml_get_widget (xml, (w)))
enum
{
RESPONSE_APPLY = 1,
RESPONSE_CLOSE
};
void
response_cb (GtkDialog *dialog, gint r, gpointer data)
{
switch (r)
{
case RESPONSE_APPLY:
gconf_client_commit_change_set (gconf_client_get_default (), changeset, TRUE, NULL);
gtk_main_quit ();
}
/* We may want to revert to the default schema-ed value */
if (!gconf_client_get_bool (gconf_client_get_default (), "/desktop/gnome/interface/use_custom_font", NULL))
{
g_print ("Unsetting\n");
gconf_client_unset (gconf_client_get_default (), "/desktop/gnome/interface/font_name", NULL);
static void
font_capplet_custom_toggled (GtkToggleButton *tb, GConfClient *client)
{
gchar *sval;
sval = gconf_client_get_string (client, FONT_CAPPLET_KEY_FONT_NAME, NULL);
if (gtk_toggle_button_get_active (tb)) {
const gchar *fontname;
/* Use custom font */
fontname = gnome_font_picker_get_font_name (GNOME_FONT_PICKER (WID ("font_picker")));
if (fontname) {
/* We are really nice here */
if (!sval || strcmp (fontname, sval)) {
gconf_client_set_string (client, FONT_CAPPLET_KEY_FONT_NAME, fontname, NULL);
}
}
} else {
/* Do not use custom font */
if (sval) {
gconf_client_unset (client, FONT_CAPPLET_KEY_FONT_NAME, NULL);
}
}
break;
case RESPONSE_CLOSE:
gtk_main_quit ();
break;
gtk_widget_set_sensitive (WID ("font_picker"), gtk_toggle_button_get_active (tb));
if (sval) g_free (sval);
}
static void
font_capplet_font_set (GnomeFontPicker *fp, const gchar *fontname, GConfClient *client)
{
gchar *sval;
sval = gconf_client_get_string (client, FONT_CAPPLET_KEY_FONT_NAME, NULL);
if (fontname) {
if (!sval || strcmp (fontname, sval)) {
gconf_client_set_string (client, FONT_CAPPLET_KEY_FONT_NAME, fontname, NULL);
}
}
if (sval) g_free (sval);
}
static void
font_capplet_value_notify (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
if (entry->value) {
const gchar *sval;
/* We have value set */
sval = gconf_value_get_string (entry->value);
if (sval) {
gnome_font_picker_set_font_name (GNOME_FONT_PICKER (WID ("font_picker")), sval);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("custom_check")), TRUE);
}
} else {
/* No value set */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("custom_check")), FALSE);
}
}
static void
setup_dialog (void)
setup_dialog (GConfClient *client)
{
gchar *sval;
#if 0
GObject *peditor;
peditor = gconf_peditor_new_boolean (NULL, /*changeset,*/ "/desktop/gnome/interface/use_custom_font", WID ("custom_check"), NULL);
gconf_peditor_widget_set_guard (GCONF_PROPERTY_EDITOR (peditor), WID ("font_picker"));
peditor = gconf_peditor_new_font (NULL, /*changeset,*/ "/desktop/gnome/interface/font_name", WID ("font_picker"), NULL);
#endif
/* Set initial values */
sval = gconf_client_get_string (client, FONT_CAPPLET_KEY_FONT_NAME, NULL);
if (sval) gnome_font_picker_set_font_name (GNOME_FONT_PICKER (WID ("font_picker")), sval);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("custom_check")), sval != NULL);
gtk_widget_set_sensitive (WID ("font_picker"), sval != NULL);
if (sval) g_free (sval);
g_signal_connect (G_OBJECT (WID ("custom_check")), "toggled", G_CALLBACK (font_capplet_custom_toggled), client);
g_signal_connect (G_OBJECT (WID ("font_picker")), "font_set", G_CALLBACK (font_capplet_font_set), client);
gconf_client_notify_add (client, FONT_CAPPLET_KEY_FONT_NAME, font_capplet_value_notify, NULL, NULL, NULL);
}
int
main (int argc, char **argv)
{
GConfClient *client;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
@ -60,14 +154,16 @@ main (int argc, char **argv)
xml = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/font-properties.glade", NULL, NULL);
changeset = gconf_change_set_new ();
setup_dialog ();
activate_settings_daemon ();
client = gconf_client_get_default ();
gconf_client_add_dir (client, FONT_CAPPLET_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
setup_dialog (client);
glade_xml_signal_autoconnect (xml);
gtk_main ();
gconf_change_set_unref (changeset);
return 0;
}