Kaydet (Commit) e28ca322 authored tarafından Enrico Tröger's avatar Enrico Tröger

Add option 'System Default' for toolbar icon style and size to use the GTK default value.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4817 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 0eb7bb5b
2010-04-11 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* geany.glade, doc/geany.txt, plugins/geanyfunctions.h,
src/callbacks.c, src/interface.c, src/keyfile.c, src/plugindata.h,
src/plugins.c, src/prefs.c, src/toolbar.c, src/toolbar.h,
src/ui_utils.c, src/ui_utils.h:
Add option 'System Default' for toolbar icon style and size to
use the GTK default value.
2010-04-09 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
* plugins/htmlchars.c:
......
......@@ -1792,6 +1792,8 @@ Append Toolbar to the Menu
Allows to append the toolbar to the main menu bar instead of placing it below.
This is useful to save vertical space.
Customize Toolbar
See `Customizing the toolbar`_.
Appearance
``````````
......@@ -1799,12 +1801,11 @@ Appearance
Icon Style
Select the toolbar icon style to use - either icons and text, just
icons or just text.
The choice System default uses whatever icon style is set by GTK.
Icon size
Select the size of the icons you see (large, small or very small).
Customize Toolbar
See `Customizing the toolbar`_.
The choice System default uses whatever icon size is set by GTK.
Editor Features preferences
......
This diff is collapsed.
......@@ -266,6 +266,8 @@
geany_functions->p_ui->ui_widget_modify_font_from_string
#define ui_is_keyval_enter_or_return \
geany_functions->p_ui->ui_is_keyval_enter_or_return
#define ui_get_gtk_settings_integer \
geany_functions->p_ui->ui_get_gtk_settings_integer
#define dialogs_show_question \
geany_functions->p_dialogs->dialogs_show_question
#define dialogs_show_msgbox \
......
......@@ -507,8 +507,8 @@ on_images_and_text2_activate (GtkCheckMenuItem *menuitem,
if (ignore_toolbar_toggle || ! gtk_check_menu_item_get_active(menuitem))
return;
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOLBAR_BOTH);
toolbar_prefs.icon_style = GTK_TOOLBAR_BOTH;
toolbar_set_icon_style();
}
......@@ -519,8 +519,8 @@ on_images_only2_activate (GtkCheckMenuItem *menuitem,
if (ignore_toolbar_toggle || ! gtk_check_menu_item_get_active(menuitem))
return;
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOLBAR_ICONS);
toolbar_prefs.icon_style = GTK_TOOLBAR_ICONS;
toolbar_set_icon_style();
}
......@@ -531,8 +531,8 @@ on_text_only2_activate (GtkCheckMenuItem *menuitem,
if (ignore_toolbar_toggle || ! gtk_check_menu_item_get_active(menuitem))
return;
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOLBAR_TEXT);
toolbar_prefs.icon_style = GTK_TOOLBAR_TEXT;
toolbar_set_icon_style();
}
......@@ -626,7 +626,7 @@ on_toolbar_large_icons1_activate (GtkCheckMenuItem *menuitem,
return;
toolbar_prefs.icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
gtk_toolbar_set_icon_size(GTK_TOOLBAR(main_widgets.toolbar), toolbar_prefs.icon_size);
toolbar_set_icon_size();
}
......@@ -638,7 +638,7 @@ on_toolbar_small_icons1_activate (GtkCheckMenuItem *menuitem,
return;
toolbar_prefs.icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
gtk_toolbar_set_icon_size(GTK_TOOLBAR(main_widgets.toolbar), toolbar_prefs.icon_size);
toolbar_set_icon_size();
}
......@@ -650,7 +650,7 @@ on_very_small_icons1_activate (GtkCheckMenuItem *menuitem,
return;
toolbar_prefs.icon_size = GTK_ICON_SIZE_MENU;
gtk_toolbar_set_icon_size(GTK_TOOLBAR(main_widgets.toolbar), toolbar_prefs.icon_size);
toolbar_set_icon_size();
}
......
This diff is collapsed.
......@@ -406,6 +406,8 @@ static void save_dialog_prefs(GKeyFile *config)
/* toolbar */
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", toolbar_prefs.visible);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_append_to_menu", toolbar_prefs.append_to_menu);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_style", toolbar_prefs.use_gtk_default_style);
g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_icon", toolbar_prefs.use_gtk_default_icon);
g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_style", toolbar_prefs.icon_style);
g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_size", toolbar_prefs.icon_size);
......@@ -616,14 +618,6 @@ void configuration_load_session_files(GKeyFile *config, gboolean read_recent_fil
}
#define GEANY_GET_SETTING(propertyname, value, default_value) \
if (g_object_class_find_property( \
G_OBJECT_GET_CLASS(G_OBJECT(gtk_settings_get_default())), propertyname)) \
g_object_get(G_OBJECT(gtk_settings_get_default()), propertyname, &value, \
NULL); \
else \
value = default_value;
static void load_dialog_prefs(GKeyFile *config)
{
gchar *tmp_string, *tmp_string2;
......@@ -729,12 +723,13 @@ static void load_dialog_prefs(GKeyFile *config)
toolbar_prefs.visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE);
toolbar_prefs.append_to_menu = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_append_to_menu", FALSE);
{
GtkIconSize tb_iconsize;
GtkToolbarStyle tb_style;
GEANY_GET_SETTING("gtk-toolbar-style", tb_style, GTK_TOOLBAR_ICONS);
GEANY_GET_SETTING("gtk-toolbar-icon-size", tb_iconsize, GTK_ICON_SIZE_LARGE_TOOLBAR);
toolbar_prefs.icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", tb_style);
toolbar_prefs.icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", tb_iconsize);
toolbar_prefs.use_gtk_default_style = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_style", TRUE);
if (! toolbar_prefs.use_gtk_default_style)
toolbar_prefs.icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", GTK_TOOLBAR_ICONS);
toolbar_prefs.use_gtk_default_icon = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_use_gtk_default_icon", TRUE);
if (! toolbar_prefs.use_gtk_default_icon)
toolbar_prefs.icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", GTK_ICON_SIZE_LARGE_TOOLBAR);
}
/* VTE */
......
......@@ -430,6 +430,7 @@ typedef struct UIUtilsFuncs
GCallback callback);
void (*ui_widget_modify_font_from_string) (GtkWidget *widget, const gchar *str);
gboolean (*ui_is_keyval_enter_or_return) (guint keyval);
gint (*ui_get_gtk_settings_integer) (const gchar *property_name, gint default_value);
}
UIUtilsFuncs;
......
......@@ -229,7 +229,8 @@ static UIUtilsFuncs uiutils_funcs = {
&ui_entry_add_clear_icon,
&ui_menu_add_document_items,
&ui_widget_modify_font_from_string,
&ui_is_keyval_enter_or_return
&ui_is_keyval_enter_or_return,
&ui_get_gtk_settings_integer
};
static DialogFuncs dialog_funcs = {
......
......@@ -456,6 +456,8 @@ static void prefs_init_dialog(void)
case 1: widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_text"); break;
default: widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_imagetext"); break;
}
if (toolbar_prefs.use_gtk_default_style)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_style_default");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
switch (toolbar_prefs.icon_size)
......@@ -466,6 +468,8 @@ static void prefs_init_dialog(void)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_small"); break;
default: widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_verysmall"); break;
}
if (toolbar_prefs.use_gtk_default_icon)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_icon_default");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
/* disable elements if toolbar is hidden */
......@@ -851,30 +855,39 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_in_menu");
toolbar_prefs.append_to_menu = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_imagetext");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
toolbar_prefs.icon_style = 2;
else
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_style_default");
toolbar_prefs.use_gtk_default_style = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
if (! toolbar_prefs.use_gtk_default_style)
{
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_image");
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_imagetext");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
toolbar_prefs.icon_style = 0;
toolbar_prefs.icon_style = 2;
else
/* now only the text only radio remains, so set text only */
toolbar_prefs.icon_style = 1;
{
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_image");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
toolbar_prefs.icon_style = 0;
else
/* now only the text only radio remains, so set text only */
toolbar_prefs.icon_style = 1;
}
}
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_large");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
toolbar_prefs.icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
else
{
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_small");
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_icon_default");
toolbar_prefs.use_gtk_default_icon = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
if (! toolbar_prefs.use_gtk_default_icon)
{ toolbar_prefs.icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_large");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
toolbar_prefs.icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
toolbar_prefs.icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
else
toolbar_prefs.icon_size = GTK_ICON_SIZE_MENU;
{
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_toolbar_small");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
toolbar_prefs.icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
else
toolbar_prefs.icon_size = GTK_ICON_SIZE_MENU;
}
}
/* Files settings */
......@@ -1409,7 +1422,12 @@ static void on_toolbar_show_toggled(GtkToggleButton *togglebutton, gpointer user
{
gboolean sens = gtk_toggle_button_get_active(togglebutton);
gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "frame13"), sens);
gtk_widget_set_sensitive(
ui_lookup_widget(ui_widgets.prefs_dialog, "frame_toolbar_style"), sens);
gtk_widget_set_sensitive(
ui_lookup_widget(ui_widgets.prefs_dialog, "frame_toolbar_icon"), sens);
gtk_widget_set_sensitive(
ui_lookup_widget(ui_widgets.prefs_dialog, "button_customize_toolbar"), sens);
gtk_widget_set_sensitive(
ui_lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_in_menu"), sens);
}
......
......@@ -505,40 +505,59 @@ void toolbar_show_hide(void)
}
void toolbar_apply_settings(void)
/* sets the icon style of the toolbar */
void toolbar_set_icon_style(void)
{
/* sets the icon style of the toolbar */
switch (toolbar_prefs.icon_style)
gint icon_style;
icon_style = toolbar_prefs.icon_style;
if (toolbar_prefs.use_gtk_default_style)
icon_style = ui_get_gtk_settings_integer("gtk-toolbar-style", toolbar_prefs.icon_style);
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), icon_style);
switch (icon_style)
{
default:
case GTK_TOOLBAR_BOTH:
{
/*gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "images_and_text1")), TRUE);*/
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(ui_widgets.toolbar_menu, "images_and_text2")), TRUE);
break;
}
case GTK_TOOLBAR_ICONS:
{
/*gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "images_only1")), TRUE);*/
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(ui_widgets.toolbar_menu, "images_only2")), TRUE);
break;
}
case GTK_TOOLBAR_TEXT:
{
/*gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "text_only1")), TRUE);*/
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(ui_widgets.toolbar_menu, "text_only2")), TRUE);
break;
}
}
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), toolbar_prefs.icon_style);
g_message("%d style %d (%d)", toolbar_prefs.use_gtk_default_style, icon_style, toolbar_prefs.icon_style);
}
/* sets the icon size of the toolbar, use user preferences (.gtkrc) if not set */
if (toolbar_prefs.icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR ||
toolbar_prefs.icon_size == GTK_ICON_SIZE_LARGE_TOOLBAR ||
toolbar_prefs.icon_size == GTK_ICON_SIZE_MENU)
{
gtk_toolbar_set_icon_size(GTK_TOOLBAR(main_widgets.toolbar), toolbar_prefs.icon_size);
}
/* sets the icon size of the toolbar */
void toolbar_set_icon_size(void)
{
gint icon_size;
icon_size = toolbar_prefs.icon_size;
if (toolbar_prefs.use_gtk_default_icon)
icon_size = ui_get_gtk_settings_integer("gtk-toolbar-icon-size", toolbar_prefs.icon_size);
gtk_toolbar_set_icon_size(GTK_TOOLBAR(main_widgets.toolbar), icon_size);
}
void toolbar_apply_settings(void)
{
toolbar_set_icon_style();
toolbar_set_icon_size();
}
......
......@@ -30,6 +30,8 @@ typedef struct GeanyToolbarPrefs
gboolean visible;
GtkIconSize icon_size;
GtkToolbarStyle icon_style; /**< Icon style. */
gboolean use_gtk_default_style;
gboolean use_gtk_default_icon;
gboolean append_to_menu;
}
GeanyToolbarPrefs;
......@@ -49,6 +51,10 @@ void toolbar_update_ui(void);
void toolbar_apply_settings(void);
void toolbar_set_icon_style(void);
void toolbar_set_icon_size(void);
void toolbar_show_hide(void);
void toolbar_item_ref(GtkToolItem *item);
......
......@@ -2245,3 +2245,23 @@ gboolean ui_is_keyval_enter_or_return(guint keyval)
{
return (keyval == GDK_Return || keyval == GDK_ISO_Enter|| keyval == GDK_KP_Enter);
}
/** Reads an integer from the GTK default settings registry
* (see http://library.gnome.org/devel/gtk/stable/GtkSettings.html).
* @param property_name The property to read.
* @param default_value The default value in case the value could not be read.
* @return The value for the property if it exists, otherwise the @a default_value.
* @since 0.19 */
gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value)
{
if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(
gtk_settings_get_default())), property_name))
{
gint value;
g_object_get(G_OBJECT(gtk_settings_get_default()), property_name, &value, NULL);
return value;
}
else
return default_value;
}
......@@ -306,4 +306,6 @@ void ui_swap_sidebar_pos(void);
gboolean ui_is_keyval_enter_or_return(guint keyval);
gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment