clean up appearance code
authorDana Jansens <danakj@orodu.net>
Thu, 31 May 2007 06:06:54 +0000 (06:06 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 31 May 2007 06:06:54 +0000 (06:06 +0000)
src/appearance.c
src/appearance.h
src/main.c

index d67b7d689923f2c81491a633382820fb15419bbb..6d282280ffe612ecb07fdad1563c9ce1533ba4b6 100644 (file)
 
 static gboolean mapping = FALSE;
 
-static RrFont *appr_setup_font(GtkWidget *w, const gchar *place);
-static RrFont *appr_set_font(GtkFontButton *w, const gchar *place);
+static RrFont *read_font(GtkFontButton *w, const gchar *place);
+static RrFont *write_font(GtkFontButton *w, const gchar *place);
 
-void appr_setup_window_border(GtkWidget *w)
-{
-    gboolean border;
-
-    mapping = TRUE;
-
-    border = tree_get_bool("theme/keepBorder", TRUE);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), border);
-
-    mapping = FALSE;
-}
-
-void appr_setup_title_layout(GtkWidget *w)
+void appearance_setup_tab()
 {
+    GtkWidget *w;
     gchar *layout;
+    RrFont *f;
 
     mapping = TRUE;
 
+    w = get_widget("window_border");
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w),
+                                 tree_get_bool("theme/keepBorder", TRUE));
+
+    w = get_widget("title_layout");
     layout = tree_get_string("theme/titleLayout", "NLIMC");
     gtk_entry_set_text(GTK_ENTRY(w), layout);
     preview_update_set_title_layout(layout);
     g_free(layout);
 
-    mapping = FALSE;
-}
+    w = get_widget("font_active");
+    f = read_font(GTK_FONT_BUTTON(w), "ActiveWindow");
+    preview_update_set_active_font(f);
 
-void appr_setup_font_active(GtkWidget *w)
-{
-    preview_update_set_active_font(appr_setup_font(w, "ActiveWindow"));
-}
+    w = get_widget("font_inactive");
+    f = read_font(GTK_FONT_BUTTON(w), "InactiveWindow");
+    preview_update_set_inactive_font(f);
 
-void appr_setup_font_inactive(GtkWidget *w)
-{
-    preview_update_set_inactive_font(appr_setup_font(w, "InactiveWindow"));
-}
+    w = get_widget("font_menu_header");
+    f = read_font(GTK_FONT_BUTTON(w), "MenuHeader");
+    preview_update_set_menu_header_font(f);
 
-void appr_setup_font_menu_header(GtkWidget *w)
-{
-    preview_update_set_menu_header_font(appr_setup_font(w, "MenuHeader"));
-}
+    w = get_widget("font_menu_item");
+    f = read_font(GTK_FONT_BUTTON(w), "MenuItem");
+    preview_update_set_menu_item_font(f);
 
-void appr_setup_font_menu_item(GtkWidget *w)
-{
-    preview_update_set_menu_item_font(appr_setup_font(w, "MenuItem"));
-}
+    w = get_widget("font_display");
+    f = read_font(GTK_FONT_BUTTON(w), "OnScreenDisplay");
+    preview_update_set_osd_font(f);
 
-void appr_setup_font_display(GtkWidget *w)
-{
-    preview_update_set_osd_font(appr_setup_font(w, "OnScreenDisplay"));
+    mapping = FALSE;
 }
 
 void on_window_border_toggled(GtkToggleButton *w, gpointer data)
@@ -155,30 +145,30 @@ void on_title_layout_changed(GtkEntry *w, gpointer data)
 
 void on_font_active_font_set(GtkFontButton *w, gpointer data)
 {
-    preview_update_set_active_font(appr_set_font(w, "ActiveWindow"));
+    preview_update_set_active_font(write_font(w, "ActiveWindow"));
 }
 
 void on_font_inactive_font_set(GtkFontButton *w, gpointer data)
 {
-    preview_update_set_inactive_font(appr_set_font(w, "InactiveWindow"));
+    preview_update_set_inactive_font(write_font(w, "InactiveWindow"));
 }
 
 void on_font_menu_header_font_set(GtkFontButton *w, gpointer data)
 {
-    preview_update_set_menu_header_font(appr_set_font(w, "MenuHeader"));
+    preview_update_set_menu_header_font(write_font(w, "MenuHeader"));
 }
 
 void on_font_menu_item_font_set(GtkFontButton *w, gpointer data)
 {
-    preview_update_set_menu_item_font(appr_set_font(w, "MenuItem"));
+    preview_update_set_menu_item_font(write_font(w, "MenuItem"));
 }
 
 void on_font_display_font_set(GtkFontButton *w, gpointer data)
 {
-    preview_update_set_osd_font(appr_set_font(w, "OnScreenDisplay"));
+    preview_update_set_osd_font(write_font(w, "OnScreenDisplay"));
 }
 
-static RrFont *appr_setup_font(GtkWidget *w, const gchar *place)
+static RrFont *read_font(GtkFontButton *w, const gchar *place)
 {
     RrFont *font;
     gchar *fontstring, *node;
@@ -223,7 +213,7 @@ static RrFont *appr_setup_font(GtkWidget *w, const gchar *place)
     }
 
     fontstring = g_strdup_printf("%s %s %s %s", name, weight, slant, size);
-    gtk_font_button_set_font_name(GTK_FONT_BUTTON(w), fontstring);
+    gtk_font_button_set_font_name(w, fontstring);
 
     if (!g_ascii_strcasecmp(weight, "Bold")) rr_weight = RR_FONTWEIGHT_BOLD;
     if (!g_ascii_strcasecmp(slant, "Italic")) rr_slant = RR_FONTSLANT_ITALIC;
@@ -241,7 +231,7 @@ static RrFont *appr_setup_font(GtkWidget *w, const gchar *place)
     return font;
 }
 
-static RrFont *appr_set_font(GtkFontButton *w, const gchar *place)
+static RrFont *write_font(GtkFontButton *w, const gchar *place)
 {
     gchar *c;
     gchar *font, *node;
index 16e475c783b295e4fb6547a90ba9d12cd853963e..f45503d35f9d49e533581f746ab062e5f35f4b1d 100644 (file)
 #ifndef obconf__appearance_h
 #define obconf__appearance_h
 
-void appr_setup_window_border    (GtkWidget *w);
-void appr_setup_title_layout     (GtkWidget *w);
-
-void appr_setup_font_active      (GtkWidget *w);
-void appr_setup_font_inactive    (GtkWidget *w);
-void appr_setup_font_menu_header (GtkWidget *w);
-void appr_setup_font_menu_item   (GtkWidget *w);
-void appr_setup_font_display     (GtkWidget *w);
+void appearance_setup_tab();
 
 #endif
index d9f578d9ca3bc6236dcfb1484d2f14be8d7bf267..8e55c877e1774b776ffb89bf71d62eaf272bd7e5 100644 (file)
@@ -158,13 +158,7 @@ int main(int argc, char **argv)
 
     theme_setup_names(get_widget("theme_names"));
 
-    appr_setup_window_border(get_widget("window_border"));
-    appr_setup_title_layout(get_widget("title_layout"));
-    appr_setup_font_active(get_widget("font_active"));
-    appr_setup_font_inactive(get_widget("font_inactive"));
-    appr_setup_font_menu_header(get_widget("font_menu_header"));
-    appr_setup_font_menu_item(get_widget("font_menu_item"));
-    appr_setup_font_display(get_widget("font_display"));
+    appearance_setup_tab();
 
     behavior_setup_tab();
     behavior_setup_focus_mouse(get_widget("focus_mouse"));