fill the Preferences tab with life

2007-05-01  Jens Granseuer  <jensgr@gmx.net>

	* appearance-main.c: (main):
	* appearance-ui.c:
	* appearance-ui.h:
	* appearance.h:
	* appearance.glade:

	fill the Preferences tab with life

svn path=/trunk/; revision=7530
This commit is contained in:
Jens Granseuer 2007-05-01 13:02:29 +00:00 committed by Jens Granseuer
parent 93bc8933ef
commit e794639a0c
6 changed files with 345 additions and 69 deletions

View file

@ -1,3 +1,13 @@
2007-05-01 Jens Granseuer <jensgr@gmx.net>
* appearance-main.c: (main):
* appearance-ui.c:
* appearance-ui.h:
* appearance.h:
* appearance.glade:
fill the Preferences tab with life
2007-05-01 Jens Granseuer <jensgr@gmx.net> 2007-05-01 Jens Granseuer <jensgr@gmx.net>
* appearance-main.c: (init_appearance_data), (main): * appearance-main.c: (init_appearance_data), (main):

View file

@ -20,6 +20,7 @@
#include "appearance.h" #include "appearance.h"
#include "appearance-themes.h" #include "appearance-themes.h"
#include "appearance-ui.h"
#include "theme-thumbnail.h" #include "theme-thumbnail.h"
#include "activate-settings-daemon.h" #include "activate-settings-daemon.h"
@ -80,6 +81,7 @@ main (int argc, char **argv)
/* init tabs */ /* init tabs */
themes_init (data); themes_init (data);
ui_init (data);
/* /*
* fonts_init (data); * fonts_init (data);
* desktop_init (data); * desktop_init (data);
@ -95,6 +97,7 @@ main (int argc, char **argv)
gtk_main (); gtk_main ();
/* free stuff */ /* free stuff */
ui_shutdown (data);
g_object_unref (data->client); g_object_unref (data->client);
g_object_unref (data->xml); g_object_unref (data->xml);
g_free (data); g_free (data);

View file

@ -0,0 +1,252 @@
/*
* Copyright (C) 2007 The GNOME Foundation
* Written by Jonathan Blandford <jrb@gnome.org>
* Jens Granseuer <jensgr@gmx.net>
* All Rights Reserved
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "appearance.h"
#include "gconf-property-editor.h"
static GConfEnumStringPair toolbar_style_enums[] = {
{ 0, "both" },
{ 1, "both-horiz" },
{ 2, "icons" },
{ 3, "text" },
{ -1, NULL }
};
static void
show_handlebar (AppearanceData *data, gboolean show)
{
GtkWidget *handlebox = WID ("toolbar_handlebox");
GtkWidget *toolbar = WID ("toolbar_toolbar");
GtkWidget *align = WID ("toolbar_align");
g_object_ref (handlebox);
g_object_ref (toolbar);
if (GTK_BIN (align)->child)
gtk_container_remove (GTK_CONTAINER (align), GTK_BIN (align)->child);
if (GTK_BIN (handlebox)->child)
gtk_container_remove (GTK_CONTAINER (handlebox), GTK_BIN (handlebox)->child);
if (show) {
gtk_container_add (GTK_CONTAINER (align), handlebox);
gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
g_object_unref (handlebox);
} else {
gtk_container_add (GTK_CONTAINER (align), toolbar);
}
g_object_unref (toolbar);
}
static void
set_toolbar_style (AppearanceData *data, const char *value)
{
static const GtkToolbarStyle gtk_toolbar_styles[] =
{ GTK_TOOLBAR_BOTH, GTK_TOOLBAR_BOTH_HORIZ, GTK_TOOLBAR_ICONS, GTK_TOOLBAR_TEXT };
int enum_val;
if (!gconf_string_to_enum (toolbar_style_enums, value, &enum_val))
enum_val = 0;
gtk_toolbar_set_style (GTK_TOOLBAR (WID("toolbar_toolbar")),
gtk_toolbar_styles[enum_val]);
}
static void
set_have_icons (AppearanceData *data, gboolean value)
{
static const char *menu_item_names[] = {
"menu_item_1",
"menu_item_2",
"menu_item_3",
"menu_item_4",
"menu_item_5",
"cut",
"copy",
"paste",
NULL
};
const char **name;
for (name = menu_item_names; *name != NULL; name++) {
GtkImageMenuItem *item = GTK_IMAGE_MENU_ITEM (WID (*name));
GtkWidget *image;
if (value) {
image = g_object_get_data (G_OBJECT (item), "image");
if (image) {
gtk_image_menu_item_set_image (item, image);
g_object_unref (image);
}
} else {
image = gtk_image_menu_item_get_image (item);
g_object_set_data (G_OBJECT (item), "image", image);
g_object_ref (image);
gtk_image_menu_item_set_image (item, NULL);
}
}
}
/** GConf Callbacks and Conversions **/
static GConfValue *
toolbar_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
{
GConfValue *new_value;
new_value = gconf_value_new (GCONF_VALUE_STRING);
gconf_value_set_string (new_value,
gconf_enum_to_string (toolbar_style_enums,
gconf_value_get_int (value)));
return new_value;
}
static GConfValue *
toolbar_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
{
GConfValue *new_value;
const gchar *str;
gint val;
str = (value && (value->type == GCONF_VALUE_STRING)) ?
gconf_value_get_string (value) : NULL;
if (!gconf_string_to_enum (toolbar_style_enums, str, &val))
val = 0;
new_value = gconf_value_new (GCONF_VALUE_INT);
gconf_value_set_int (new_value, val);
return new_value;
}
static void
toolbar_style_cb (GConfPropertyEditor *peditor,
gchar *key,
GConfValue *value,
AppearanceData *data)
{
set_toolbar_style (data, gconf_value_get_string (value));
}
static void
menus_have_icons_cb (GConfPropertyEditor *peditor,
gchar *key,
GConfValue *value,
AppearanceData *data)
{
set_have_icons (data, gconf_value_get_bool (value));
}
static void
toolbar_detachable_cb (GConfClient *client,
const gchar *key,
GConfValue *value,
AppearanceData *data)
{
if (key != NULL &&
strcmp (key, "/desktop/gnome/interface/toolbar_detachable") == 0)
show_handlebar (data, gconf_value_get_bool (value));
}
/** GUI Callbacks **/
static gint
button_press_block_cb (GtkWidget *toolbar,
GdkEvent *event,
gpointer data)
{
return TRUE;
}
/** Public Functions **/
void
ui_init (AppearanceData *data)
{
GSList *peds = NULL;
GObject *peditor;
char *toolbar_style;
gconf_client_add_dir (data->client, "/desktop/gnome/interface",
GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
peditor = gconf_peditor_new_boolean
(NULL, "/desktop/gnome/interface/can_change_accels",
WID ("menu_accel_toggle"), NULL);
g_slist_append (peds, peditor);
peditor = gconf_peditor_new_boolean
(NULL, "/desktop/gnome/interface/menus_have_icons",
WID ("menu_icons_toggle"), NULL);
g_signal_connect (peditor, "value_changed",
G_CALLBACK (menus_have_icons_cb), data);
g_slist_append (peds, peditor);
set_have_icons (data,
gconf_client_get_bool (data->client,
"/desktop/gnome/interface/menus_have_icons",
NULL));
peditor = gconf_peditor_new_select_menu
(NULL, "/desktop/gnome/interface/toolbar_style",
WID ("toolbar_style_omenu"),
"conv-to-widget-cb", toolbar_to_widget,
"conv-from-widget-cb", toolbar_from_widget,
NULL);
g_signal_connect (peditor, "value_changed",
G_CALLBACK (toolbar_style_cb), data);
g_slist_append (peds, peditor);
g_signal_connect (G_OBJECT (WID ("toolbar_handlebox")),
"button_press_event",
G_CALLBACK (button_press_block_cb), NULL);
show_handlebar (data,
gconf_client_get_bool (data->client,
"/desktop/gnome/interface/toolbar_detachable",
NULL));
toolbar_style = gconf_client_get_string
(data->client,
"/desktop/gnome/interface/toolbar_style",
NULL);
set_toolbar_style (data, toolbar_style);
g_free (toolbar_style);
/* no ui for detachable toolbars */
g_signal_connect (G_OBJECT (data->client), "value_changed",
G_CALLBACK (toolbar_detachable_cb), data);
data->peditors = peds;
}
void
ui_shutdown (AppearanceData *data)
{
g_slist_foreach (data->peditors, (GFunc) g_object_unref, NULL);
g_slist_free (data->peditors);
}

View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2007 The GNOME Foundation
* Written by Jens Granseuer <jensgr@gmx.net>
* All Rights Reserved
*
* 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.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
void ui_init (AppearanceData *data);
void ui_shutdown (AppearanceData *data);

View file

@ -1193,7 +1193,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">6</property> <property name="spacing">6</property>
<child> <child>
<widget class="GtkCheckButton" id="menu_icons_toggle2"> <widget class="GtkCheckButton" id="menu_icons_toggle">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Show _icons in menus</property> <property name="label" translatable="yes">Show _icons in menus</property>
@ -1207,22 +1207,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkCheckButton" id="detachable_toolbars_toggle2"> <widget class="GtkCheckButton" id="menu_accel_toggle">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Show icons in buttons</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="menu_accel_toggle2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">_Editable menu shortcut keys</property> <property name="label" translatable="yes">_Editable menu shortcut keys</property>
@ -1235,42 +1220,6 @@
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="spacing">12</property>
<child>
<widget class="GtkLabel" id="label28">
<property name="width_request">150</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Toolbar Icon Size: </property>
<property name="use_underline">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkOptionMenu" id="toolbar_style_omenu3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Small </property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child> <child>
<widget class="GtkHBox" id="hbox8"> <widget class="GtkHBox" id="hbox8">
<property name="visible">True</property> <property name="visible">True</property>
@ -1289,10 +1238,47 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkOptionMenu" id="toolbar_style_omenu2"> <widget class="GtkOptionMenu" id="toolbar_style_omenu">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Icons and Text </property>
<child internal-child="menu">
<widget class="GtkMenu" id="toolbar_style_menu">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="tb_style_text_below_icons">
<property name="visible">True</property>
<property name="label" translatable="yes">Text below icons</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="tb_style_text_beside_icons">
<property name="visible">True</property>
<property name="label" translatable="yes">Text beside icons</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="tb_style_icons_only">
<property name="visible">True</property>
<property name="label" translatable="yes">Icons only</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="tb_style_text_only">
<property name="visible">True</property>
<property name="label" translatable="yes">Text only</property>
<property name="use_underline">True</property>
</widget>
</child>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -1362,14 +1348,14 @@
<widget class="GtkMenuBar" id="menubar3"> <widget class="GtkMenuBar" id="menubar3">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<widget class="GtkMenuItem" id="File Menu2"> <widget class="GtkMenuItem" id="File Menu">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_File</property> <property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<child> <child>
<widget class="GtkMenu" id="File Menu_menu2"> <widget class="GtkMenu" id="File Menu_menu">
<child> <child>
<widget class="GtkImageMenuItem" id="menu_item_11"> <widget class="GtkImageMenuItem" id="menu_item_1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_New</property> <property name="label" translatable="yes">_New</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -1383,7 +1369,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="menu_item_12"> <widget class="GtkImageMenuItem" id="menu_item_2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Open</property> <property name="label" translatable="yes">_Open</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -1397,7 +1383,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="menu_item_13"> <widget class="GtkImageMenuItem" id="menu_item_3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Save</property> <property name="label" translatable="yes">_Save</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -1416,7 +1402,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="menu_item_14"> <widget class="GtkImageMenuItem" id="menu_item_4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Print</property> <property name="label" translatable="yes">_Print</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -1435,7 +1421,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="menu_item_15"> <widget class="GtkImageMenuItem" id="menu_item_5">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Quit</property> <property name="label" translatable="yes">_Quit</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -1460,7 +1446,7 @@
<child> <child>
<widget class="GtkMenu" id="edit1_menu2"> <widget class="GtkMenu" id="edit1_menu2">
<child> <child>
<widget class="GtkImageMenuItem" id="cut3"> <widget class="GtkImageMenuItem" id="cut">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">C_ut</property> <property name="label" translatable="yes">C_ut</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -1474,7 +1460,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="copy3"> <widget class="GtkImageMenuItem" id="copy">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Copy</property> <property name="label" translatable="yes">_Copy</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -1488,7 +1474,7 @@
</widget> </widget>
</child> </child>
<child> <child>
<widget class="GtkImageMenuItem" id="paste3"> <widget class="GtkImageMenuItem" id="paste">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Paste</property> <property name="label" translatable="yes">_Paste</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
@ -1512,14 +1498,14 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkAlignment" id="toolbar_align2"> <widget class="GtkAlignment" id="toolbar_align">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<widget class="GtkHandleBox" id="toolbar_handlebox2"> <widget class="GtkHandleBox" id="toolbar_handlebox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_OUT</property> <property name="shadow_type">GTK_SHADOW_OUT</property>
<child> <child>
<widget class="GtkToolbar" id="toolbar_toolbar2"> <widget class="GtkToolbar" id="toolbar_toolbar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH</property> <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
<child> <child>
@ -1544,7 +1530,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="save_button2"> <widget class="GtkToolButton" id="save_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Save File</property> <property name="tooltip" translatable="yes">Save File</property>
<property name="stock_id">gtk-save</property> <property name="stock_id">gtk-save</property>

View file

@ -32,4 +32,7 @@ typedef struct {
int argc; int argc;
char **argv; char **argv;
GladeXML *xml; GladeXML *xml;
/* ui */
GSList *peditors;
} AppearanceData; } AppearanceData;