[Xfce4-commits] [panel-plugins/xfce4-weather-plugin] 05/25: Use accessor functions instead of direct access

noreply at xfce.org noreply at xfce.org
Mon Sep 17 00:14:02 CEST 2018


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-weather-plugin.

commit e51f77e6419be1edbffb5215d7a9a4bce71fb5a7
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Sep 9 14:27:55 2018 -0400

    Use accessor functions instead of direct access
---
 panel-plugin/Makefile.am         |  3 ++-
 panel-plugin/weather-scrollbox.c | 40 ++++++++++++++++++++++++----------------
 panel-plugin/weather-summary.c   | 11 ++++++++---
 3 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 3af5cd1..1a0bdab 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -41,7 +41,8 @@ libweather_la_CFLAGS =						\
 	$(LIBXML_CFLAGS)	\
 	-DGTK_DISABLE_SINGLE_INCLUDES	\
 	-DGDK_DISABLE_DEPRECATED	\
-	-DGTK_DISABLE_DEPRECATED
+	-DGTK_DISABLE_DEPRECATED	\
+	-DGSEAL_ENABLE
 
 libweather_la_LIBADD =						\
 	$(LIBM)                                 \
diff --git a/panel-plugin/weather-scrollbox.c b/panel-plugin/weather-scrollbox.c
index 9883815..48f94e0 100644
--- a/panel-plugin/weather-scrollbox.c
+++ b/panel-plugin/weather-scrollbox.c
@@ -180,6 +180,7 @@ gtk_scrollbox_expose_event(GtkWidget *widget,
     PangoRectangle logical_rect;
     gboolean result = FALSE;
     PangoMatrix matrix = PANGO_MATRIX_INIT;
+    GtkAllocation allocation;
 
     if (GTK_WIDGET_CLASS(gtk_scrollbox_parent_class)->expose_event != NULL)
         result = GTK_WIDGET_CLASS
@@ -193,28 +194,30 @@ gtk_scrollbox_expose_event(GtkWidget *widget,
         pango_context_set_matrix(pango_layout_get_context(layout), &matrix);
         pango_layout_get_extents(layout, NULL, &logical_rect);
 
+        gtk_widget_get_allocation (GTK_WIDGET (widget), &allocation);
+
         if (self->orientation == GTK_ORIENTATION_HORIZONTAL) {
-            width = widget->allocation.x
-                + (widget->allocation.width
+            width = allocation.x
+                + (allocation.width
                    - PANGO_PIXELS(logical_rect.width)) / 2;
-            height = widget->allocation.y
-                + (widget->allocation.height
+            height = allocation.y
+                + (allocation.height
                    - PANGO_PIXELS(logical_rect.height)) / 2
                 + (self->fade == FADE_IN || self->fade == FADE_OUT
                    ? self->offset : 0);
         } else {
-            width = widget->allocation.x
-                + (widget->allocation.width
+            width = allocation.x
+                + (allocation.width
                    - PANGO_PIXELS(logical_rect.height)) / 2
                 + (self->fade == FADE_IN || self->fade == FADE_OUT
                    ? self->offset : 0);
-            height = widget->allocation.y
-                + (widget->allocation.height
+            height = allocation.y
+                + (allocation.height
                    - PANGO_PIXELS(logical_rect.width)) / 2;
         }
 
-        gtk_paint_layout(widget->style,
-                         widget->window,
+        gtk_paint_layout(gtk_widget_get_style (GTK_WIDGET (widget)),
+                         gtk_widget_get_window (GTK_WIDGET (widget)),
                          gtk_widget_get_state(widget), TRUE,
                          &event->area, widget,
                          "GtkScrollbox", width, height, layout);
@@ -304,6 +307,7 @@ static gboolean
 gtk_scrollbox_fade_out(gpointer user_data)
 {
     GtkScrollbox *self = GTK_SCROLLBOX(user_data);
+    GtkAllocation allocation;
 
     /* increase counter */
     if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -312,11 +316,12 @@ gtk_scrollbox_fade_out(gpointer user_data)
         self->offset--;
 
     gtk_widget_queue_draw(GTK_WIDGET(self));
+    gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
 
     if ((self->orientation == GTK_ORIENTATION_HORIZONTAL &&
-         self->offset < GTK_WIDGET(self)->allocation.height) ||
+         self->offset < allocation.height) ||
         (self->orientation == GTK_ORIENTATION_VERTICAL &&
-         self->offset > 0 - GTK_WIDGET(self)->allocation.width))
+         self->offset > 0 - allocation.width))
         return TRUE;
 
     (void) gtk_scrollbox_control_loop(self);
@@ -332,6 +337,7 @@ static gboolean
 gtk_scrollbox_control_loop(gpointer user_data)
 {
     GtkScrollbox *self = GTK_SCROLLBOX(user_data);
+    GtkAllocation allocation;
 
     if (self->timeout_id != 0) {
         g_source_remove(self->timeout_id);
@@ -366,14 +372,16 @@ gtk_scrollbox_control_loop(gpointer user_data)
         break;
     }
 
+    gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
+
     /* now perform the next action */
     switch(self->fade) {
     case FADE_IN:
         if (self->labels_len > 1) {
             if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
-                self->offset = GTK_WIDGET(self)->allocation.height;
+                self->offset = allocation.height;
             else
-                self->offset = 0 - GTK_WIDGET(self)->allocation.width;
+                self->offset = 0 - allocation.width;
         } else
             self->offset = 0;
         self->timeout_id = g_timeout_add(LABEL_SPEED,
@@ -393,9 +401,9 @@ gtk_scrollbox_control_loop(gpointer user_data)
         break;
     case FADE_NONE:
         if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
-            self->offset = GTK_WIDGET(self)->allocation.height;
+            self->offset = allocation.height;
         else
-            self->offset = GTK_WIDGET(self)->allocation.width;
+            self->offset = allocation.width;
         self->timeout_id = g_timeout_add_seconds(LABEL_SLEEP_LONG,
                                                  gtk_scrollbox_control_loop,
                                                  self);
diff --git a/panel-plugin/weather-summary.c b/panel-plugin/weather-summary.c
index 14d220c..fe3a821 100644
--- a/panel-plugin/weather-summary.c
+++ b/panel-plugin/weather-summary.c
@@ -215,6 +215,8 @@ view_scrolled_cb(GtkAdjustment *adj,
                  summary_details *sum)
 {
     gint x, y, x1, y1;
+    GtkAllocation allocation;
+    GtkRequisition requisition;
 
     if (sum->icon_ebox) {
         /* TRANSLATORS: DO NOT TRANSLATE THIS STRING. This string is
@@ -229,11 +231,14 @@ view_scrolled_cb(GtkAdjustment *adj,
            If you know of a better way to determine LTR/RTL that makes
            this tweak unnecessary, please tell the developer.
         */
+        gtk_widget_get_allocation (GTK_WIDGET (sum->text_view), &allocation);
+        gtk_widget_get_requisition (GTK_WIDGET (sum->text_view), &requisition);
+
         if (!strcmp(_("LTR"), "RTL"))
             x1 = -30;
         else
-            x1 = sum->text_view->allocation.width - 191 - 15;
-        y1 = sum->text_view->requisition.height - 60 - 15;
+            x1 = allocation.width - 191 - 15;
+        y1 = requisition.height - 60 - 15;
         gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(sum->text_view),
                                               GTK_TEXT_WINDOW_TEXT,
                                               x1, y1, &x, &y);
@@ -1154,7 +1159,7 @@ create_summary_window(plugin_data *data)
         g_free(title);
     }
     vbox = gtk_vbox_new(FALSE, 0);
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), vbox, TRUE, TRUE, 0);
+    gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area (GTK_DIALOG(window))), vbox, TRUE, TRUE, 0);
 
     symbol = get_data(conditions, data->units, SYMBOL,
                       FALSE, data->night_time);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list