[Xfce4-commits] <xfce4-cpufreq-plugin:master> Adapt text to the panel's size and orientation

Florian Rivoal noreply at xfce.org
Sun Jan 23 11:26:04 CET 2011


Updating branch refs/heads/master
         to 6836d994bb9191e5b16838d1fcfcbf23bc4ba99d (commit)
       from c978de6ac2326a6427485545d06b5aaa64e46529 (commit)

commit 6836d994bb9191e5b16838d1fcfcbf23bc4ba99d
Author: Florian Rivoal <frivoal at xfce.org>
Date:   Sun Jan 23 09:56:27 2011 +0900

    Adapt text to the panel's size and orientation
    
    The thresholds are arbitrary, but the work well enough with common
    fonts.

 panel-plugin/xfce4-cpufreq-plugin.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/panel-plugin/xfce4-cpufreq-plugin.c b/panel-plugin/xfce4-cpufreq-plugin.c
index 2fb3653..db109fb 100644
--- a/panel-plugin/xfce4-cpufreq-plugin.c
+++ b/panel-plugin/xfce4-cpufreq-plugin.c
@@ -48,21 +48,33 @@ cpufreq_update_label (CpuInfo *cpu)
 	if (!cpuFreq->options->show_label_governor && !cpuFreq->options->show_label_freq)
 		return TRUE;
 	
+	gint size = xfce_panel_plugin_get_size (cpuFreq->plugin);
+	gboolean both = cpu->cur_governor != NULL && cpuFreq->options->show_label_freq && cpuFreq->options->show_label_governor;
+
+	gchar *txt_size = both ?
+	                       (size <= 38 ? (size <= 28 ? "<span size=\"xx-small\">" : "<span size=\"x-small\">") : "<span>") :
+			       (size <= 19 ? "<span size=\"x-small\">" : "<span>"); 
+
 	freq = cpufreq_get_human_readable_freq (cpu->cur_freq);
-	label = g_strconcat (
+	label = g_strconcat (txt_size,
+
 		cpuFreq->options->show_label_freq ? freq : "",
 		
-		cpu->cur_governor != NULL &&
-		cpuFreq->options->show_label_freq && cpuFreq->options->show_label_governor ? "\n" : "",
+		both ? (size <= 25 ? " " : "\n") : "",
 	
 		cpu->cur_governor != NULL &&
 		cpuFreq->options->show_label_governor ? cpu->cur_governor : "",
-		
+
+		"</span>",
 		NULL);
 
 	if (strcmp(label,""))
 	{
-		gtk_label_set_label (GTK_LABEL(cpuFreq->label), label);
+		gtk_label_set_markup (GTK_LABEL(cpuFreq->label), label);
+		if (xfce_panel_plugin_get_orientation (cpuFreq->plugin) == GTK_ORIENTATION_VERTICAL)
+			gtk_label_set_angle (GTK_LABEL(cpuFreq->label), -90);
+		else
+			gtk_label_set_angle (GTK_LABEL(cpuFreq->label), 0);
 		gtk_widget_show (cpuFreq->label);
 	}
 	else
@@ -132,6 +144,7 @@ static void
 cpufreq_orientation_changed (XfcePanelPlugin *plugin, GtkOrientation orientation, CpuFreqPlugin *cpufreq)
 {
 	gtk_orientable_set_orientation (GTK_ORIENTABLE (cpufreq->box), orientation);
+	cpufreq_update_plugin ();
 }
 
 void
@@ -295,6 +308,7 @@ cpufreq_set_size (XfcePanelPlugin *plugin, gint size, CpuFreqPlugin *cpufreq)
 {
 	cpufreq->icon_size = size - 4;
 	cpufreq_update_icon (cpufreq);
+	cpufreq_update_plugin ();
 
 	return TRUE;
 }



More information about the Xfce4-commits mailing list