From 0e1a17d18a4ddc008463a4e5290f5748d416723f Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 21 Dec 2009 13:02:09 -0500 Subject: [PATCH] Add the Inactive OSD font, and the primaryMonitor options --- src/appearance.c | 45 +++-- src/main.c | 3 +- src/obconf.glade | 391 ++++++++++++++++++++++++++++++++++++++++--- src/preview_update.c | 23 ++- src/preview_update.h | 3 +- src/strings.c | 12 +- src/windows.c | 58 +++++++ 7 files changed, 490 insertions(+), 45 deletions(-) diff --git a/src/appearance.c b/src/appearance.c index 293e43f..f130311 100644 --- a/src/appearance.c +++ b/src/appearance.c @@ -23,7 +23,7 @@ static gboolean mapping = FALSE; -static RrFont *read_font(GtkFontButton *w, const gchar *place); +static RrFont *read_font(GtkFontButton *w, const gchar *place, gboolean def); static RrFont *write_font(GtkFontButton *w, const gchar *place); void appearance_setup_tab() @@ -49,24 +49,31 @@ void appearance_setup_tab() g_free(layout); w = get_widget("font_active"); - f = read_font(GTK_FONT_BUTTON(w), "ActiveWindow"); + f = read_font(GTK_FONT_BUTTON(w), "ActiveWindow", TRUE); preview_update_set_active_font(f); w = get_widget("font_inactive"); - f = read_font(GTK_FONT_BUTTON(w), "InactiveWindow"); + f = read_font(GTK_FONT_BUTTON(w), "InactiveWindow", TRUE); preview_update_set_inactive_font(f); w = get_widget("font_menu_header"); - f = read_font(GTK_FONT_BUTTON(w), "MenuHeader"); + f = read_font(GTK_FONT_BUTTON(w), "MenuHeader", TRUE); preview_update_set_menu_header_font(f); w = get_widget("font_menu_item"); - f = read_font(GTK_FONT_BUTTON(w), "MenuItem"); + f = read_font(GTK_FONT_BUTTON(w), "MenuItem", TRUE); preview_update_set_menu_item_font(f); - w = get_widget("font_display"); - f = read_font(GTK_FONT_BUTTON(w), "OnScreenDisplay"); - preview_update_set_osd_font(f); + w = get_widget("font_active_display"); + if (!(f = read_font(GTK_FONT_BUTTON(w), "ActiveOnScreenDisplay", FALSE))) { + f = read_font(GTK_FONT_BUTTON(w), "OnScreenDisplay", TRUE); + tree_delete_node("theme/font:place=OnScreenDisplay"); + } + preview_update_set_osd_active_font(f); + + w = get_widget("font_inactive_display"); + f = read_font(GTK_FONT_BUTTON(w), "InactiveOnScreenDisplay", TRUE); + preview_update_set_osd_inactive_font(f); mapping = FALSE; } @@ -185,14 +192,23 @@ void on_font_menu_item_font_set(GtkFontButton *w, gpointer data) preview_update_set_menu_item_font(write_font(w, "MenuItem")); } -void on_font_display_font_set(GtkFontButton *w, gpointer data) +void on_font_active_display_font_set(GtkFontButton *w, gpointer data) { if (mapping) return; - preview_update_set_osd_font(write_font(w, "OnScreenDisplay")); + preview_update_set_osd_active_font(write_font(w, "ActiveOnScreenDisplay")); } -static RrFont *read_font(GtkFontButton *w, const gchar *place) +void on_font_inactive_display_font_set(GtkFontButton *w, gpointer data) +{ + if (mapping) return; + + preview_update_set_osd_inactive_font + (write_font(w, "InactiveOnScreenDisplay")); +} + +static RrFont *read_font(GtkFontButton *w, const gchar *place, + gboolean use_default) { RrFont *font; gchar *fontstring, *node; @@ -207,9 +223,14 @@ static RrFont *read_font(GtkFontButton *w, const gchar *place) mapping = TRUE; node = g_strdup_printf("theme/font:place=%s/name", place); - name = tree_get_string(node, "Sans"); + name = tree_get_string(node, use_default ? "Sans" : NULL); g_free(node); + if (name[0] == '\0') { + g_free(name); + return NULL; + } + node = g_strdup_printf("theme/font:place=%s/size", place); size = tree_get_string(node, "8"); g_free(node); diff --git a/src/main.c b/src/main.c index 875b783..f72976e 100644 --- a/src/main.c +++ b/src/main.c @@ -297,7 +297,8 @@ int main(int argc, char **argv) preview_update_set_inactive_font(NULL); preview_update_set_menu_header_font(NULL); preview_update_set_menu_item_font(NULL); - preview_update_set_osd_font(NULL); + preview_update_set_osd_active_font(NULL); + preview_update_set_osd_inactive_font(NULL); preview_update_set_title_layout(NULL); } diff --git a/src/obconf.glade b/src/obconf.glade index 81e926f..464acff 100644 --- a/src/obconf.glade +++ b/src/obconf.glade @@ -943,7 +943,7 @@ Omnipresent (On all desktops) True - 5 + 6 2 False 3 @@ -1012,27 +1012,6 @@ Omnipresent (On all desktops) - - - True - True - True - True - True - False - True - - - - 1 - 2 - 4 - 5 - fill - - - - True @@ -1152,7 +1131,7 @@ Omnipresent (On all desktops) True - _On-screen display: + Active _On-screen display: True False GTK_JUSTIFY_LEFT @@ -1162,7 +1141,6 @@ Omnipresent (On all desktops) 0.5 0 0 - font_display PANGO_ELLIPSIZE_NONE -1 False @@ -1197,6 +1175,76 @@ Omnipresent (On all desktops) + + + + True + Inactive O_n-screen display: + True + False + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + True + True + True + True + False + True + + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + True + True + True + False + True + + + + 1 + 2 + 5 + 6 + fill + + + 0 @@ -1576,6 +1624,301 @@ Omnipresent (On all desktops) True + + + + True + False + 6 + + + + True + <span weight="bold">Primary Monitor</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 6 + + + + True + False + 0 + + + + True + The primary monitor is where Openbox will place dialogs, such as the one used for cycling windows. + False + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 0 + False + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 6 + + + + True + Primary _monitor: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + primary_monitor_popup + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + True + 1 + + + + + + + True + Fixed Monitor + True + + + + + + + True + Active Monitor + True + + + + + + + True + Monitor With Mouse Pointer + True + + + + + + + + 0 + False + False + + + + + 0 + True + True + + + + + + True + False + 6 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + _Fixed monitor: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + fixed_monitor + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 1 100 1 10 10 + + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + False + True + + + + + 0 + False + True + + False diff --git a/src/preview_update.c b/src/preview_update.c index a0e17c8..2f61fb7 100644 --- a/src/preview_update.c +++ b/src/preview_update.c @@ -10,18 +10,21 @@ static RrFont *active_window_font = NULL; static RrFont *inactive_window_font = NULL; static RrFont *menu_title_font = NULL; static RrFont *menu_item_font = NULL; -static RrFont *osd_font = NULL; +static RrFont *osd_active_font = NULL; +static RrFont *osd_inactive_font = NULL; static gboolean update_theme_preview_iterate(gpointer data); void preview_update_all() { if (!list_store) return; + if (!RR_CHECK_VERSION(3,5,0)) return; g_idle_remove_by_data(list_store); if (!(title_layout && active_window_font && inactive_window_font && - menu_title_font && menu_item_font && osd_font)) + menu_title_font && menu_item_font && + osd_active_font && osd_inactive_font)) return; /* not set up */ restart_theme_preview_update = TRUE; @@ -70,10 +73,17 @@ void preview_update_set_menu_item_font(RrFont *f) preview_update_all(); } -void preview_update_set_osd_font(RrFont *f) +void preview_update_set_osd_active_font(RrFont *f) { - RrFontClose(osd_font); - osd_font = f; + RrFontClose(osd_active_font); + osd_active_font = f; + preview_update_all(); +} + +void preview_update_set_osd_inactive_font(RrFont *f) +{ + RrFontClose(osd_inactive_font); + osd_inactive_font = f; preview_update_all(); } @@ -123,7 +133,8 @@ static gboolean update_theme_preview_iterate(gpointer data) gtk_list_store_set(GTK_LIST_STORE(ls), &iter, 1, preview_theme(name, title_layout, active_window_font, inactive_window_font, menu_title_font, - menu_item_font, osd_font), + menu_item_font, osd_active_font, + osd_inactive_font), -1); return TRUE; diff --git a/src/preview_update.h b/src/preview_update.h index 5163174..596f092 100644 --- a/src/preview_update.h +++ b/src/preview_update.h @@ -11,7 +11,8 @@ void preview_update_set_active_font (RrFont *f); void preview_update_set_inactive_font (RrFont *f); void preview_update_set_menu_header_font (RrFont *f); void preview_update_set_menu_item_font (RrFont *f); -void preview_update_set_osd_font (RrFont *f); +void preview_update_set_osd_active_font (RrFont *f); +void preview_update_set_osd_inactive_font(RrFont *f); void preview_update_set_title_layout (const gchar *layout); #endif diff --git a/src/strings.c b/src/strings.c index abf39b6..8e24f40 100644 --- a/src/strings.c +++ b/src/strings.c @@ -45,7 +45,8 @@ gchar *s = N_("_Active window title: "); gchar *s = N_("_Inactive window title: "); gchar *s = N_("Menu _header: "); gchar *s = N_("_Menu Item: "); -gchar *s = N_("_On-screen display: "); +gchar *s = N_("Active _On-screen display: "); +gchar *s = N_("Inactive O_n-screen display: "); gchar *s = N_("Appearance"); gchar *s = N_("Focusing Windows"); gchar *s = N_(" "); @@ -58,6 +59,15 @@ gchar *s = N_("Prefer to place new windows _on:"); gchar *s = N_("All monitors"); gchar *s = N_("The active monitor"); gchar *s = N_("The monitor with the mouse"); +gchar *s = N_("Primary Monitor"); +gchar *s = N_(" "); +gchar *s = N_("The primary monitor is where Openbox will place dialogs, such as the one used for cycling windows."); +gchar *s = N_("Primary _monitor:"); +gchar *s = N_("Fixed Monitor"); +gchar *s = N_("Active Monitor"); +gchar *s = N_("Monitor With Mouse Pointer"); +gchar *s = N_(" "); +gchar *s = N_("_Fixed monitor:"); gchar *s = N_("Windows"); gchar *s = N_("Moving and Resizing Windows"); gchar *s = N_(" "); diff --git a/src/windows.c b/src/windows.c index ed5ed35..d2b4d96 100644 --- a/src/windows.c +++ b/src/windows.c @@ -23,6 +23,7 @@ static gboolean mapping = FALSE; #define PLACE_ON_ALL 0 +#define PLACE_ON_FIXED 0 #define PLACE_ON_ACTIVE 1 #define PLACE_ON_MOUSE 2 @@ -59,6 +60,21 @@ void windows_setup_tab() gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ALL); g_free(s); + w = get_widget("primary_monitor_popup"); + s = tree_get_string("placement/primaryMonitor", ""); + if (!g_ascii_strcasecmp(s, "Active")) + gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_ACTIVE); + else if (!g_ascii_strcasecmp(s, "Mouse")) + gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_MOUSE); + else { + gtk_option_menu_set_history(GTK_OPTION_MENU(w), PLACE_ON_FIXED); + + w = get_widget("fixed_monitor"); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), + tree_get_int("placement/primaryMonitor", 1)); + } + g_free(s); + enable_stuff(); mapping = FALSE; @@ -71,8 +87,50 @@ static void enable_stuff() w = get_widget("place_mouse"); b = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); + w = get_widget("place_center"); gtk_widget_set_sensitive(w, !b); + + w = get_widget("primary_monitor_popup"); + b = gtk_option_menu_get_history(GTK_OPTION_MENU(w)) == PLACE_ON_FIXED; + w = get_widget("fixed_monitor"); + gtk_widget_set_sensitive(w, b); +} + +void on_primary_monitor_active_activate(GtkMenuItem *w, gpointer data) +{ + if (mapping) return; + + tree_set_string("placement/primaryMonitor", "Active"); + enable_stuff(); +} + +void on_primary_monitor_mouse_activate(GtkMenuItem *w, gpointer data) +{ + if (mapping) return; + + tree_set_string("placement/primaryMonitor", "Mouse"); + enable_stuff(); +} + +void on_primary_monitor_fixed_activate(GtkMenuItem *w, gpointer data) +{ + GtkWidget *w2; + + if (mapping) return; + + w2 = get_widget("fixed_monitor"); + tree_set_int("placement/primaryMonitor", + gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(w2))); + enable_stuff(); +} + +void on_fixed_monitor_value_changed(GtkSpinButton *w, gpointer data) +{ + if (mapping) return; + + tree_set_int("placement/primaryMonitor", + gtk_spin_button_get_value_as_int(w)); } void on_focus_new_toggled(GtkToggleButton *w, gpointer data) -- 2.39.2