2002-01-29 03:26:23 +00:00
|
|
|
/* gnome-ui-properties.c
|
|
|
|
* Copyright (C) 2002 Jonathan Blandford
|
|
|
|
*
|
|
|
|
* Written by: Jonathan Blandford <jrb@gnome.org>
|
|
|
|
*
|
|
|
|
* 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, 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gnome.h>
|
|
|
|
#include <gconf/gconf-client.h>
|
|
|
|
#include <glade/glade.h>
|
|
|
|
|
|
|
|
#include "capplet-util.h"
|
|
|
|
#include "gconf-property-editor.h"
|
|
|
|
|
2002-02-11 04:23:42 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
RESPONSE_APPLY = 1,
|
|
|
|
RESPONSE_CLOSE
|
|
|
|
};
|
2002-01-29 03:26:23 +00:00
|
|
|
|
|
|
|
static GConfEnumStringPair toolbar_style_enums[] = {
|
|
|
|
{ 0, "both" },
|
2003-05-04 23:14:05 +00:00
|
|
|
{ 1, "both-horiz" },
|
2002-05-06 07:18:54 +00:00
|
|
|
{ 2, "icons" },
|
|
|
|
{ 3, "text" },
|
2002-05-14 15:15:56 +00:00
|
|
|
{ -1, NULL }
|
2002-01-29 03:26:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static GConfValue *
|
2002-03-20 03:30:11 +00:00
|
|
|
toolbar_from_widget (GConfPropertyEditor *peditor, GConfValue *value)
|
2002-01-29 03:26:23 +00:00
|
|
|
{
|
|
|
|
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 *
|
2002-03-20 03:30:11 +00:00
|
|
|
toolbar_to_widget (GConfPropertyEditor *peditor, GConfValue *value)
|
2002-01-29 03:26:23 +00:00
|
|
|
{
|
|
|
|
GConfValue *new_value;
|
2002-03-26 16:39:05 +00:00
|
|
|
const gchar *str;
|
2002-01-29 03:26:23 +00:00
|
|
|
gint val = 2;
|
|
|
|
|
2002-03-26 16:39:05 +00:00
|
|
|
str = (value && (value->type == GCONF_VALUE_STRING)) ? gconf_value_get_string (value) : NULL;
|
2002-01-29 03:26:23 +00:00
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
2002-05-14 15:15:56 +00:00
|
|
|
if (!gconf_string_to_enum (toolbar_style_enums, str, &val))
|
|
|
|
val = 0;
|
2002-01-29 03:26:23 +00:00
|
|
|
gconf_value_set_int (new_value, val);
|
|
|
|
|
|
|
|
return new_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2002-02-04 17:48:43 +00:00
|
|
|
dialog_button_clicked_cb (GtkDialog *dialog, gint response_id, GConfChangeSet *changeset)
|
2002-01-29 03:26:23 +00:00
|
|
|
{
|
2002-05-27 02:54:19 +00:00
|
|
|
if (response_id == GTK_RESPONSE_HELP)
|
|
|
|
capplet_help (GTK_WINDOW (dialog),
|
2004-02-12 14:23:03 +00:00
|
|
|
"user-guide.xml",
|
2002-05-29 04:14:29 +00:00
|
|
|
"goscustuserinter-2");
|
2002-05-27 02:54:19 +00:00
|
|
|
else
|
2002-05-09 18:25:46 +00:00
|
|
|
gtk_main_quit ();
|
2002-01-29 03:26:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GladeXML *
|
|
|
|
create_dialog (void)
|
|
|
|
{
|
|
|
|
GladeXML *dialog;
|
|
|
|
|
2007-02-02 18:12:40 +00:00
|
|
|
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/gnome-ui-properties.glade", "gnome_ui_properties_dialog", NULL);
|
2002-01-29 03:26:23 +00:00
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
2002-03-11 04:52:47 +00:00
|
|
|
static void
|
2002-03-21 16:52:26 +00:00
|
|
|
show_handlebar (GladeXML *dialog, gboolean show)
|
2002-03-11 04:52:47 +00:00
|
|
|
{
|
|
|
|
GtkWidget *handlebox;
|
|
|
|
GtkWidget *toolbar;
|
2003-07-18 14:53:12 +00:00
|
|
|
GtkWidget *align;
|
2002-03-11 04:52:47 +00:00
|
|
|
|
|
|
|
handlebox = WID ("toolbar_handlebox");
|
|
|
|
toolbar = WID ("toolbar_toolbar");
|
2003-07-18 14:53:12 +00:00
|
|
|
align = WID ("toolbar_align");
|
2002-03-11 04:52:47 +00:00
|
|
|
|
|
|
|
g_object_ref (handlebox);
|
|
|
|
g_object_ref (toolbar);
|
|
|
|
|
2003-07-18 14:53:12 +00:00
|
|
|
if (GTK_BIN (align)->child)
|
|
|
|
gtk_container_remove (GTK_CONTAINER (align), GTK_BIN (align)->child);
|
2002-03-11 04:52:47 +00:00
|
|
|
if (GTK_BIN (handlebox)->child)
|
|
|
|
gtk_container_remove (GTK_CONTAINER (handlebox), GTK_BIN (handlebox)->child);
|
2002-03-21 16:52:26 +00:00
|
|
|
if (show)
|
2002-03-11 04:52:47 +00:00
|
|
|
{
|
2003-07-18 14:53:12 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (align), handlebox);
|
2002-03-11 04:52:47 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (handlebox), toolbar);
|
|
|
|
g_object_unref (handlebox);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-07-18 14:53:12 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (align), toolbar);
|
2002-03-11 04:52:47 +00:00
|
|
|
}
|
|
|
|
g_object_unref (toolbar);
|
2002-03-21 16:52:26 +00:00
|
|
|
|
|
|
|
|
2002-03-11 04:52:47 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 16:52:26 +00:00
|
|
|
static void
|
|
|
|
set_toolbar_style (GladeXML *dialog, const char *value)
|
|
|
|
{
|
|
|
|
static const GtkToolbarStyle gtk_toolbar_styles[] =
|
2002-04-25 16:53:39 +00:00
|
|
|
{ GTK_TOOLBAR_BOTH, GTK_TOOLBAR_BOTH_HORIZ, GTK_TOOLBAR_ICONS, GTK_TOOLBAR_TEXT };
|
2002-03-21 16:52:26 +00:00
|
|
|
|
|
|
|
int enum_val;
|
|
|
|
|
2002-05-14 15:15:56 +00:00
|
|
|
if (!gconf_string_to_enum (toolbar_style_enums, value, &enum_val))
|
|
|
|
enum_val = 0;
|
2002-03-21 16:52:26 +00:00
|
|
|
|
|
|
|
gtk_toolbar_set_style (GTK_TOOLBAR (WID("toolbar_toolbar")),
|
|
|
|
gtk_toolbar_styles[enum_val]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
toolbar_detachable_cb (GConfPropertyEditor *peditor,
|
|
|
|
gchar *key,
|
|
|
|
GConfValue *value,
|
|
|
|
GladeXML *dialog)
|
|
|
|
{
|
|
|
|
show_handlebar (dialog, gconf_value_get_bool (value));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
toolbar_style_cb (GConfPropertyEditor *peditor,
|
|
|
|
gchar *key,
|
|
|
|
GConfValue *value,
|
|
|
|
GladeXML *dialog)
|
|
|
|
{
|
|
|
|
set_toolbar_style (dialog, gconf_value_get_string (value));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_have_icons (GladeXML *dialog, gboolean value)
|
|
|
|
{
|
|
|
|
static char *menu_item_names[] =
|
|
|
|
{
|
|
|
|
"menu_item_1",
|
|
|
|
"menu_item_2",
|
|
|
|
"menu_item_3",
|
|
|
|
"menu_item_4",
|
|
|
|
"menu_item_5",
|
2002-07-18 03:54:36 +00:00
|
|
|
"cut1",
|
|
|
|
"copy1",
|
|
|
|
"paste1",
|
2002-03-21 16:52:26 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-03-11 04:52:47 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
menus_have_icons_cb (GConfPropertyEditor *peditor,
|
|
|
|
gchar *key,
|
|
|
|
GConfValue *value,
|
|
|
|
GladeXML *dialog)
|
|
|
|
{
|
2002-03-21 16:52:26 +00:00
|
|
|
set_have_icons (dialog, gconf_value_get_bool (value));
|
2002-03-11 04:52:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
button_press_blocker (GtkWidget *toolbar,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-01-29 03:26:23 +00:00
|
|
|
static void
|
|
|
|
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
2002-04-10 12:26:20 +00:00
|
|
|
GObject *peditor;
|
2002-03-21 16:52:26 +00:00
|
|
|
char *toolbar_style;
|
2005-05-22 15:46:45 +00:00
|
|
|
GConfClient *client = gconf_client_get_default ();
|
2002-01-29 03:26:23 +00:00
|
|
|
|
2002-03-11 04:52:47 +00:00
|
|
|
peditor = gconf_peditor_new_boolean
|
2002-01-29 03:26:23 +00:00
|
|
|
(changeset, "/desktop/gnome/interface/toolbar_detachable", WID ("detachable_toolbars_toggle"), NULL);
|
2002-04-10 12:26:20 +00:00
|
|
|
g_signal_connect (peditor,
|
|
|
|
"value_changed",
|
|
|
|
G_CALLBACK (toolbar_detachable_cb), dialog);
|
2002-01-29 03:26:23 +00:00
|
|
|
|
2005-01-13 00:56:07 +00:00
|
|
|
peditor = gconf_peditor_new_boolean
|
|
|
|
(changeset, "/desktop/gnome/interface/can_change_accels", WID ("menu_accel_toggle"), NULL);
|
|
|
|
|
2002-03-11 04:52:47 +00:00
|
|
|
peditor = gconf_peditor_new_boolean
|
2002-01-29 03:26:23 +00:00
|
|
|
(changeset, "/desktop/gnome/interface/menus_have_icons", WID ("menu_icons_toggle"), NULL);
|
2002-04-10 12:26:20 +00:00
|
|
|
g_signal_connect (peditor,
|
|
|
|
"value_changed",
|
|
|
|
G_CALLBACK (menus_have_icons_cb), dialog);
|
2002-03-21 16:52:26 +00:00
|
|
|
|
|
|
|
set_have_icons (dialog,
|
2005-05-22 15:46:45 +00:00
|
|
|
gconf_client_get_bool (client,
|
2002-03-21 16:52:26 +00:00
|
|
|
"/desktop/gnome/interface/menus_have_icons",
|
|
|
|
NULL));
|
2002-01-29 03:26:23 +00:00
|
|
|
|
2002-03-21 16:52:26 +00:00
|
|
|
peditor = gconf_peditor_new_select_menu
|
2002-01-29 03:26:23 +00:00
|
|
|
(changeset, "/desktop/gnome/interface/toolbar_style", WID ("toolbar_style_omenu"),
|
|
|
|
"conv-to-widget-cb", toolbar_to_widget,
|
|
|
|
"conv-from-widget-cb", toolbar_from_widget,
|
|
|
|
NULL);
|
2002-04-10 12:26:20 +00:00
|
|
|
g_signal_connect (peditor,
|
|
|
|
"value_changed",
|
2002-03-21 16:52:26 +00:00
|
|
|
G_CALLBACK (toolbar_style_cb), dialog);
|
2002-01-29 03:26:23 +00:00
|
|
|
|
2002-03-11 04:52:47 +00:00
|
|
|
widget = WID ("toolbar_handlebox");
|
2002-04-10 12:26:20 +00:00
|
|
|
g_signal_connect (G_OBJECT (widget),
|
|
|
|
"button_press_event",
|
|
|
|
G_CALLBACK (button_press_blocker), NULL);
|
2002-01-29 03:26:23 +00:00
|
|
|
|
|
|
|
widget = WID ("gnome_ui_properties_dialog");
|
2002-04-10 12:26:20 +00:00
|
|
|
g_signal_connect (G_OBJECT (widget),
|
|
|
|
"response",
|
|
|
|
G_CALLBACK (dialog_button_clicked_cb), changeset);
|
2002-03-21 16:52:26 +00:00
|
|
|
|
|
|
|
show_handlebar (dialog,
|
2005-05-22 15:46:45 +00:00
|
|
|
gconf_client_get_bool (client,
|
2002-03-21 16:52:26 +00:00
|
|
|
"/desktop/gnome/interface/toolbar_detachable",
|
|
|
|
NULL));
|
|
|
|
|
2005-05-22 15:46:45 +00:00
|
|
|
toolbar_style = gconf_client_get_string (client,
|
2002-03-21 16:52:26 +00:00
|
|
|
"/desktop/gnome/interface/toolbar_style",
|
|
|
|
NULL);
|
2005-05-22 15:46:45 +00:00
|
|
|
g_object_unref (client);
|
|
|
|
|
2002-03-21 16:52:26 +00:00
|
|
|
set_toolbar_style (dialog, toolbar_style);
|
|
|
|
|
|
|
|
g_free (toolbar_style);
|
|
|
|
|
2002-05-29 18:49:34 +00:00
|
|
|
gtk_window_set_resizable (GTK_WINDOW (widget), FALSE);
|
2004-08-20 16:50:57 +00:00
|
|
|
capplet_set_icon (widget, "gnome-settings-ui-behavior");
|
2002-01-29 03:26:23 +00:00
|
|
|
gtk_widget_show_all (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2007-01-31 17:48:40 +00:00
|
|
|
GnomeProgram *program;
|
2002-01-29 03:26:23 +00:00
|
|
|
GConfClient *client;
|
2002-02-12 06:16:11 +00:00
|
|
|
GConfChangeSet *changeset = NULL;
|
2002-01-29 03:26:23 +00:00
|
|
|
GladeXML *dialog;
|
|
|
|
|
2002-02-27 22:19:53 +00:00
|
|
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
textdomain (GETTEXT_PACKAGE);
|
2002-01-29 03:26:23 +00:00
|
|
|
|
2007-01-31 17:48:40 +00:00
|
|
|
program = gnome_program_init ("gnome-ui-properties", VERSION,
|
|
|
|
LIBGNOMEUI_MODULE, argc, argv,
|
|
|
|
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
|
|
|
NULL);
|
2002-01-29 03:26:23 +00:00
|
|
|
|
|
|
|
client = gconf_client_get_default ();
|
|
|
|
gconf_client_add_dir (client, "/desktop/gnome/interface", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
2005-05-22 15:46:45 +00:00
|
|
|
g_object_unref (client);
|
2002-01-29 03:26:23 +00:00
|
|
|
dialog = create_dialog ();
|
2002-02-11 04:38:16 +00:00
|
|
|
setup_dialog (dialog, changeset);
|
2002-01-29 03:26:23 +00:00
|
|
|
gtk_main ();
|
|
|
|
|
2007-01-31 17:48:40 +00:00
|
|
|
g_object_unref (dialog);
|
|
|
|
g_object_unref (program);
|
2002-01-29 03:26:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|