[Xfce4-commits] <xfce4-xkb-plugin:master> Text size on icon is noew adjustable (bug #6703 by Rinat) 3 modes is now available in options: small, medium, large.

Azamat H. Hackimov noreply at xfce.org
Fri Nov 4 17:00:02 CET 2011


Updating branch refs/heads/master
         to c4b5d2746aefd562f324a12fa789423d22ff4324 (commit)
       from 8f25a9eeeb812f49ed5ab030549f6d3763756c0b (commit)

commit c4b5d2746aefd562f324a12fa789423d22ff4324
Author: Azamat H. Hackimov <azamat.hackimov at gmail.com>
Date:   Fri Nov 4 21:56:19 2011 +0600

    Text size on icon is noew adjustable (bug #6703 by Rinat)
    3 modes is now available in options: small, medium, large.

 ChangeLog                          |    1 +
 panel-plugin/xfce4-xkb-plugin.c    |    3 +++
 panel-plugin/xfce4-xkb-plugin.h    |    8 ++++++++
 panel-plugin/xkb-cairo.c           |   34 ++++++++++++++++------------------
 panel-plugin/xkb-cairo.h           |    1 +
 panel-plugin/xkb-callbacks.c       |    1 +
 panel-plugin/xkb-settings-dialog.c |   23 ++++++++++++++++++++++-
 7 files changed, 52 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 404b7d9..6bc3971 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 2011-11-04 20:42  winterheart
+	* Text size on icon is noew adjustable (bug #6703 by Rinat)
 	* New flag: Cambodia (request from Janne Snabb)
 
 2011-10-15 18:54  winterheart
diff --git a/panel-plugin/xfce4-xkb-plugin.c b/panel-plugin/xfce4-xkb-plugin.c
index c8ccae8..6a0635a 100644
--- a/panel-plugin/xfce4-xkb-plugin.c
+++ b/panel-plugin/xfce4-xkb-plugin.c
@@ -261,6 +261,7 @@ xfce_xkb_save_config (XfcePanelPlugin *plugin, t_xkb *xkb)
     xfce_rc_set_group (rcfile, NULL);
 
     xfce_rc_write_int_entry (rcfile, "display_type", xkb->display_type);
+    xfce_rc_write_int_entry (rcfile, "display_textsize", xkb->display_textsize);
     xfce_rc_write_int_entry (rcfile, "group_policy", xkb->settings->group_policy);
     xfce_rc_write_int_entry (rcfile, "default_group", xkb->settings->default_group);
     xfce_rc_write_bool_entry (rcfile, "never_modify_config", xkb->settings->never_modify_config);
@@ -293,6 +294,7 @@ xkb_load_config (t_xkb *xkb, const gchar *filename)
         xfce_rc_set_group (rcfile, NULL);
 
         xkb->display_type = xfce_rc_read_int_entry (rcfile, "display_type", DISPLAY_TYPE_IMAGE);
+        xkb->display_textsize = xfce_rc_read_int_entry (rcfile, "display_textsize", DISPLAY_TEXTSIZE_SMALL);
         xkb->settings->group_policy = xfce_rc_read_int_entry (rcfile, "group_policy", GROUP_POLICY_PER_APPLICATION);
 
         if (xkb->settings->group_policy != GROUP_POLICY_GLOBAL)
@@ -324,6 +326,7 @@ static void
 xkb_load_default (t_xkb *xkb)
 {
     xkb->display_type = DISPLAY_TYPE_IMAGE;
+    xkb->display_textsize = DISPLAY_TEXTSIZE_SMALL;
     xkb->settings->group_policy = GROUP_POLICY_PER_APPLICATION;
     xkb->settings->default_group = 0;
     xkb->settings->kbd_config = NULL;
diff --git a/panel-plugin/xfce4-xkb-plugin.h b/panel-plugin/xfce4-xkb-plugin.h
index 12aed1f..ef9b995 100644
--- a/panel-plugin/xfce4-xkb-plugin.h
+++ b/panel-plugin/xfce4-xkb-plugin.h
@@ -42,6 +42,13 @@ typedef enum
     DISPLAY_TYPE_TEXT = 1
 } t_display_type;
 
+typedef enum
+{
+    DISPLAY_TEXTSIZE_SMALL = 0,
+    DISPLAY_TEXTSIZE_MEDIUM = 1,
+    DISPLAY_TEXTSIZE_LARGE = 2
+} t_display_textsize;
+
 typedef struct
 {
     XfcePanelPlugin *plugin;
@@ -53,6 +60,7 @@ typedef struct
     gint button_vsize;            /* read allocated button size - see below */
 
     t_display_type display_type;  /* display layout as image ot text */
+    t_display_textsize display_textsize; /* text size for text layout */
     t_xkb_settings *settings;     /* per-app setting and default group */
 
     gint button_state;            /* gtk state of the button */
diff --git a/panel-plugin/xkb-cairo.c b/panel-plugin/xkb-cairo.c
index eeb18ac..3b828ec 100644
--- a/panel-plugin/xkb-cairo.c
+++ b/panel-plugin/xkb-cairo.c
@@ -25,6 +25,7 @@
 
 #include "xkb-cairo.h"
 #include "xkb-util.h"
+#include "xfce4-xkb-plugin.h"
 
 #define XKB_PREFERRED_FONT "Courier New, Courier 10 Pitch, Monospace Bold %d"
 
@@ -44,23 +45,6 @@
     cairo_device_to_user (cr, &xx, &yy); \
     cairo_move_to (cr, xx, yy);
 
-gint font_sizes[113] = {
-    6,        6,        6,        6,        6,        6,        6,        6,
-    7,        7,        8,        8,        8,        8,        8,        8,
-    10,       10,       10,       10,       12,       12,       14,       14,
-    14,       14,       14,       14,       16,       16,       16,       16,
-    18,       18,       18,       18,       20,       20,       20,       20,
-    20,       20,       22,       22,       22,       22,       24,       24,
-    24,       24,       26,       26,       26,       26,       28,       28,
-    28,       28,       30,       30,       30,       30,       30,       30,
-    32,       32,       32,       32,       34,       34,       34,       34,
-    34,       34,       36,       36,       36,       36,       36,       36,
-    38,       38,       38,       38,       38,       38,       38,       38,
-    40,       40,       40,       40,       40,       40,       42,       42,
-    42,       42,       42,       42,       44,       44,       44,       44,
-    44,       44,       46,       46,       46,       46,       46,       46,
-    48
-};
 
 void
 xkb_cairo_draw_flag (cairo_t *cr,
@@ -97,6 +81,7 @@ xkb_cairo_draw_flag (cairo_t *cr,
                 actual_width, actual_height,
                 width, height,
                 variant_markers_count,
+                DISPLAY_TEXTSIZE_SMALL,     // not used for flag layout
                 fgcolor);
         return;
     }
@@ -150,6 +135,7 @@ xkb_cairo_draw_label (cairo_t *cr,
                       gint width,
                       gint height,
                       gint variant_markers_count,
+                      gint textsize,
                       GdkColor fgcolor)
 {
     gchar *normalized_group_name;
@@ -175,7 +161,19 @@ xkb_cairo_draw_label (cairo_t *cr,
     }
 
     pango_layout_set_text (layout, normalized_group_name, -1);
-    g_sprintf (font_str, XKB_PREFERRED_FONT, font_sizes[panel_size - 16]);
+    switch (textsize){
+        case DISPLAY_TEXTSIZE_SMALL:
+        default:    /* catch misconfiguration */
+            g_sprintf (font_str, XKB_PREFERRED_FONT, (int)(0.375 * panel_size) );
+            break;
+        case DISPLAY_TEXTSIZE_MEDIUM:
+            g_sprintf (font_str, XKB_PREFERRED_FONT, (int)(0.600 * panel_size) );
+            break;
+        case DISPLAY_TEXTSIZE_LARGE:
+            g_sprintf (font_str, XKB_PREFERRED_FONT, (int)(0.900 * panel_size) );
+            break;
+    }
+
     desc = pango_font_description_from_string (font_str);
     pango_layout_set_font_description (layout, desc);
     pango_font_description_free (desc);
diff --git a/panel-plugin/xkb-cairo.h b/panel-plugin/xkb-cairo.h
index 90c9996..a8ecf32 100644
--- a/panel-plugin/xkb-cairo.h
+++ b/panel-plugin/xkb-cairo.h
@@ -52,6 +52,7 @@ void        xkb_cairo_draw_label    (cairo_t *cr,
                                      gint width,
                                      gint height,
                                      gint variant_markers_count,
+                                     gint textsize,
                                      GdkColor fgcolor);
 
 #endif
diff --git a/panel-plugin/xkb-callbacks.c b/panel-plugin/xkb-callbacks.c
index 9ab4716..d12e086 100644
--- a/panel-plugin/xkb-callbacks.c
+++ b/panel-plugin/xkb-callbacks.c
@@ -131,6 +131,7 @@ xkb_plugin_layout_image_exposed (GtkWidget *widget,
                 actual_hsize, actual_vsize,
                 xkb->hsize, xkb->vsize,
                 xkb_config_variant_index_for_group (-1),
+                xkb->display_textsize,
                 fgcolor
         );
     }
diff --git a/panel-plugin/xkb-settings-dialog.c b/panel-plugin/xkb-settings-dialog.c
index 34f004c..e792725 100644
--- a/panel-plugin/xkb-settings-dialog.c
+++ b/panel-plugin/xkb-settings-dialog.c
@@ -90,6 +90,13 @@ on_display_type_changed (GtkComboBox *cb, t_xkb *xkb)
 }
 
 static void
+on_display_textsize_changed (GtkComboBox *cb, t_xkb *xkb)
+{
+    xkb->display_textsize = gtk_combo_box_get_active (cb);
+    xkb_refresh_gui (xkb);
+}
+
+static void
 on_group_policy_changed (GtkComboBox *cb, t_xkb *xkb)
 {
     xkb->settings->group_policy = gtk_combo_box_get_active (cb);
@@ -495,6 +502,7 @@ xfce_xkb_configure (XfcePanelPlugin *plugin,
 {
     GtkWidget *display_type_optmenu, *group_policy_combo;
     GtkWidget *vbox, *display_type_frame, *group_policy_frame, *bin;
+    GtkWidget *display_textsize_frame, *display_textsize_optmenu;
 
     GtkCellRenderer *renderer, *renderer2;
     GtkWidget *vbox1, *vbox2, *hbox, *frame;
@@ -686,6 +694,18 @@ xfce_xkb_configure (XfcePanelPlugin *plugin,
     gtk_widget_set_size_request (display_type_optmenu, 230, -1);
     gtk_container_add (GTK_CONTAINER (bin), display_type_optmenu);
 
+    /* text size option */
+    display_textsize_frame = xfce_gtk_frame_box_new (_("Text size:"), &bin);
+    gtk_widget_show (display_textsize_frame);
+    gtk_box_pack_start (GTK_BOX (vbox), display_textsize_frame, TRUE, TRUE, 2);
+
+    display_textsize_optmenu = gtk_combo_box_new_text ();
+    gtk_combo_box_append_text (GTK_COMBO_BOX (display_textsize_optmenu), _("small"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (display_textsize_optmenu), _("medium"));
+    gtk_combo_box_append_text (GTK_COMBO_BOX (display_textsize_optmenu), _("large"));
+    gtk_widget_set_size_request (display_textsize_optmenu, 230, -1);
+    gtk_container_add (GTK_CONTAINER (bin), display_textsize_optmenu);
+
     group_policy_frame = xfce_gtk_frame_box_new (_("Manage layout:"), &bin);
     gtk_widget_show (group_policy_frame);
     gtk_box_pack_start (GTK_BOX (vbox), group_policy_frame, TRUE, TRUE, 2);
@@ -704,11 +724,12 @@ xfce_xkb_configure (XfcePanelPlugin *plugin,
             G_CALLBACK (on_settings_close), xkb);
 
     gtk_combo_box_set_active (GTK_COMBO_BOX (display_type_optmenu), xkb->display_type);
-
+    gtk_combo_box_set_active (GTK_COMBO_BOX (display_textsize_optmenu), xkb->display_textsize);
     gtk_combo_box_set_active (GTK_COMBO_BOX (group_policy_combo), xkb->settings->group_policy);
 
     g_signal_connect (display_type_optmenu, "changed", G_CALLBACK (on_display_type_changed), xkb);
     g_signal_connect (group_policy_combo, "changed", G_CALLBACK (on_group_policy_changed), xkb);
+    g_signal_connect (display_textsize_optmenu, "changed", G_CALLBACK (on_display_textsize_changed), xkb);
 
     g_signal_connect (xkb->add_layout_btn, "clicked", G_CALLBACK (xkb_settings_add_layout), xkb);
     g_signal_connect (xkb->rm_layout_btn, "clicked", G_CALLBACK (xkb_settings_rm_layout), xkb);


More information about the Xfce4-commits mailing list