[gnome-panel/wip/in-process-only: 2/3] libpanel-applet: remove background related things



commit 5674678496ee709a5354437764ce3bdb25ebad6d
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Jul 26 21:53:29 2016 +0300

    libpanel-applet: remove background related things

 applets/notification_area/main.c     |   13 --
 applets/notification_area/na-tray.c  |   31 ----
 applets/notification_area/na-tray.h  |    1 -
 applets/wncklet/window-list.c        |    6 +-
 applets/wncklet/workspace-switcher.c |    6 +-
 libpanel-applet/panel-applet.c       |  273 ----------------------------------
 libpanel-applet/panel-applet.h       |    8 -
 libpanel-applet/test-dbus-applet.c   |   15 --
 8 files changed, 4 insertions(+), 349 deletions(-)
---
diff --git a/applets/notification_area/main.c b/applets/notification_area/main.c
index 1d9a683..f807846 100644
--- a/applets/notification_area/main.c
+++ b/applets/notification_area/main.c
@@ -137,18 +137,6 @@ na_tray_applet_style_updated (GtkWidget *widget)
 }
 
 static void
-na_tray_applet_change_background (PanelApplet     *panel_applet,
-                                  cairo_pattern_t *pattern)
-{
-  NaTrayApplet *applet = NA_TRAY_APPLET (panel_applet);
-
-  if (!applet->priv->tray)
-    return;
-
-  na_tray_force_redraw (applet->priv->tray);
-}
-
-static void
 na_tray_applet_change_orient (PanelApplet       *panel_applet,
                               PanelAppletOrient  orient)
 {
@@ -170,7 +158,6 @@ na_tray_applet_class_init (NaTrayAppletClass *class)
   widget_class->realize = na_tray_applet_realize;
   widget_class->unrealize = na_tray_applet_unrealize;
   widget_class->style_updated = na_tray_applet_style_updated;
-  applet_class->change_background = na_tray_applet_change_background;
   applet_class->change_orient = na_tray_applet_change_orient;
 
   gtk_widget_class_install_style_property (
diff --git a/applets/notification_area/na-tray.c b/applets/notification_area/na-tray.c
index 96e8f8a..6fbee6b 100644
--- a/applets/notification_area/na-tray.c
+++ b/applets/notification_area/na-tray.c
@@ -47,8 +47,6 @@ struct _NaTrayPrivate
 
   GtkWidget *box;
 
-  guint idle_redraw_id;
-
   GtkOrientation orientation;
 };
 
@@ -668,12 +666,6 @@ na_tray_dispose (GObject *object)
 
   priv->trays_screen = NULL;
 
-  if (priv->idle_redraw_id != 0)
-    {
-      g_source_remove (priv->idle_redraw_id);
-      priv->idle_redraw_id = 0;
-    }
-
   G_OBJECT_CLASS (na_tray_parent_class)->dispose (object);
 }
 
@@ -797,18 +789,6 @@ na_tray_get_orientation (NaTray *tray)
   return tray->priv->orientation;
 }
 
-static gboolean
-idle_redraw_cb (NaTray *tray)
-{
-  NaTrayPrivate *priv = tray->priv;
-
-  gtk_container_foreach (GTK_CONTAINER (priv->box), (GtkCallback)na_tray_child_force_redraw, tray);
-  
-  priv->idle_redraw_id = 0;
-
-  return FALSE;
-}
-
 void
 na_tray_set_padding (NaTray *tray,
                      gint    padding)
@@ -841,14 +821,3 @@ na_tray_set_colors (NaTray   *tray,
   if (get_tray (priv->trays_screen) == tray)
     na_tray_manager_set_colors (priv->trays_screen->tray_manager, fg, error, warning, success);
 }
-
-void
-na_tray_force_redraw (NaTray *tray)
-{
-  NaTrayPrivate *priv = tray->priv;
-
-  /* Force the icons to redraw their backgrounds.
-   */
-  if (priv->idle_redraw_id == 0)
-    priv->idle_redraw_id = g_idle_add ((GSourceFunc) idle_redraw_cb, tray);
-}
diff --git a/applets/notification_area/na-tray.h b/applets/notification_area/na-tray.h
index f06bfc6..c7bc443 100644
--- a/applets/notification_area/na-tray.h
+++ b/applets/notification_area/na-tray.h
@@ -67,7 +67,6 @@ void            na_tray_set_colors      (NaTray        *tray,
                                         GdkRGBA       *error,
                                         GdkRGBA       *warning,
                                         GdkRGBA       *success);
