[network-manager-applet] editor: fix compat with GTK+ <= 2.22



commit 8e75c5f223f9bb07c7b06731bc00ae669e5f3eaf
Author: Dan Williams <dcbw redhat com>
Date:   Wed Aug 17 14:58:03 2011 -0500

    editor: fix compat with GTK+ <= 2.22
    
    Which doesn't have GtkComboBoxText, so we have to use the old way.
    It gets a bit complicated because we can't use the GtkBuilder file
    to store the widget (since that can't change programmatically) so
    we replace the widget in the Builder file with an alignment that
    we stick the programmatically created combo box into.

 src/connection-editor/ce-page-wired.ui    |   10 ++++----
 src/connection-editor/ce-page-wireless.ui |   10 ++++----
 src/connection-editor/page-wired.c        |   31 +++++++++++++++++++++++++++-
 src/connection-editor/page-wireless.c     |   31 +++++++++++++++++++++++++++-
 4 files changed, 68 insertions(+), 14 deletions(-)
---
diff --git a/src/connection-editor/ce-page-wired.ui b/src/connection-editor/ce-page-wired.ui
index e644d40..29fa3f9 100644
--- a/src/connection-editor/ce-page-wired.ui
+++ b/src/connection-editor/ce-page-wired.ui
@@ -175,12 +175,12 @@
           </packing>
         </child>
         <child>
-          <object class="GtkComboBoxText" id="wired_device_mac">
+          <object class="GtkAlignment" id="wired_device_mac_alignment">
             <property name="visible">True</property>
-            <property name="has_entry">True</property>
-            <property name="entry_text_column">0</property>
-            <property name="can_focus">True</property>
-            <property name="tooltip_text" translatable="yes">This option locks this connection to the network device specified by its permanent MAC address entered here.  Example: 00:11:22:33:44:55</property>
+            <property name="xalign">0</property>
+            <child>
+              <placeholder/>
+            </child>
           </object>
           <packing>
             <property name="left_attach">1</property>
diff --git a/src/connection-editor/ce-page-wireless.ui b/src/connection-editor/ce-page-wireless.ui
index 1d00bd4..e3923e8 100644
--- a/src/connection-editor/ce-page-wireless.ui
+++ b/src/connection-editor/ce-page-wireless.ui
@@ -117,12 +117,12 @@
           </packing>
         </child>
         <child>
-          <object class="GtkComboBoxText" id="wireless_device_mac">
+          <object class="GtkAlignment" id="wireless_device_mac_alignment">
             <property name="visible">True</property>
-            <property name="has_entry">True</property>
-            <property name="entry_text_column">0</property>
-            <property name="can_focus">True</property>
-            <property name="tooltip_text" translatable="yes">This option locks this connection to the network device specified by its permanent MAC address entered here.  Example: 00:11:22:33:44:55</property>
+            <property name="xalign">0</property>
+            <child>
+              <placeholder/>
+            </child>
           </object>
           <packing>
             <property name="left_attach">1</property>
diff --git a/src/connection-editor/page-wired.c b/src/connection-editor/page-wired.c
index ba9345f..bf7e6ad 100644
--- a/src/connection-editor/page-wired.c
+++ b/src/connection-editor/page-wired.c
@@ -41,7 +41,11 @@ G_DEFINE_TYPE (CEPageWired, ce_page_wired, CE_TYPE_PAGE)
 typedef struct {
 	NMSettingWired *setting;
 
+#if GTK_CHECK_VERSION(2,24,0)
 	GtkComboBoxText *device_mac;  /* Permanent MAC of the device */
+#else
+	GtkComboBoxEntry *device_mac;
+#endif
 	GtkEntry *cloned_mac;         /* Cloned MAC - used for MAC spoofing */
 	GtkComboBox *port;
 	GtkComboBox *speed;
@@ -69,10 +73,24 @@ wired_private_init (CEPageWired *self)
 {
 	CEPageWiredPrivate *priv = CE_PAGE_WIRED_GET_PRIVATE (self);
 	GtkBuilder *builder;
+	GtkWidget *align;
 
 	builder = CE_PAGE (self)->builder;
 
-	priv->device_mac = GTK_COMBO_BOX_TEXT (GTK_WIDGET (gtk_builder_get_object (builder, "wired_device_mac")));
+#if GTK_CHECK_VERSION(2,24,0)
+	priv->device_mac = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new_with_entry ());
+	gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (priv->device_mac), 0);
+#else
+	priv->device_mac = GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new_text ());
+	gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (priv->device_mac), 0);
+#endif
+	gtk_widget_set_tooltip_text (GTK_WIDGET (priv->device_mac),
+	                             _("This option locks this connection to the network device specified by its permanent MAC address entered here.  Example: 00:11:22:33:44:55"));
+
+	align = GTK_WIDGET (gtk_builder_get_object (builder, "wired_device_mac_alignment"));
+	gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET (priv->device_mac));
+	gtk_widget_show_all (GTK_WIDGET (priv->device_mac));
+
 	priv->cloned_mac = GTK_ENTRY (GTK_WIDGET (gtk_builder_get_object (builder, "wired_cloned_mac")));
 	priv->port = GTK_COMBO_BOX (GTK_WIDGET (gtk_builder_get_object (builder, "wired_port")));
 	priv->speed = GTK_COMBO_BOX (GTK_WIDGET (gtk_builder_get_object (builder, "wired_speed")));
@@ -157,14 +175,23 @@ populate_ui (CEPageWired *self)
 	                    NULL;
 
 	for (iter = mac_list; iter && *iter; iter++) {
+#if GTK_CHECK_VERSION (2,24,0)
 		gtk_combo_box_text_append_text (priv->device_mac, *iter);
+#else
+		gtk_combo_box_append_text (GTK_COMBO_BOX (priv->device_mac), *iter);
+#endif
 		if (s_mac_str && g_ascii_strncasecmp (*iter, s_mac_str, 17) == 0)
 			active_mac = *iter;
 	}
 
 	if (s_mac_str) {
-		if (!active_mac)
+		if (!active_mac) {
+#if GTK_CHECK_VERSION (2,24,0)
 			gtk_combo_box_text_prepend_text (priv->device_mac, s_mac_str);
+#else
+			gtk_combo_box_prepend_text (GTK_COMBO_BOX (priv->device_mac), s_mac_str);
+#endif
+		}
 
 		entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
 		if (entry)
diff --git a/src/connection-editor/page-wireless.c b/src/connection-editor/page-wireless.c
index 21ac5b1..5861893 100644
--- a/src/connection-editor/page-wireless.c
+++ b/src/connection-editor/page-wireless.c
@@ -44,7 +44,11 @@ typedef struct {
 
 	GtkEntry *ssid;
 	GtkEntry *bssid;
+#if GTK_CHECK_VERSION (2,24,0)
 	GtkComboBoxText *device_mac;  /* Permanent MAC of the device */
+#else
+	GtkComboBoxEntry *device_mac;
+#endif
 	GtkEntry *cloned_mac;         /* Cloned MAC - used for MAC spoofing */
 	GtkComboBox *mode;
 	GtkComboBox *band;
@@ -65,6 +69,7 @@ wireless_private_init (CEPageWireless *self)
 	CEPageWirelessPrivate *priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
 	GtkBuilder *builder;
 	GtkWidget *widget;
+	GtkWidget *align;
 
 	builder = CE_PAGE (self)->builder;
 
@@ -72,12 +77,25 @@ wireless_private_init (CEPageWireless *self)
 
 	priv->ssid     = GTK_ENTRY (GTK_WIDGET (gtk_builder_get_object (builder, "wireless_ssid")));
 	priv->bssid    = GTK_ENTRY (GTK_WIDGET (gtk_builder_get_object (builder, "wireless_bssid")));
-	priv->device_mac = GTK_COMBO_BOX_TEXT (GTK_WIDGET (gtk_builder_get_object (builder, "wireless_device_mac")));
 	priv->cloned_mac = GTK_ENTRY (GTK_WIDGET (gtk_builder_get_object (builder, "wireless_cloned_mac")));
 	priv->mode     = GTK_COMBO_BOX (GTK_WIDGET (gtk_builder_get_object (builder, "wireless_mode")));
 	priv->band     = GTK_COMBO_BOX (GTK_WIDGET (gtk_builder_get_object (builder, "wireless_band")));
 	priv->channel  = GTK_SPIN_BUTTON (GTK_WIDGET (gtk_builder_get_object (builder, "wireless_channel")));
 
+#if GTK_CHECK_VERSION(2,24,0)
+	priv->device_mac = GTK_COMBO_BOX_TEXT (gtk_combo_box_text_new_with_entry ());
+	gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (priv->device_mac), 0);
+#else
+	priv->device_mac = GTK_COMBO_BOX_ENTRY (gtk_combo_box_entry_new_text ());
+	gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (priv->device_mac), 0);
+#endif
+	gtk_widget_set_tooltip_text (GTK_WIDGET (priv->device_mac),
+	                             _("This option locks this connection to the network device specified by its permanent MAC address entered here.  Example: 00:11:22:33:44:55"));
+
+	align = GTK_WIDGET (gtk_builder_get_object (builder, "wireless_device_mac_alignment"));
+	gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET (priv->device_mac));
+	gtk_widget_show_all (GTK_WIDGET (priv->device_mac));
+
 	priv->rate     = GTK_SPIN_BUTTON (GTK_WIDGET (gtk_builder_get_object (builder, "wireless_rate")));
 	widget = GTK_WIDGET (gtk_builder_get_object (builder, "rate_units"));
 	gtk_size_group_add_widget (priv->group, widget);
@@ -357,14 +375,23 @@ populate_ui (CEPageWireless *self)
 	                    NULL;
 
 	for (iter = mac_list; iter && *iter; iter++) {
+#if GTK_CHECK_VERSION (2,24,0)
 		gtk_combo_box_text_append_text (priv->device_mac, *iter);
+#else
+		gtk_combo_box_append_text (GTK_COMBO_BOX (priv->device_mac), *iter);
+#endif
 		if (s_mac_str && g_ascii_strncasecmp (*iter, s_mac_str, 17) == 0)
 			active_mac = *iter;
 	}
 
 	if (s_mac_str) {
-		if (!active_mac)
+		if (!active_mac) {
+#if GTK_CHECK_VERSION (2,24,0)
 			gtk_combo_box_text_prepend_text (priv->device_mac, s_mac_str);
+#else
+			gtk_combo_box_prepend_text (GTK_COMBO_BOX (priv->device_mac), s_mac_str);
+#endif
+		}
 
 		entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
 		if (entry)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]