From a55917cad258da5688d23db6fedfc2e24afdc819 Mon Sep 17 00:00:00 2001 From: Mirsal Ennaime Date: Mon, 02 Aug 2010 22:28:06 +0000 Subject: applet: fix compilation with -DGSEAL_ENABLE (bgo #615653) This patch substitutes all direct access to Gtk+ object fields with accessor functions in order to fulfill the UseGseal goal as described at http://live.gnome.org/GnomeGoals/UseGseal (GTK 2.14+ compat fixes by dcbw) --- diff --git a/src/applet.c b/src/applet.c index 2734045..6cb4e8c 100644 --- a/src/applet.c +++ b/src/applet.c @@ -482,6 +482,7 @@ applet_new_menu_item_helper (NMConnection *connection, static gboolean menu_title_item_expose (GtkWidget *widget, GdkEventExpose *event) { + GtkAllocation allocation; GtkStyle *style; GtkWidget *label; PangoFontDescription *desc; @@ -509,6 +510,11 @@ menu_title_item_expose (GtkWidget *widget, GdkEventExpose *event) /* We also need to reposition the cairo context so that (0, 0) is the * top-left of where we're supposed to start drawing. */ +#if GTK_CHECK_VERSION(2,18,0) + gtk_widget_get_allocation (widget, &allocation); +#else + allocation = widget->allocation; +#endif cairo_translate (cr, widget->allocation.x, widget->allocation.y); text = gtk_label_get_text (GTK_LABEL (label)); diff --git a/src/utils/nma-bling-spinner.c b/src/utils/nma-bling-spinner.c index 5522046..0587727 100644 --- a/src/utils/nma-bling-spinner.c +++ b/src/utils/nma-bling-spinner.c @@ -67,30 +67,30 @@ static GtkDrawingAreaClass *parent_class; static void draw (GtkWidget *widget, cairo_t *cr) { + NmaBlingSpinnerPrivate *priv; + GtkAllocation allocation; double x, y; double radius; double half; int i; - int width, height; - - NmaBlingSpinnerPrivate *priv; priv = NMA_BLING_SPINNER_GET_PRIVATE (widget); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); - width = widget->allocation.width; - height = widget->allocation.height; - - if ( (width < 12) || (height <12) ) +#if GTK_CHECK_VERSION(2,18,0) + gtk_widget_get_allocation (widget, &allocation); +#else + allocation = widget->allocation; +#endif + if ((allocation.width < 12) || (allocation.height < 12)) gtk_widget_set_size_request(widget, 12, 12); - //x = widget->allocation.x + widget->allocation.width / 2; - //y = widget->allocation.y + widget->allocation.height / 2; - x = widget->allocation.width / 2; - y = widget->allocation.height / 2; - radius = MIN (widget->allocation.width / 2, - widget->allocation.height / 2); + //x = allocation.x + allocation.width / 2; + //y = allocation.y + allocation.height / 2; + x = allocation.width / 2; + y = allocation.height / 2; + radius = MIN (allocation.width / 2, allocation.height / 2); half = priv->lines / 2; /*FIXME: render in B&W for non transparency */ @@ -154,7 +154,11 @@ nma_bling_spinner_init (NmaBlingSpinner *spinner) priv->current = 0; priv->timeout = 0; +#if GTK_CHECK_VERSION(2,18,0) + gtk_widget_set_has_window (GTK_WIDGET (spinner), FALSE); +#else GTK_WIDGET_SET_FLAGS (GTK_WIDGET (spinner), GTK_NO_WINDOW); +#endif } static gboolean -- cgit v0.8.3.1 From 7143a4c40d05c857e2c8e817e0e2f768936bf66c Mon Sep 17 00:00:00 2001 From: Vincent Untz Date: Mon, 09 Aug 2010 15:34:11 +0000 Subject: build: fix compilation with glib >= 2.25.12 (bgo #626424) Work around API breakage in glib. --- diff --git a/src/utils/tests/test-utils.c b/src/utils/tests/test-utils.c index 7eb1ffa..83b8ffe 100644 --- a/src/utils/tests/test-utils.c +++ b/src/utils/tests/test-utils.c @@ -413,7 +413,11 @@ test_ap_hash_foobar_asdf11_adhoc_wpa_rsn (void *f, TestData *d) g_assert (strcmp (d->foobar_adhoc_wpa_rsn, d->asdf11_adhoc_wpa_rsn)); } +#if GLIB_CHECK_VERSION(2,25,12) +typedef GTestFixtureFunc TCFunc; +#else typedef void (*TCFunc)(void); +#endif #define TESTCASE(t, d) g_test_create_case (#t, 0, d, NULL, (TCFunc) t, NULL) -- cgit v0.8.3.1 From f7d629b6bd1ddcddcc449db83a999e3e65084fd2 Mon Sep 17 00:00:00 2001 From: Mirsal Ennaime Date: Mon, 02 Aug 2010 22:01:53 +0000 Subject: applet: use GSEAL compatible code for GTK 2.14+ functions This makes the applet GSEAL compatible except for those functions that do not exist in GTK 2.14. Patch for full GSeal compatibility will come soon. --- diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c index 27cfb67..eaa2267 100644 --- a/src/applet-device-gsm.c +++ b/src/applet-device-gsm.c @@ -700,8 +700,8 @@ ask_for_pin_puk (NMDevice *device, GtkEntry **out_secret_entry) { GtkDialog *dialog; - GtkWidget *w = NULL, *ok_button; - GtkBox *box; + GtkWidget *w = NULL, *ok_button = NULL; + GtkBox *box = NULL, *vbox = NULL; char *dev_str; dialog = GTK_DIALOG (gtk_dialog_new ()); @@ -718,21 +718,23 @@ ask_for_pin_puk (NMDevice *device, ok_button = gtk_dialog_add_button (dialog, GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_window_set_default (GTK_WINDOW (dialog), ok_button); + vbox = GTK_BOX (gtk_dialog_get_content_area (dialog)); + if (!strcmp (secret_name, NM_SETTING_GSM_PIN)) w = gtk_label_new (_("PIN code is needed for the mobile broadband device")); else if (!strcmp (secret_name, NM_SETTING_GSM_PUK)) w = gtk_label_new (_("PUK code is needed for the mobile broadband device")); if (w) - gtk_box_pack_start (GTK_BOX (dialog->vbox), w, TRUE, TRUE, 0); + gtk_box_pack_start (vbox, w, TRUE, TRUE, 0); dev_str = g_strdup_printf ("%s", utils_get_device_description (device)); w = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (w), dev_str); g_free (dev_str); - gtk_box_pack_start (GTK_BOX (dialog->vbox), w, TRUE, TRUE, 0); + gtk_box_pack_start (vbox, w, TRUE, TRUE, 0); w = gtk_alignment_new (0.5, 0.5, 0, 1.0); - gtk_box_pack_start (GTK_BOX (dialog->vbox), w, TRUE, TRUE, 0); + gtk_box_pack_start (vbox, w, TRUE, TRUE, 0); box = GTK_BOX (gtk_hbox_new (FALSE, 6)); gtk_container_set_border_width (GTK_CONTAINER (box), 6); @@ -749,7 +751,7 @@ ask_for_pin_puk (NMDevice *device, g_signal_connect (w, "changed", G_CALLBACK (pin_entry_changed), ok_button); pin_entry_changed (GTK_EDITABLE (w), ok_button); - gtk_widget_show_all (dialog->vbox); + gtk_widget_show_all (GTK_WIDGET (vbox)); return GTK_WIDGET (dialog); } diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c index cebdf80..0821e7f 100644 --- a/src/applet-device-wifi.c +++ b/src/applet-device-wifi.c @@ -57,7 +57,8 @@ show_ignore_focus_stealing_prevention (GtkWidget *widget) { gtk_widget_realize (widget); gtk_widget_show (widget); - gtk_window_present_with_time (GTK_WINDOW (widget), gdk_x11_get_server_time (widget->window)); + gtk_window_present_with_time (GTK_WINDOW (widget), + gdk_x11_get_server_time (gtk_widget_get_window (widget))); } static void diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c index 7f10e57..b1649cd 100644 --- a/src/applet-device-wired.c +++ b/src/applet-device-wired.c @@ -569,7 +569,7 @@ pppoe_get_secrets (NMDevice *device, w = gtk_dialog_add_button (GTK_DIALOG (info->dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); info->ok_button = w; - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (info->dialog)->vbox), + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (info->dialog))), glade_xml_get_widget (xml, "DslPage"), TRUE, TRUE, 0); diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c index 7681e48..ae6ae69 100644 --- a/src/applet-dialogs.c +++ b/src/applet-dialogs.c @@ -564,7 +564,8 @@ applet_info_dialog_show (NMApplet *applet) g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), dialog); g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_hide), dialog); gtk_widget_realize (dialog); - gtk_window_present_with_time (GTK_WINDOW (dialog), gdk_x11_get_server_time (dialog->window)); + gtk_window_present_with_time (GTK_WINDOW (dialog), + gdk_x11_get_server_time (gtk_widget_get_window (dialog))); } static void @@ -697,7 +698,8 @@ applet_warning_dialog_show (const char *message) gtk_window_set_title (GTK_WINDOW (dialog), _("Missing resources")); gtk_widget_realize (dialog); gtk_widget_show (dialog); - gtk_window_present_with_time (GTK_WINDOW (dialog), gdk_x11_get_server_time (dialog->window)); + gtk_window_present_with_time (GTK_WINDOW (dialog), + gdk_x11_get_server_time (gtk_widget_get_window (dialog))); g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), @@ -712,7 +714,7 @@ applet_mobile_password_dialog_new (NMDevice *device, { GtkDialog *dialog; GtkWidget *w; - GtkBox *box; + GtkBox *box = NULL, *vbox = NULL; char *dev_str; NMSettingConnection *s_con; char *tmp; @@ -732,16 +734,19 @@ applet_mobile_password_dialog_new (NMDevice *device, tmp = g_strdup_printf (_("A password is required to connect to '%s'."), id); w = gtk_label_new (tmp); g_free (tmp); - gtk_box_pack_start (GTK_BOX (dialog->vbox), w, TRUE, TRUE, 0); + + vbox = GTK_BOX (gtk_dialog_get_content_area (dialog)); + + gtk_box_pack_start (vbox, w, TRUE, TRUE, 0); dev_str = g_strdup_printf ("%s", utils_get_device_description (device)); w = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (w), dev_str); g_free (dev_str); - gtk_box_pack_start (GTK_BOX (dialog->vbox), w, TRUE, TRUE, 0); + gtk_box_pack_start (vbox, w, TRUE, TRUE, 0); w = gtk_alignment_new (0.5, 0.5, 0, 1.0); - gtk_box_pack_start (GTK_BOX (dialog->vbox), w, TRUE, TRUE, 0); + gtk_box_pack_start (vbox, w, TRUE, TRUE, 0); box = GTK_BOX (gtk_hbox_new (FALSE, 6)); gtk_container_set_border_width (GTK_CONTAINER (box), 6); @@ -754,7 +759,7 @@ applet_mobile_password_dialog_new (NMDevice *device, gtk_entry_set_activates_default (GTK_ENTRY (w), TRUE); gtk_box_pack_start (box, w, FALSE, FALSE, 0); - gtk_widget_show_all (dialog->vbox); + gtk_widget_show_all (GTK_WIDGET (vbox)); return GTK_WIDGET (dialog); } @@ -914,7 +919,8 @@ applet_mobile_pin_dialog_present (GtkWidget *dialog, gboolean now) /* Show the dialog */ gtk_widget_realize (dialog); if (now) - gtk_window_present_with_time (GTK_WINDOW (dialog), gdk_x11_get_server_time (dialog->window)); + gtk_window_present_with_time (GTK_WINDOW (dialog), + gdk_x11_get_server_time (gtk_widget_get_window (dialog))); else gtk_window_present (GTK_WINDOW (dialog)); } diff --git a/src/applet.c b/src/applet.c index fb4936c..2734045 100644 --- a/src/applet.c +++ b/src/applet.c @@ -496,7 +496,7 @@ menu_title_item_expose (GtkWidget *widget, GdkEventExpose *event) label = gtk_bin_get_child (GTK_BIN (widget)); - cr = gdk_cairo_create (widget->window); + cr = gdk_cairo_create (gtk_widget_get_window (widget)); /* The drawing area we get is the whole menu; clip the drawing to the * event area, which should just be our menu item. @@ -2922,9 +2922,12 @@ applet_pre_keyring_callback (gpointer user_data) NMApplet *applet = NM_APPLET (user_data); GdkScreen *screen; GdkDisplay *display; + GdkWindow *window = NULL; - if (applet->menu && applet->menu->window) { - screen = gdk_drawable_get_screen (applet->menu->window); + if (applet->menu) + window = gtk_widget_get_window (applet->menu); + if (window) { + screen = gdk_drawable_get_screen (window); display = gdk_screen_get_display (screen); g_object_ref (display); @@ -2941,8 +2944,11 @@ applet_pre_keyring_callback (gpointer user_data) g_object_unref (display); } - if (applet->context_menu && applet->context_menu->window) { - screen = gdk_drawable_get_screen (applet->context_menu->window); + window = NULL; + if (applet->context_menu) + window = gtk_widget_get_window (applet->context_menu); + if (window) { + screen = gdk_drawable_get_screen (window); display = gdk_screen_get_display (screen); g_object_ref (display); diff --git a/src/wireless-dialog.c b/src/wireless-dialog.c index 8a4bc03..d312744 100644 --- a/src/wireless-dialog.c +++ b/src/wireless-dialog.c @@ -1084,7 +1084,7 @@ internal_init (NMAWirelessDialog *self, gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 2); widget = gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - gtk_box_set_child_packing (GTK_BOX (GTK_DIALOG (self)->action_area), widget, + gtk_box_set_child_packing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (self))), widget, FALSE, TRUE, 0, GTK_PACK_END); /* Connect/Create button */ @@ -1100,7 +1100,7 @@ internal_init (NMAWirelessDialog *self, } else widget = gtk_dialog_add_button (GTK_DIALOG (self), GTK_STOCK_CONNECT, GTK_RESPONSE_OK); - gtk_box_set_child_packing (GTK_BOX (GTK_DIALOG (self)->action_area), widget, + gtk_box_set_child_packing (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (self))), widget, FALSE, TRUE, 0, GTK_PACK_END); g_object_set (G_OBJECT (widget), "can-default", TRUE, NULL); gtk_widget_grab_default (widget); -- cgit v0.8.3.1 From c3644402e9e3ade371bada2547e248cd2601e6a6 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 01 Oct 2010 10:09:28 +0000 Subject: Drop deprecated gtk_dialog_set_has_separator() https://bugzilla.gnome.org/show_bug.cgi?id=631083 --- diff --git a/src/wireless-dialog.c b/src/wireless-dialog.c index 98b684c..621526f 100644 --- a/src/wireless-dialog.c +++ b/src/wireless-dialog.c @@ -1069,7 +1069,6 @@ internal_init (NMAWirelessDialog *self, gtk_container_set_border_width (GTK_CONTAINER (self), 6); gtk_window_set_default_size (GTK_WINDOW (self), 488, -1); gtk_window_set_resizable (GTK_WINDOW (self), FALSE); - gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE); priv->auth_only = auth_only; if (auth_only) -- cgit v0.8.3.1