[gnome-power-manager] switch to GtkComboBoxText.
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-power-manager] switch to GtkComboBoxText.
- Date: Mon, 25 Oct 2010 08:31:37 +0000 (UTC)
commit 81cffa48a4364bb969f969dbd62fa0d6f2e4150f
Author: Alban Browaeys <prahal yahoo com>
Date: Tue Oct 19 01:29:58 2010 +0200
switch to GtkComboBoxText.
data/gpm-prefs.ui | 39 ++++++++++++++++++++++-----------
data/gpm-statistics.ui | 9 +++++--
src/cc-power-panel.c | 38 +++++++--------------------------
src/gpm-statistics.c | 55 ++++++++++++++----------------------------------
4 files changed, 56 insertions(+), 85 deletions(-)
---
diff --git a/data/gpm-prefs.ui b/data/gpm-prefs.ui
index c7ff62e..21d04b2 100644
--- a/data/gpm-prefs.ui
+++ b/data/gpm-prefs.ui
@@ -40,7 +40,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_ac_display">
+ <object class="GtkComboBoxText" id="combobox_ac_display">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -74,7 +75,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_ac_computer">
+ <object class="GtkComboBoxText" id="combobox_ac_computer">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -108,7 +110,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_ac_lid">
+ <object class="GtkComboBoxText" id="combobox_ac_lid">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -191,7 +194,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_battery_display">
+ <object class="GtkComboBoxText" id="combobox_battery_display">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -225,7 +229,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_battery_computer">
+ <object class="GtkComboBoxText" id="combobox_battery_computer">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -259,7 +264,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_battery_lid">
+ <object class="GtkComboBoxText" id="combobox_battery_lid">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -293,7 +299,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_battery_critical">
+ <object class="GtkComboBoxText" id="combobox_battery_critical">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -393,7 +400,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_ups_display">
+ <object class="GtkComboBoxText" id="combobox_ups_display">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -427,7 +435,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_ups_computer">
+ <object class="GtkComboBoxText" id="combobox_ups_computer">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -461,7 +470,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_ups_low">
+ <object class="GtkComboBoxText" id="combobox_ups_low">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -495,7 +505,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_ups_critical">
+ <object class="GtkComboBoxText" id="combobox_ups_critical">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -554,7 +565,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_general_power">
+ <object class="GtkComboBoxText" id="combobox_general_power">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -588,7 +600,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_general_suspend">
+ <object class="GtkComboBoxText" id="combobox_general_suspend">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
diff --git a/data/gpm-statistics.ui b/data/gpm-statistics.ui
index 8fe3d04..b8c0c79 100644
--- a/data/gpm-statistics.ui
+++ b/data/gpm-statistics.ui
@@ -92,7 +92,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_history_type">
+ <object class="GtkComboBoxText" id="combobox_history_type">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -119,7 +120,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_history_time">
+ <object class="GtkComboBoxText" id="combobox_history_time">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
@@ -259,7 +261,8 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="combobox_stats_type">
+ <object class="GtkComboBoxText" id="combobox_stats_type">
+ <property name="entry-text-column">0</property>
<property name="visible">True</property>
</object>
<packing>
diff --git a/src/cc-power-panel.c b/src/cc-power-panel.c
index c7e4517..9413d5e 100644
--- a/src/cc-power-panel.c
+++ b/src/cc-power-panel.c
@@ -115,26 +115,6 @@ cc_power_panel_action_time_changed_cb (GtkWidget *widget, CcPowerPanel *panel)
}
/**
- * cc_power_panel_set_combo_simple_text:
- **/
-static void
-cc_power_panel_set_combo_simple_text (GtkWidget *combo_box)
-{
- GtkCellRenderer *cell;
- GtkListStore *store;
-
- store = gtk_list_store_new (1, G_TYPE_STRING);
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
- g_object_unref (store);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
- "text", 0,
- NULL);
-}
-
-/**
* cc_power_panel_actions_destroy_cb:
**/
static void
@@ -159,7 +139,6 @@ cc_power_panel_setup_action_combo (CcPowerPanel *panel, const gchar *widget_name
GpmActionPolicy *actions_added;
widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, widget_name));
- cc_power_panel_set_combo_simple_text (widget);
value = g_settings_get_enum (panel->priv->settings, gpm_pref_key);
is_writable = g_settings_is_writable (panel->priv->settings, gpm_pref_key);
@@ -176,26 +155,26 @@ cc_power_panel_setup_action_combo (CcPowerPanel *panel, const gchar *widget_name
if (policy == GPM_ACTION_POLICY_SHUTDOWN && !panel->priv->can_shutdown) {
g_debug ("Cannot add option, as cannot shutdown.");
} else if (policy == GPM_ACTION_POLICY_SHUTDOWN && panel->priv->can_shutdown) {
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Shutdown"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Shutdown"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
} else if (policy == GPM_ACTION_POLICY_SUSPEND && !panel->priv->can_suspend) {
g_debug ("Cannot add option, as cannot suspend.");
} else if (policy == GPM_ACTION_POLICY_HIBERNATE && !panel->priv->can_hibernate) {
g_debug ("Cannot add option, as cannot hibernate.");
} else if (policy == GPM_ACTION_POLICY_SUSPEND && panel->priv->can_suspend) {
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Suspend"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Suspend"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
} else if (policy == GPM_ACTION_POLICY_HIBERNATE && panel->priv->can_hibernate) {
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Hibernate"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Hibernate"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
} else if (policy == GPM_ACTION_POLICY_BLANK) {
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Blank screen"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Blank screen"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
} else if (policy == GPM_ACTION_POLICY_INTERACTIVE) {
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Ask me"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Ask me"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
} else if (policy == GPM_ACTION_POLICY_NOTHING) {
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Do nothing"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Do nothing"));
g_ptr_array_add (array, GINT_TO_POINTER (policy));
} else {
g_warning ("Unknown action read from settings: %i", policy);
@@ -248,7 +227,6 @@ cc_power_panel_setup_time_combo (CcPowerPanel *panel, const gchar *widget_name,
GArray *values;
widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, widget_name));
- cc_power_panel_set_combo_simple_text (widget);
value = g_settings_get_int (panel->priv->settings, gpm_pref_key);
is_writable = g_settings_is_writable (panel->priv->settings, gpm_pref_key);
@@ -285,10 +263,10 @@ cc_power_panel_setup_time_combo (CcPowerPanel *panel, const gchar *widget_name,
/* get translation for number of seconds */
if (loop_value != 0) {
text = gpm_get_timestring (loop_value);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), text);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), text);
g_free (text);
} else {
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), _("Never"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), _("Never"));
}
/* matches, so set default */
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index c3e9893..7ac12c5 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -1275,7 +1275,7 @@ gpm_stats_history_type_combo_changed_cb (GtkWidget *widget, gpointer data)
gchar *value;
const gchar *axis_x = NULL;
const gchar *axis_y = NULL;
- value = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
+ value = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget));
if (g_strcmp0 (value, GPM_HISTORY_RATE_TEXT) == 0) {
history_type = GPM_HISTORY_RATE_VALUE;
/* TRANSLATORS: this is the X axis on the graph */
@@ -1326,7 +1326,7 @@ gpm_stats_type_combo_changed_cb (GtkWidget *widget, gpointer data)
gchar *value;
const gchar *axis_x = NULL;
const gchar *axis_y = NULL;
- value = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
+ value = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget));
if (g_strcmp0 (value, GPM_STATS_CHARGE_DATA_TEXT) == 0) {
stats_type = GPM_STATS_CHARGE_DATA_VALUE;
/* TRANSLATORS: this is the X axis on the graph for the whole battery device */
@@ -1375,7 +1375,7 @@ static void
gpm_stats_range_combo_changed (GtkWidget *widget, gpointer data)
{
gchar *value;
- value = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
+ value = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget));
if (g_strcmp0 (value, GPM_HISTORY_MINUTE_TEXT) == 0)
history_time = GPM_HISTORY_MINUTE_VALUE;
else if (g_strcmp0 (value, GPM_HISTORY_HOUR_TEXT) == 0)
@@ -1449,26 +1449,6 @@ gpm_stats_points_checkbox_stats_cb (GtkWidget *widget, gpointer data)
}
/**
- * gpm_stats_set_combo_simple_text:
- **/
-static void
-gpm_stats_set_combo_simple_text (GtkWidget *combo_box)
-{
- GtkCellRenderer *cell;
- GtkListStore *store;
-
- store = gtk_list_store_new (1, G_TYPE_STRING);
- gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
- g_object_unref (store);
-
- cell = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
- "text", 0,
- NULL);
-}
-
-/**
* gpm_stats_highlight_device:
**/
static void
@@ -1708,11 +1688,10 @@ main (int argc, char *argv[])
stats_type = GPM_STATS_CHARGE_DATA_VALUE;
widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_history_type"));
- gpm_stats_set_combo_simple_text (widget);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_RATE_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_CHARGE_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_TIME_FULL_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_TIME_EMPTY_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_RATE_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_CHARGE_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_TIME_FULL_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_TIME_EMPTY_TEXT);
if (g_strcmp0 (history_type, GPM_HISTORY_RATE_VALUE) == 0)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
else
@@ -1721,11 +1700,10 @@ main (int argc, char *argv[])
G_CALLBACK (gpm_stats_history_type_combo_changed_cb), NULL);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_stats_type"));
- gpm_stats_set_combo_simple_text (widget);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_STATS_CHARGE_DATA_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_STATS_CHARGE_ACCURACY_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_STATS_DISCHARGE_DATA_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_STATS_DISCHARGE_ACCURACY_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_STATS_CHARGE_DATA_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_STATS_CHARGE_ACCURACY_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_STATS_DISCHARGE_DATA_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_STATS_DISCHARGE_ACCURACY_TEXT);
if (g_strcmp0 (stats_type, GPM_STATS_CHARGE_DATA_VALUE) == 0)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
else if (g_strcmp0 (stats_type, GPM_STATS_CHARGE_DATA_VALUE) == 0)
@@ -1740,12 +1718,11 @@ main (int argc, char *argv[])
G_CALLBACK (gpm_stats_type_combo_changed_cb), NULL);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "combobox_history_time"));
- gpm_stats_set_combo_simple_text (widget);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_MINUTE_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_HOUR_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_HOURS_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_DAY_TEXT);
- gtk_combo_box_append_text (GTK_COMBO_BOX (widget), GPM_HISTORY_WEEK_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_MINUTE_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_HOUR_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_HOURS_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_DAY_TEXT);
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), GPM_HISTORY_WEEK_TEXT);
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
if (history_time == GPM_HISTORY_MINUTE_VALUE)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]