-void           na_tray_force_redraw    (NaTray        *tray);
 
 G_END_DECLS
 
diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c
index c4cb990..e52884f 100644
--- a/applets/wncklet/window-list.c
+++ b/applets/wncklet/window-list.c
@@ -119,6 +119,7 @@ applet_change_orient (PanelApplet       *applet,
        tasklist_update (tasklist);
 }
 
+#if 0
 static void
 applet_change_background (PanelApplet     *applet,
                          cairo_pattern_t *pattern,
@@ -128,6 +129,7 @@ applet_change_background (PanelApplet     *applet,
                                          pattern != NULL ? GTK_RELIEF_NONE
                                                          : GTK_RELIEF_NORMAL);
 }
+#endif
 
 static void
 destroy_tasklist(GtkWidget * widget, TasklistData *tasklist)
@@ -409,10 +411,6 @@ window_list_applet_fill (PanelApplet *applet)
                          "change_orient",
                          G_CALLBACK (applet_change_orient),
                          tasklist);
-       g_signal_connect (G_OBJECT (tasklist->applet),
-                         "change_background",
-                         G_CALLBACK (applet_change_background),
-                         tasklist);
 
        action_group = g_simple_action_group_new ();
        g_action_map_add_action_entries (G_ACTION_MAP (action_group),
diff --git a/applets/wncklet/workspace-switcher.c b/applets/wncklet/workspace-switcher.c
index 51d7cec..6783885 100644
--- a/applets/wncklet/workspace-switcher.c
+++ b/applets/wncklet/workspace-switcher.c
@@ -198,6 +198,7 @@ applet_change_orient (PanelApplet       *applet,
                gtk_label_set_text (GTK_LABEL (pager->label_row_col), pager->orientation == 
GTK_ORIENTATION_HORIZONTAL ? _("rows") : _("columns"));     
 }
 
+#if 0
 static void
 applet_change_background (PanelApplet               *applet,
                           cairo_pattern_t           *pattern,
@@ -206,6 +207,7 @@ applet_change_background (PanelApplet               *applet,
         wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager),
                                     pattern != NULL ? GTK_SHADOW_NONE : GTK_SHADOW_IN);
 }
+#endif
 
 static void
 destroy_pager(GtkWidget * widget, PagerData *pager)
@@ -367,10 +369,6 @@ workspace_switcher_applet_fill (PanelApplet *applet)
                          "change_orient",
                          G_CALLBACK (applet_change_orient),
                          pager);
-       g_signal_connect (G_OBJECT (pager->applet),
-                         "change_background",
-                         G_CALLBACK (applet_change_background),
-                         pager);
 
        gtk_widget_show (pager->applet);
 
diff --git a/libpanel-applet/panel-applet.c b/libpanel-applet/panel-applet.c
index 9de4062..005e08a 100644
--- a/libpanel-applet/panel-applet.c
+++ b/libpanel-applet/panel-applet.c
@@ -94,10 +94,6 @@ struct _PanelAppletPrivate {
 
        PanelAppletFlags   flags;
        PanelAppletOrient  orient;
-       char              *background;
-
-       int                previous_width;
-       int                previous_height;
 
         int               *size_hints;
         int                size_hints_len;
@@ -109,7 +105,6 @@ struct _PanelAppletPrivate {
 
 enum {
         CHANGE_ORIENT,
-        CHANGE_BACKGROUND,
        MOVE_FOCUS_OUT_OF_APPLET,
         LAST_SIGNAL
 };
@@ -124,13 +119,11 @@ enum {
        PROP_CONNECTION,
        PROP_SETTINGS_PATH,
        PROP_ORIENT,
-       PROP_BACKGROUND,
        PROP_FLAGS,
        PROP_SIZE_HINTS,
        PROP_LOCKED_DOWN
 };
 
-static void       panel_applet_handle_background   (PanelApplet       *applet);
 static GAction   *panel_applet_menu_get_action     (PanelApplet       *applet,
                                                    const gchar       *action);
 static void       panel_applet_menu_update_actions (PanelApplet       *applet);
@@ -871,7 +864,6 @@ panel_applet_finalize (GObject *object)
 
        g_free (applet->priv->size_hints);
        g_free (applet->priv->settings_path);
-       g_free (applet->priv->background);
        g_free (applet->priv->id);
 
        /* closure is owned by the factory */
@@ -1216,7 +1208,6 @@ panel_applet_size_allocate (GtkWidget     *widget,
        GtkBin        *bin;
        GtkWidget     *child;
        int            border_width;
-       PanelApplet   *applet;
 
        if (!panel_applet_can_focus (widget)) {
                GTK_WIDGET_CLASS (panel_applet_parent_class)->size_allocate (widget, allocation);
@@ -1243,16 +1234,6 @@ panel_applet_size_allocate (GtkWidget     *widget,
                if (child)
                        gtk_widget_size_allocate (child, &child_allocation);
        }
-
-       applet = PANEL_APPLET (widget);
-
-       if (applet->priv->previous_height != allocation->height ||
-           applet->priv->previous_width  != allocation->width) {
-               applet->priv->previous_height = allocation->height;
-               applet->priv->previous_width = allocation->width;
-
-               panel_applet_handle_background (applet);
-       }
 }
 
 static gboolean
@@ -1338,204 +1319,6 @@ panel_applet_focus (GtkWidget        *widget,
        return ret;
 }
 
-static cairo_surface_t *
-panel_applet_create_foreign_surface_for_display (GdkDisplay *display,
-                                                 GdkVisual  *visual,
-                                                 Window      xid)
-{
-        Window window;
-        gint x, y;
-        guint width, height, border, depth;
-
-        if (!XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xid, &window,
-                           &x, &y, &width, &height, &border, &depth))
-                return NULL;
-
-        return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display),
-                                          xid, gdk_x11_visual_get_xvisual (visual),
-                                          width, height);
-}
-
-static cairo_pattern_t *
-panel_applet_get_pattern_from_pixmap (PanelApplet *applet,
-                                      Window       xid,
-                                      int          x,
-                                      int          y)
-{
-       GdkWindow       *window;
-       int              width;
-       int              height;
-        cairo_t         *cr;
-        cairo_surface_t *background;
-        cairo_surface_t *surface;
-        cairo_pattern_t *pattern;
-
-       g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
-
-       if (!gtk_widget_get_realized (GTK_WIDGET (applet)))
-               return NULL;
-
-        window = gtk_widget_get_window (GTK_WIDGET (applet));
-
-        gdk_error_trap_push ();
-        background = panel_applet_create_foreign_surface_for_display (gdk_window_get_display (window),
-                                                                      gdk_window_get_visual (window),
-                                                                      xid);
-        gdk_error_trap_pop_ignored ();
-
-        /* background can be NULL if the user changes the background very fast.
-         * We'll get the next update, so it's not a big deal. */
-        if (!background ||
-            cairo_surface_status (background) != CAIRO_STATUS_SUCCESS) {
-                if (background)
-                        cairo_surface_destroy (background);
-                return NULL;
-        }
-
-        width = gdk_window_get_width (window);
-        height = gdk_window_get_height (window);
-        surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
-
-        gdk_error_trap_push ();
-        cr = cairo_create (surface);
-        cairo_set_source_surface (cr, background, -x, -y);
-        cairo_rectangle (cr, 0, 0, width, height);
-        cairo_fill (cr);
-        gdk_error_trap_pop_ignored ();
-
-        cairo_surface_destroy (background);
-
-       pattern = NULL;
-
-       if (cairo_status (cr) == CAIRO_STATUS_SUCCESS)
-               pattern = cairo_pattern_create_for_surface (surface);
-
-        cairo_destroy (cr);
-        cairo_surface_destroy (surface);
-
-       return pattern;
-}
-
-/**
- * panel_applet_get_background:
- * @applet: a #PanelApplet.
- *
- * Gets the background pattern for @applet, or %NULL if there is none.
- *
- * Returns: (transfer full): a new #cairo_pattern_t to use as background for
- * @applet.
- **/
-cairo_pattern_t *
-panel_applet_get_background (PanelApplet *applet)
-{
-        cairo_pattern_t *pattern = NULL;
-        GVariant        *variant;
-        GVariantIter     iter;
-        GError          *error = NULL;
-
-        g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
-
-       if (!gtk_widget_get_realized (GTK_WIDGET (applet)) || !applet->priv->background)
-               return NULL;
-
-        variant = g_variant_parse (NULL, applet->priv->background,
-                                   NULL, NULL, &error);
-        if (!variant) {
-                g_warning ("Error parsing background %s: %s\n", applet->priv->background, error->message);
-                g_error_free (error);
-                return NULL;
-        }
-
-        g_variant_iter_init (&iter, variant);
-        switch (g_variant_iter_n_children (&iter)) {
-        case 4: {
-                gdouble red, green, blue, alpha;
-
-                g_variant_get (variant, "(dddd)", &red, &green, &blue, &alpha);
-                pattern = cairo_pattern_create_rgba (red, green, blue, alpha);
-        }
-                break;
-        case 3: {
-                guint32 xid;
-                int x, y;
-
-                g_variant_get (variant, "(uii)", &xid, &x, &y);
-                pattern = panel_applet_get_pattern_from_pixmap (applet, xid, x, y);
-        }
-                break;
-        default:
-                break;
-        }
-
-        g_variant_unref (variant);
-
-        return pattern;
-}
-
-static void
-panel_applet_set_background_string (PanelApplet *applet,
-                                   const gchar *background)
-{
-       if (applet->priv->background == background)
-               return;
-
-       if (g_strcmp0 (applet->priv->background, background) == 0)
-               return;
-
-       if (applet->priv->background)
-               g_free (applet->priv->background);
-       applet->priv->background = background ? g_strdup (background) : NULL;
-       panel_applet_handle_background (applet);
-
-       g_object_notify (G_OBJECT (applet), "background");
-}
-
-static void
-panel_applet_style_updated (GtkWidget *widget)
-{
-  PanelApplet *applet;
-
-  applet = PANEL_APPLET (widget);
-
-  GTK_WIDGET_CLASS (panel_applet_parent_class)->style_updated (widget);
-
-  panel_applet_handle_background (applet);
-}
-
-static void
-panel_applet_handle_background (PanelApplet *applet)
-{
-       GdkWindow *window;
-       cairo_pattern_t *pattern;
-
-       if (applet->priv->plug == NULL)
-               return;
-
-       window = gtk_widget_get_window (applet->priv->plug);
-
-       if (window == NULL)
-         return;
-
-       pattern = panel_applet_get_background (applet);
-
-       gdk_window_set_background_pattern (window, pattern);
-       gtk_widget_queue_draw (applet->priv->plug);
-
-       g_signal_emit (applet, panel_applet_signals [CHANGE_BACKGROUND], 0, pattern);
-
-       if (pattern)
-               cairo_pattern_destroy (pattern);
-}
-
-static void
-panel_applet_realize (GtkWidget *widget)
-{
-       GTK_WIDGET_CLASS (panel_applet_parent_class)->realize (widget);
-
-       if (PANEL_APPLET (widget)->priv->background)
-               panel_applet_handle_background (PANEL_APPLET (widget));
-}
-
 static void
 panel_applet_move_focus_out_of_applet (PanelApplet      *applet,
                                       GtkDirectionType  dir)
