summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCallum McKenzie <callum@src.gnome.org>2009-01-13 08:36:09 +0000
committerCallum McKenzie <callum@src.gnome.org>2009-01-13 08:36:09 +0000
commitcb0883ff5487a2d9c6a079bf0e1c8363d3319545 (patch)
tree9a2152491023ec82db55141cb58942dfe04a4582
parente2abfbf099940adab7781e94f2aee2c79a084b02 (diff)
Backport of fixes to the CPU frequency applet from 2.25
svn path=/branches/gnome-2-24/; revision=11183
-rw-r--r--ChangeLog5
-rw-r--r--NEWS9
-rw-r--r--configure.in2
-rw-r--r--cpufreq/ChangeLog8
-rw-r--r--cpufreq/src/cpufreq-applet.c173
5 files changed, 98 insertions, 99 deletions
diff --git a/ChangeLog b/ChangeLog
index f94d6f1fa..debeb6942 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-13 Callum McKenzie <callum@spooky-possum.org>
+
+ * NEWS:
+ * configure.in: 2.24.3
+
==================== 2.24.2 ======================
2008-11-25 Callum McKenzie <callum@spooky-possum.org>
diff --git a/NEWS b/NEWS
index bebd1ad62..0f670e744 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+Changes in GNOME-Applets 2.24.3
+===============================
+
+CPU Frequency Applet:
+ - Geometry and update fixes backported from 2.25.
+
+Translation Updates:
+bg, et, pt_BR
+
Changes in GNOME-Applets 2.24.2
===============================
diff --git a/configure.in b/configure.in
index b4afd43b3..d79859c29 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,7 @@
dnl ***************************************************************************
dnl *** configure.in for GNOME-APPLETS ***
dnl ***************************************************************************
-AC_INIT(gnome-applets, 2.24.2)
+AC_INIT(gnome-applets, 2.24.3)
AC_PREREQ(2.59)
AM_CONFIG_HEADER(config.h)
diff --git a/cpufreq/ChangeLog b/cpufreq/ChangeLog
index fc6848c33..4e7b0db2f 100644
--- a/cpufreq/ChangeLog
+++ b/cpufreq/ChangeLog
@@ -1,3 +1,11 @@
+2009-01-13 Callum McKenzie <callum@spooky-possum.org>
+
+ * src/cpufreq-applet.c: Backport of changes in trunk that might
+ help fix bugs like 556099. Original work by Carlos Garcia
+ Campos. These changes were made to trunk between revisions 11151
+ and 11156. They mostly involve making sure the geometry is set up
+ correctly and the applet is updated appropriately.
+
==================== 2.24.2 ======================
==================== 2.24.1 ======================
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c
index 26a104491..83d382568 100644
--- a/cpufreq/src/cpufreq-applet.c
+++ b/cpufreq/src/cpufreq-applet.c
@@ -50,6 +50,8 @@ struct _CPUFreqApplet {
PanelApplet base;
/* Visibility */
+ CPUFreqShowMode show_mode;
+ CPUFreqShowTextMode show_text_mode;
gboolean show_freq;
gboolean show_perc;
gboolean show_unit;
@@ -64,6 +66,7 @@ struct _CPUFreqApplet {
GtkWidget *unit_label;
GtkWidget *icon;
GtkWidget *box;
+ GtkWidget *labels_box;
GtkWidget *container;
GdkPixbuf *pixbufs[5];
@@ -113,10 +116,6 @@ static void cpufreq_applet_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void cpufreq_applet_change_orient (PanelApplet *pa,
PanelAppletOrient orient);
-static void cpufreq_applet_change_background (PanelApplet *pa,
- PanelAppletBackgroundType type,
- GdkColor *color,
- GdkPixmap *pixmap);
static gboolean cpufreq_applet_factory (CPUFreqApplet *applet,
const gchar *iid,
@@ -196,7 +195,11 @@ cpufreq_applet_init (CPUFreqApplet *applet)
applet->need_refresh = TRUE;
+ applet->show_mode = CPUFREQ_MODE_BOTH;
+ applet->show_text_mode = CPUFREQ_MODE_TEXT_FREQUENCY_UNIT;
+
panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR);
+ panel_applet_set_background_widget (PANEL_APPLET (applet), GTK_WIDGET (applet));
applet->size = panel_applet_get_size (PANEL_APPLET (applet));
applet->orient = panel_applet_get_orient (PANEL_APPLET (applet));
@@ -214,8 +217,6 @@ cpufreq_applet_init (CPUFreqApplet *applet)
gtk_container_add (GTK_CONTAINER (applet), applet->container);
gtk_widget_show (applet->container);
-
- gtk_widget_show (GTK_WIDGET (applet));
}
static void
@@ -233,7 +234,6 @@ cpufreq_applet_class_init (CPUFreqAppletClass *klass)
widget_class->key_press_event = cpufreq_applet_key_press;
applet_class->change_orient = cpufreq_applet_change_orient;
- applet_class->change_background = cpufreq_applet_change_background;
}
static void
@@ -277,6 +277,8 @@ cpufreq_applet_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
applet = CPUFREQ_APPLET (widget);
+ GTK_WIDGET_CLASS (cpufreq_applet_parent_class)->size_allocate (widget, allocation);
+
switch (applet->orient) {
case PANEL_APPLET_ORIENT_LEFT:
case PANEL_APPLET_ORIENT_RIGHT:
@@ -292,8 +294,6 @@ cpufreq_applet_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
applet->size = size;
cpufreq_applet_refresh (applet);
}
-
- GTK_WIDGET_CLASS (cpufreq_applet_parent_class)->size_allocate (widget, allocation);
}
static gint
@@ -382,7 +382,8 @@ static void
cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
CPUFreqApplet *applet;
- gint width = 0;
+ gint labels_width = 0;
+ gint width;
applet = CPUFREQ_APPLET (widget);
@@ -393,23 +394,27 @@ cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition)
return;
if (applet->show_freq) {
- width += cpufreq_applet_get_max_label_width (applet) + 2;
+ labels_width += cpufreq_applet_get_max_label_width (applet) + 2;
}
if (applet->show_perc) {
- width += cpufreq_applet_get_max_perc_width (applet);
+ labels_width += cpufreq_applet_get_max_perc_width (applet);
}
if (applet->show_unit) {
- width += cpufreq_applet_get_max_unit_width (applet);
+ labels_width += cpufreq_applet_get_max_unit_width (applet);
}
if (applet->show_icon) {
GtkRequisition req;
gtk_widget_size_request (applet->icon, &req);
- width += req.width + 2;
- }
+ width = GTK_IS_HBOX (applet->box) ?
+ labels_width + req.width + 2 :
+ MAX (labels_width, req.width + 2);
+ } else {
+ width = labels_width;
+ }
requisition->width = width;
}
@@ -558,45 +563,6 @@ cpufreq_applet_change_orient (PanelApplet *pa, PanelAppletOrient orient)
}
static void
-cpufreq_applet_change_background (PanelApplet *pa,
- PanelAppletBackgroundType type,
- GdkColor *color, GdkPixmap *pixmap)
-{
- CPUFreqApplet *applet;
- /* Taken from TrashApplet */
- GtkRcStyle *rc_style;
- GtkStyle *style;
-
- applet = CPUFREQ_APPLET (pa);
-
- /* reset style */
- gtk_widget_set_style (GTK_WIDGET (applet), NULL);
- rc_style = gtk_rc_style_new ();
- gtk_widget_modify_style (GTK_WIDGET (applet), rc_style);
- gtk_rc_style_unref (rc_style);
-
- switch (type) {
- case PANEL_PIXMAP_BACKGROUND:
- style = gtk_style_copy (GTK_WIDGET (applet)->style);
- if (style->bg_pixmap[GTK_STATE_NORMAL])
- g_object_unref (
- style->bg_pixmap[GTK_STATE_NORMAL]);
- style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (
- pixmap);
- gtk_widget_set_style (GTK_WIDGET (applet), style);
- g_object_unref (style);
- break;
- case PANEL_COLOR_BACKGROUND:
- gtk_widget_modify_bg (GTK_WIDGET (applet),
- GTK_STATE_NORMAL, color);
- break;
- case PANEL_NO_BACKGROUND:
- default:
- break;
- }
-}
-
-static void
cpufreq_applet_preferences_cb (BonoboUIComponent *uic,
CPUFreqApplet *applet,
const gchar *cname)
@@ -684,6 +650,14 @@ cpufreq_applet_pixmap_set_image (CPUFreqApplet *applet, gint perc)
gtk_image_set_from_pixbuf (GTK_IMAGE (applet->icon), applet->pixbufs[image]);
}
+static gboolean
+refresh_cb (CPUFreqApplet *applet)
+{
+ cpufreq_applet_refresh (applet);
+
+ return FALSE;
+}
+
static void
cpufreq_applet_update_visibility (CPUFreqApplet *applet)
{
@@ -718,9 +692,15 @@ cpufreq_applet_update_visibility (CPUFreqApplet *applet)
show_icon = TRUE;
}
- if ((applet->show_perc && show_freq) ||
- (applet->show_freq && show_perc))
- need_update = TRUE;
+ if (applet->show_mode != show_mode) {
+ applet->show_mode = show_mode;
+ need_update = TRUE;
+ }
+
+ if (applet->show_text_mode != show_text_mode) {
+ applet->show_text_mode = show_text_mode;
+ need_update = TRUE;
+ }
if (show_freq != applet->show_freq) {
applet->show_freq = show_freq;
@@ -758,7 +738,7 @@ cpufreq_applet_update_visibility (CPUFreqApplet *applet)
}
if (changed)
- cpufreq_applet_refresh (applet);
+ g_idle_add ((GSourceFunc)refresh_cb, applet);
if (need_update)
cpufreq_applet_update (applet, applet->monitor);
@@ -767,7 +747,7 @@ cpufreq_applet_update_visibility (CPUFreqApplet *applet)
static void
cpufreq_applet_update (CPUFreqApplet *applet, CPUFreqMonitor *monitor)
{
- gchar *text_tip, *text_mode;
+ gchar *text_tip, *text_mode = NULL;
gchar *freq_label, *unit_label;
gint freq;
gint perc;
@@ -777,7 +757,7 @@ cpufreq_applet_update (CPUFreqApplet *applet, CPUFreqMonitor *monitor)
cpu = cpufreq_monitor_get_cpu (monitor);
freq = cpufreq_monitor_get_frequency (monitor);
perc = cpufreq_monitor_get_percentage (monitor);
- governor = g_strdup (cpufreq_monitor_get_governor (monitor));
+ governor = cpufreq_monitor_get_governor (monitor);
freq_label = cpufreq_utils_get_frequency_label (freq);
unit_label = cpufreq_utils_get_frequency_unit (freq);
@@ -802,24 +782,30 @@ cpufreq_applet_update (CPUFreqApplet *applet, CPUFreqMonitor *monitor)
cpufreq_applet_pixmap_set_image (applet, perc);
}
- governor[0] = g_ascii_toupper (governor[0]);
- text_mode = g_strdup_printf ("%s\n%s %s (%d%%)",
- governor, freq_label,
- unit_label, perc);
+ if (governor) {
+ gchar *gov_text;
+
+ gov_text = g_strdup (governor);
+ gov_text[0] = g_ascii_toupper (gov_text[0]);
+ text_mode = g_strdup_printf ("%s\n%s %s (%d%%)",
+ gov_text, freq_label,
+ unit_label, perc);
+ g_free (gov_text);
+ }
g_free (freq_label);
g_free (unit_label);
- g_free (governor);
-
- if (cpufreq_utils_get_n_cpus () == 1)
- text_tip = g_strdup_printf ("%s", text_mode);
- else
- text_tip = g_strdup_printf ("CPU %u - %s", cpu, text_mode);
- g_free (text_mode);
-
- gtk_widget_set_tooltip_text (GTK_WIDGET (applet), text_tip);
- g_free (text_tip);
+ if (text_mode) {
+ gchar *text_tip;
+
+ text_tip = cpufreq_utils_get_n_cpus () == 1 ?
+ g_strdup_printf ("%s", text_mode) :
+ g_strdup_printf ("CPU %u - %s", cpu, text_mode);
+ g_free (text_mode);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (applet), text_tip);
+ g_free (text_tip);
+ }
/* Call refresh only the first time */
if (applet->need_refresh) {
@@ -859,7 +845,6 @@ cpufreq_applet_get_widget_size (CPUFreqApplet *applet,
static void
cpufreq_applet_refresh (CPUFreqApplet *applet)
{
- GtkWidget *labels_box = NULL;
gint total_size = 0;
gint panel_size, label_size;
gint unit_label_size, pixmap_size;
@@ -889,27 +874,17 @@ cpufreq_applet_refresh (CPUFreqApplet *applet)
total_size += pixmap_size;
if (applet->box) {
- GtkWidget *child;
- GList *children;
-
- do_unref = TRUE;
- g_object_ref (applet->icon);
- gtk_container_remove (GTK_CONTAINER (applet->box), applet->icon);
- children = gtk_container_get_children (GTK_CONTAINER (applet->box));
- if (children && children->data) {
- /* Should be labels_box */
- child = (GtkWidget *)children->data;
+ if (applet->labels_box) {
g_object_ref (applet->label);
- gtk_container_remove (GTK_CONTAINER (child), applet->label);
+ gtk_container_remove (GTK_CONTAINER (applet->labels_box), applet->label);
g_object_ref (applet->unit_label);
- gtk_container_remove (GTK_CONTAINER (child), applet->unit_label);
+ gtk_container_remove (GTK_CONTAINER (applet->labels_box), applet->unit_label);
}
- g_list_free (children);
gtk_widget_destroy (applet->box);
}
if (horizontal) {
- labels_box = gtk_hbox_new (FALSE, 2);
+ applet->labels_box = gtk_hbox_new (FALSE, 2);
if ((label_size + pixmap_size) <= panel_size)
applet->box = gtk_vbox_new (FALSE, 2);
else
@@ -917,22 +892,22 @@ cpufreq_applet_refresh (CPUFreqApplet *applet)
} else {
if (total_size <= panel_size) {
applet->box = gtk_hbox_new (FALSE, 2);
- labels_box = gtk_hbox_new (FALSE, 2);
+ applet->labels_box = gtk_hbox_new (FALSE, 2);
} else if ((label_size + unit_label_size) <= (panel_size - size_step)) {
applet->box = gtk_vbox_new (FALSE, 2);
- labels_box = gtk_hbox_new (FALSE, 2);
+ applet->labels_box = gtk_hbox_new (FALSE, 2);
} else {
applet->box = gtk_vbox_new (FALSE, 2);
- labels_box = gtk_vbox_new (FALSE, 2);
+ applet->labels_box = gtk_vbox_new (FALSE, 2);
}
}
- gtk_box_pack_start (GTK_BOX (labels_box), applet->label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (labels_box), applet->unit_label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (applet->labels_box), applet->label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (applet->labels_box), applet->unit_label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (applet->box), applet->icon, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (applet->box), labels_box, FALSE, FALSE, 0);
- gtk_widget_show (labels_box);
+ gtk_box_pack_start (GTK_BOX (applet->box), applet->labels_box, FALSE, FALSE, 0);
+ gtk_widget_show (applet->labels_box);
gtk_container_add (GTK_CONTAINER (applet->container), applet->box);
gtk_widget_show (applet->box);
@@ -997,8 +972,6 @@ cpufreq_applet_setup (CPUFreqApplet *applet)
G_CALLBACK (cpufreq_applet_prefs_show_mode_changed),
(gpointer) applet);
- cpufreq_applet_update_visibility (applet);
-
/* Monitor */
applet->monitor = cpufreq_monitor_factory_create_monitor (
cpufreq_prefs_get_cpu (applet->prefs));
@@ -1030,6 +1003,10 @@ cpufreq_applet_setup (CPUFreqApplet *applet)
atk_object_set_name (atk_obj, _("CPU Frequency Scaling Monitor"));
atk_object_set_description (atk_obj, _("This utility shows the current CPU Frequency"));
}
+
+ cpufreq_applet_update_visibility (applet);
+
+ gtk_widget_show (GTK_WIDGET (applet));
}
static gboolean