From 57026bf522ee80d8fc3710ca33da73ff103f98c3 Mon Sep 17 00:00:00 2001 From: Exalm Date: Sun, 30 Aug 2015 20:02:42 +0500 Subject: Restored Interface tab in Appearance capplet Remove editable accels and toolbar style toggles as they are deprecated in GTK >= 3.10.0 --- capplets/appearance/Makefile.am | 2 + capplets/appearance/appearance-main.c | 2 + capplets/appearance/appearance-ui.c | 244 ++++++++++++++++++++++ capplets/appearance/appearance-ui.h | 21 ++ capplets/appearance/appearance.h | 4 + capplets/appearance/data/appearance.ui | 364 +++++++++++++++++++++++++++++++++ 6 files changed, 637 insertions(+) create mode 100644 capplets/appearance/appearance-ui.c create mode 100644 capplets/appearance/appearance-ui.h (limited to 'capplets/appearance') diff --git a/capplets/appearance/Makefile.am b/capplets/appearance/Makefile.am index c28d3815..500fcc64 100644 --- a/capplets/appearance/Makefile.am +++ b/capplets/appearance/Makefile.am @@ -16,6 +16,8 @@ mate_appearance_properties_SOURCES = \ appearance-themes.h \ appearance-style.c \ appearance-style.h \ + appearance-ui.c \ + appearance-ui.h \ appearance-support.c \ appearance-support.h \ mate-wp-info.c \ diff --git a/capplets/appearance/appearance-main.c b/capplets/appearance/appearance-main.c index c8256005..b51591e9 100644 --- a/capplets/appearance/appearance-main.c +++ b/capplets/appearance/appearance-main.c @@ -25,6 +25,7 @@ #include "appearance-font.h" #include "appearance-themes.h" #include "appearance-style.h" +#include "appearance-ui.h" #include "appearance-support.h" #include "theme-installer.h" #include "theme-thumbnail.h" @@ -188,6 +189,7 @@ main (int argc, char **argv) desktop_init (data, (const gchar **) wallpaper_files); g_strfreev (wallpaper_files); font_init (data); + ui_init (data); /* init support for other window managers */ support_init (data); diff --git a/capplets/appearance/appearance-ui.c b/capplets/appearance/appearance-ui.c new file mode 100644 index 00000000..04b8a49e --- /dev/null +++ b/capplets/appearance/appearance-ui.c @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2007 The GNOME Foundation + * Written by Jonathan Blandford + * Jens Granseuer + * 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 "stdio.h" + + +static void +show_handlebar (AppearanceData *data, gboolean show) +{ + GtkWidget *handlebox = appearance_capplet_get_widget (data, "toolbar_handlebox"); + GtkWidget *toolbar = appearance_capplet_get_widget (data, "toolbar_toolbar"); + GtkWidget *align = appearance_capplet_get_widget (data, "toolbar_align"); + + g_object_ref (handlebox); + g_object_ref (toolbar); + + if (gtk_bin_get_child (GTK_BIN (align))) + gtk_container_remove (GTK_CONTAINER (align), gtk_bin_get_child (GTK_BIN (align))); + + if (gtk_bin_get_child (GTK_BIN (handlebox))) + gtk_container_remove (GTK_CONTAINER (handlebox), gtk_bin_get_child (GTK_BIN (handlebox))); + + 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); +} + +#if !GTK_CHECK_VERSION (3, 10, 0) +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 = gtk_combo_box_get_active((GtkComboBox *) + appearance_capplet_get_widget (data, "toolbar_style_select")); + + gtk_toolbar_set_style (GTK_TOOLBAR (appearance_capplet_get_widget (data, "toolbar_toolbar")), + gtk_toolbar_styles[enum_val]); +} +#endif + +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 (appearance_capplet_get_widget (data, *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 **/ + +#if !GTK_CHECK_VERSION (3, 10, 0) +static gboolean +toolbar_to_widget (GValue *value, GVariant *variant, gpointer user_data) +{ + const gchar *val = g_variant_get_string(variant, NULL); + gint i = 0; + + if (g_strcmp0(val, "both-horiz") == 0 || g_strcmp0(val, "both_horiz") == 0) + i = 1; + else if (g_strcmp0(val, "icons") == 0) + i = 2; + else if (g_strcmp0(val, "text") == 0) + i = 3; + + g_value_set_int(value, i); + + return TRUE; +} + +static GVariant * +toolbar_from_widget (const GValue *value, + const GVariantType *expected_type, + gpointer user_data) +{ + static const char *gtk_toolbar_styles_str[] = { + "both", "both-horiz", "icons", "text" }; + + gint index = g_value_get_int(value); + return g_variant_new_string(gtk_toolbar_styles_str[index]); +} + +static void +toolbar_style_cb (GSettings *settings, + gchar *key, + AppearanceData *data) +{ + set_toolbar_style (data, g_settings_get_string (settings, key)); +} +#endif + +static void +menus_have_icons_cb (GSettings *settings, + gchar *key, + AppearanceData *data) +{ + set_have_icons (data, g_settings_get_boolean (settings, key)); +} + +static void +toolbar_detachable_cb (GSettings *settings, + gchar *key, + AppearanceData *data) +{ + show_handlebar (data, g_settings_get_boolean (settings, key)); +} + +/** GUI Callbacks **/ + +static gint +button_press_block_cb (GtkWidget *toolbar, + GdkEvent *event, + gpointer data) +{ + return TRUE; +} + +/** Public Functions **/ + +void +ui_init (AppearanceData *data) +{ + GtkWidget* widget; + +#if GTK_CHECK_VERSION (3, 10, 0) + GtkWidget* container = appearance_capplet_get_widget(data, "vbox24"); + + // Remove menu accels and toolbar style toggles for new GTK versions + gtk_container_remove((GtkContainer *) container, + appearance_capplet_get_widget(data, "menu_accel_toggle")); + gtk_container_remove((GtkContainer *) container, + appearance_capplet_get_widget(data, "hbox11")); +#endif + + widget = appearance_capplet_get_widget(data, "menu_icons_toggle"); + g_settings_bind (data->interface_settings, + MENU_ICONS_KEY, + G_OBJECT (widget), + "active", + G_SETTINGS_BIND_DEFAULT); + g_signal_connect (data->interface_settings, "changed::" MENU_ICONS_KEY, + G_CALLBACK (menus_have_icons_cb), data); + + set_have_icons (data, + g_settings_get_boolean (data->interface_settings, + MENU_ICONS_KEY)); + +#if !GTK_CHECK_VERSION (3, 10, 0) + widget = appearance_capplet_get_widget(data, "menu_accel_toggle"); + g_settings_bind (data->interface_settings, + ACCEL_CHANGE_KEY, + G_OBJECT (widget), + "active", + G_SETTINGS_BIND_DEFAULT); + + widget = appearance_capplet_get_widget(data, "toolbar_style_select"); + g_settings_bind_with_mapping (data->interface_settings, + TOOLBAR_STYLE_KEY, + G_OBJECT (widget), + "active", + G_SETTINGS_BIND_DEFAULT, + toolbar_to_widget, + toolbar_from_widget, + data, + NULL); + + g_signal_connect (data->interface_settings, "changed::" TOOLBAR_STYLE_KEY, + (GCallback) toolbar_style_cb, data); + + char* toolbar_style; + + toolbar_style = g_settings_get_string + (data->interface_settings, + TOOLBAR_STYLE_KEY); + set_toolbar_style (data, toolbar_style); + g_free (toolbar_style); +#endif + + g_signal_connect (appearance_capplet_get_widget (data, "toolbar_handlebox"), + "button_press_event", + (GCallback) button_press_block_cb, NULL); + + show_handlebar (data, + g_settings_get_boolean (data->interface_settings, + TOOLBAR_DETACHABLE_KEY)); + + /* no ui for detachable toolbars */ + g_signal_connect (data->interface_settings, + "changed::" TOOLBAR_DETACHABLE_KEY, (GCallback) toolbar_detachable_cb, data); +} diff --git a/capplets/appearance/appearance-ui.h b/capplets/appearance/appearance-ui.h new file mode 100644 index 00000000..5817a735 --- /dev/null +++ b/capplets/appearance/appearance-ui.h @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2007 The GNOME Foundation + * Written by Jens Granseuer + * 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); diff --git a/capplets/appearance/appearance.h b/capplets/appearance/appearance.h index 6f68a5c5..37f58291 100644 --- a/capplets/appearance/appearance.h +++ b/capplets/appearance/appearance.h @@ -45,6 +45,10 @@ #define GTK_THEME_KEY "gtk-theme" #define ICON_THEME_KEY "icon-theme" #define COLOR_SCHEME_KEY "gtk-color-scheme" +#define ACCEL_CHANGE_KEY "can-change-accels" +#define MENU_ICONS_KEY "menus-have-icons" +#define TOOLBAR_DETACHABLE_KEY "toolbar-detachable" +#define TOOLBAR_STYLE_KEY "toolbar-style" #define GTK_FONT_DEFAULT_VALUE "Sans 10" #define LOCKDOWN_SCHEMA "org.mate.lockdown" diff --git a/capplets/appearance/data/appearance.ui b/capplets/appearance/data/appearance.ui index e9736ca9..d2c9fdda 100644 --- a/capplets/appearance/data/appearance.ui +++ b/capplets/appearance/data/appearance.ui @@ -1549,6 +1549,370 @@ False + + + True + 12 + vertical + 18 + + + True + vertical + 6 + + + True + 0 + Menus and Toolbars + + + + + + False + False + 0 + + + + + True + + + True + + + + False + False + 0 + + + + + True + vertical + 6 + + + Show _icons in menus + True + True + False + True + True + True + + + False + False + 0 + + + + + _Editable menu shortcut keys + True + True + False + True + True + + + False + False + 2 + + + + + True + 12 + + + True + Toolbar _button labels: + True + center + toolbar_style_select + + + False + False + 0 + + + + + True + toolbar_style_liststore + + + + 0 + + + + + False + False + 1 + + + + + False + False + 4 + + + + + False + False + 1 + + + + + False + False + 1 + + + + + False + 0 + + + + + True + vertical + 6 + + + True + 0 + Preview + + + + + + False + False + 0 + + + + + True + + + True + + + + False + False + 0 + + + + + True + vertical + + + True + + + True + _File + True + + + + + gtk-new + True + True + True + + + + + gtk-open + True + True + True + + + + + gtk-save + True + True + True + + + + + True + + + + + gtk-print + True + True + True + + + + + True + + + + + gtk-quit + True + True + True + + + + + + + + + True + Edit + True + + + + + gtk-cut + True + True + True + + + + + gtk-copy + True + True + True + + + + + gtk-paste + True + True + True + + + + + + + + + False + False + 0 + + + + + True + + + True + + + True + both-horiz + + + True + True + gtk-new + + + False + True + + + + + True + gtk-open + + + False + True + + + + + True + gtk-save + + + False + True + + + + + + + + + False + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 3 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Interface + + + 3 + False + + 1 -- cgit v1.2.1