@@ -1577,9 +1360,6 @@ panel_applet_get_property (GObject    *object,
        case PROP_ORIENT:
                g_value_set_uint (value, applet->priv->orient);
                break;
-       case PROP_BACKGROUND:
-               g_value_set_string (value, applet->priv->background);
-               break;
        case PROP_FLAGS:
                g_value_set_uint (value, applet->priv->flags);
                break;
@@ -1638,9 +1418,6 @@ panel_applet_set_property (GObject      *object,
        case PROP_ORIENT:
                panel_applet_set_orient (applet, g_value_get_uint (value));
                break;
-       case PROP_BACKGROUND:
-               panel_applet_set_background_string (applet, g_value_get_string (value));
-               break;
        case PROP_FLAGS:
                panel_applet_set_flags (applet, g_value_get_uint (value));
                break;
@@ -1816,9 +1593,7 @@ panel_applet_class_init (PanelAppletClass *klass)
        widget_class->get_request_mode = panel_applet_get_request_mode;
        widget_class->size_allocate = panel_applet_size_allocate;
        widget_class->draw = panel_applet_draw;
-       widget_class->style_updated = panel_applet_style_updated;
        widget_class->focus = panel_applet_focus;
-       widget_class->realize = panel_applet_realize;
 
        /**
         * PanelApplet:out-of-process: (skip)
@@ -1903,18 +1678,6 @@ panel_applet_class_init (PanelAppletClass *klass)
                                                            PANEL_APPLET_ORIENT_UP,
                                                            G_PARAM_READWRITE));
        /**
-        * PanelApplet:background: (skip)
-        *
-        * Implementation detail.
-        **/
-       g_object_class_install_property (gobject_class,
-                                        PROP_BACKGROUND,
-                                        g_param_spec_string ("background",
-                                                             "Background",
-                                                             "Panel Applet Background",
-                                                             NULL,
-                                                             G_PARAM_READWRITE));
-       /**
         * PanelApplet:flags:
         *
         * The #PanelAppletFlags of the applet.
@@ -1973,25 +1736,6 @@ panel_applet_class_init (PanelAppletClass *klass)
                              G_TYPE_UINT);
 
         /**
-         * PanelApplet::change-background:
-         * @applet: the #PanelApplet which emitted the signal.
-         * @pattern: the new background pattern for @applet, or %NULL if there is none.
-         *
-         * Emitted when the background of @applet has changed.
-         **/
-       panel_applet_signals [CHANGE_BACKGROUND] =
-                g_signal_new ("change_background",
-                              G_TYPE_FROM_CLASS (klass),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (PanelAppletClass, change_background),
-                              NULL,
-                             NULL,
-                              g_cclosure_marshal_VOID__BOXED,
-                              G_TYPE_NONE,
-                             1,
-                             CAIRO_GOBJECT_TYPE_PATTERN);
-
-        /**
          * PanelApplet::move-focus-out-of-applet: (skip)
          * @applet: the #PanelApplet which emitted the signal.
          * @direction: the move direction.
@@ -2337,23 +2081,6 @@ panel_applet_factory_setup_in_process (const gchar               *factory_id,
                                                    callback, data);
 }
 
-/**
- * panel_applet_set_background_widget:
- * @applet: a #PanelApplet.
- * @widget: a #GtkWidget.
- *
- * Configure #PanelApplet to automatically draw the background of the applet on
- * @widget. It is generally enough to call this function with @applet as
- * @widget.
- *
- * Deprecated: 3.20: Do not use this API. Since 3.20 this function does nothing.
- **/
-void
-panel_applet_set_background_widget (PanelApplet *applet,
-                                   GtkWidget   *widget)
-{
-}
-
 guint32
 panel_applet_get_xid (PanelApplet *applet,
                      GdkScreen   *screen)
diff --git a/libpanel-applet/panel-applet.h b/libpanel-applet/panel-applet.h
index ee6c085..3899de5 100644
--- a/libpanel-applet/panel-applet.h
+++ b/libpanel-applet/panel-applet.h
@@ -145,8 +145,6 @@ struct _PanelApplet {
  * @event_box_class: The parent class.
  * @change_orient: Signal is emitted when the orientation of applet
  *    has changed.
- * @change_background: Signal is emmited when the background af applet
- *    has changed.
  * @move_focus_out_of_applet: Signal is emmited when the focus is moved
  *    out of applet. This is an implementation detail.
  *
@@ -157,8 +155,6 @@ struct _PanelAppletClass {
 
        void (*change_orient) (PanelApplet       *applet,
                               PanelAppletOrient  orient);
-       void (*change_background) (PanelApplet     *applet,
-                                  cairo_pattern_t *pattern);
        void (*move_focus_out_of_applet) (PanelApplet        *frame,
                                          GtkDirectionType    direction);
 };
@@ -167,10 +163,6 @@ GType              panel_applet_get_type             (void) G_GNUC_CONST;
  
 PanelAppletOrient  panel_applet_get_orient           (PanelApplet *applet);
 GtkOrientation     panel_applet_get_gtk_orientation  (PanelApplet *applet);
-cairo_pattern_t   *panel_applet_get_background       (PanelApplet *applet);
-
-void               panel_applet_set_background_widget (PanelApplet *applet,
-                                                      GtkWidget   *widget);
 
 GSettings         *panel_applet_settings_new         (PanelApplet *applet,
                                                      const char  *schema);
diff --git a/libpanel-applet/test-dbus-applet.c b/libpanel-applet/test-dbus-applet.c
index 3b70001..08ceca4 100644
--- a/libpanel-applet/test-dbus-applet.c
+++ b/libpanel-applet/test-dbus-applet.c
@@ -125,16 +125,6 @@ test_applet_handle_size_allocate (GtkWidget     *widget,
        }
 }
 
-static void
-test_applet_handle_background_change (TestApplet                *applet,
-                                     cairo_pattern_t           *pattern,
-                                     gpointer                   dummy)
-{
-       GdkWindow *window = gtk_widget_get_window (applet->label);
-
-        gdk_window_set_background_pattern (window, pattern);
-}
-
 static gboolean
 test_applet_fill (TestApplet *applet)
 {
@@ -179,11 +169,6 @@ test_applet_fill (TestApplet *applet)
                          G_CALLBACK (test_applet_handle_size_allocate),
                          applet);
 
-       g_signal_connect (G_OBJECT (applet),
-                         "change_background",
-                         G_CALLBACK (test_applet_handle_background_change),
-                         NULL);
-
        return TRUE;
 }
 


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