[Xfce4-commits] [xfce/xfce4-settings] 01/01: Fix broken hover effect in the settings manager (Bug #14539)

noreply at xfce.org noreply at xfce.org
Wed Jul 18 00:20:22 CEST 2018


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

o   c   h   o   s   i       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 xfce/xfce4-settings.

commit 57987f3e8ecee0f95effe0e98d773e517b54c3ee
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Tue Jul 17 23:35:23 2018 +0200

    Fix broken hover effect in the settings manager (Bug #14539)
    
    This is achieved by replacing the custom cell renderer
    with a few lines of CSS that modify the icon and draw a
    fake underline.
---
 xfce4-settings-manager/Makefile.am                 |   4 +-
 .../xfce-settings-manager-dialog.c                 |  51 +-
 xfce4-settings-manager/xfce-text-renderer.c        | 583 ---------------------
 xfce4-settings-manager/xfce-text-renderer.h        |  43 --
 4 files changed, 42 insertions(+), 639 deletions(-)

diff --git a/xfce4-settings-manager/Makefile.am b/xfce4-settings-manager/Makefile.am
index 04619ce..d3fc934 100644
--- a/xfce4-settings-manager/Makefile.am
+++ b/xfce4-settings-manager/Makefile.am
@@ -11,9 +11,7 @@ bin_PROGRAMS = \
 xfce4_settings_manager_SOURCES = \
 	main.c \
 	xfce-settings-manager-dialog.c \
-	xfce-settings-manager-dialog.h \
-	xfce-text-renderer.c \
-	xfce-text-renderer.h
+	xfce-settings-manager-dialog.h
 
 xfce4_settings_manager_CFLAGS = \
 	$(GTK_CFLAGS) \
diff --git a/xfce4-settings-manager/xfce-settings-manager-dialog.c b/xfce4-settings-manager/xfce-settings-manager-dialog.c
index e8e69b7..bf7bfbb 100644
--- a/xfce4-settings-manager/xfce-settings-manager-dialog.c
+++ b/xfce4-settings-manager/xfce-settings-manager-dialog.c
@@ -41,7 +41,6 @@
 #include <exo/exo.h>
 
 #include "xfce-settings-manager-dialog.h"
-#include "xfce-text-renderer.h"
 
 #define TEXT_WIDTH (128)
 #define ICON_WIDTH (48)
@@ -71,6 +70,8 @@ struct _XfceSettingsManagerDialog
 
     GList          *categories;
 
+    GtkCssProvider *css_provider;
+
     GtkWidget      *socket_scroll;
     GtkWidget      *socket_viewport;
     GarconMenuItem *socket_item;
@@ -108,8 +109,8 @@ enum
 
 
 static void     xfce_settings_manager_dialog_finalize        (GObject                   *object);
-static void     xfce_settings_manager_dialog_style_set       (GtkWidget                 *widget,
-                                                              GtkStyle                  *old_style);
+static void     xfce_settings_manager_dialog_style_updated   (GtkWidget                 *widget);
+static void     xfce_settings_manager_dialog_set_hover_style (XfceSettingsManagerDialog *dialog);
 static void     xfce_settings_manager_dialog_response        (GtkDialog                 *widget,
                                                               gint                       response_id);
 static void     xfce_settings_manager_dialog_header_style    (GtkWidget                 *header,
@@ -149,7 +150,7 @@ xfce_settings_manager_dialog_class_init (XfceSettingsManagerDialogClass *klass)
     gobject_class->finalize = xfce_settings_manager_dialog_finalize;
 
     gtkwiget_class = GTK_WIDGET_CLASS (klass);
-    gtkwiget_class->style_set = xfce_settings_manager_dialog_style_set;
+    gtkwiget_class->style_updated = xfce_settings_manager_dialog_style_updated;
 
     gtkdialog_class = GTK_DIALOG_CLASS (klass);
     gtkdialog_class->response = xfce_settings_manager_dialog_response;
@@ -280,6 +281,8 @@ xfce_settings_manager_dialog_init (XfceSettingsManagerDialog *dialog)
     gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_NONE);
     gtk_widget_show (viewport);
 
+    dialog->css_provider = gtk_css_provider_new ();
+
     xfce_settings_manager_dialog_menu_reload (dialog);
 
     g_signal_connect_swapped (G_OBJECT (dialog->menu), "reload-required",
@@ -311,19 +314,49 @@ xfce_settings_manager_dialog_finalize (GObject *object)
 
 
 static void
-xfce_settings_manager_dialog_style_set (GtkWidget *widget,
-                                        GtkStyle  *old_style)
+xfce_settings_manager_dialog_style_updated (GtkWidget *widget)
 {
     XfceSettingsManagerDialog *dialog = XFCE_SETTINGS_MANAGER_DIALOG (widget);
     GtkStyleContext *context;
 
     context = gtk_widget_get_style_context (dialog->category_viewport);
     gtk_style_context_add_class (context, "view");
+    gtk_style_context_add_class (context, "exoiconview");
+    xfce_settings_manager_dialog_set_hover_style (dialog);
 }
 
 
 
 static void
+xfce_settings_manager_dialog_set_hover_style (XfceSettingsManagerDialog *dialog)
+{
+    GtkStyleContext *context;
+    GdkRGBA          color;
+    gchar           *css_string;
+    gchar           *color_text;
+    GdkScreen       *screen;
+
+    context = gtk_widget_get_style_context (GTK_WIDGET (dialog));
+    /* Reset the provider to make sure we drop the previous Gtk theme style */
+    gtk_style_context_remove_provider (context,
+                                       GTK_STYLE_PROVIDER (dialog->css_provider));
+    /* Get the foreground color for the underline */
+    gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color);
+    color_text = gdk_rgba_to_string (&color);
+    /* Set a fake underline with box-shadow and use gtk to highlight the icon of the cell renderer */
+    css_string = g_strdup_printf (".exoiconview.view *:hover { -gtk-icon-effect: highlight; box-shadow: inset 0 -1px 1px %s; }",
+                                  color_text);
+    gtk_css_provider_load_from_data (dialog->css_provider, css_string, -1, NULL);
+    screen = gdk_screen_get_default ();
+    /* As we don't have the individual ExoIconView widgets here, we set this provider for the whole screen.
+       This is fairly unproblematic as nobody uses the CSS class exiconview. */
+    gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (dialog->css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    g_free (css_string);
+    g_free (color_text);
+}
+
+
+static void
 xfce_settings_manager_dialog_response (GtkDialog *widget,
                                        gint       response_id)
 {
@@ -362,6 +395,7 @@ xfce_settings_manager_dialog_response (GtkDialog *widget,
             xfconf_channel_set_int (dialog->channel, "/last/window-height", height);
         }
 
+        g_object_unref (dialog->css_provider);
         gtk_widget_destroy (GTK_WIDGET (widget));
         gtk_main_quit ();
     }
@@ -1102,6 +1136,7 @@ xfce_settings_manager_dialog_add_category (XfceSettingsManagerDialog *dialog,
     exo_icon_view_set_single_click (EXO_ICON_VIEW (iconview), TRUE);
     exo_icon_view_set_enable_search (EXO_ICON_VIEW (iconview), FALSE);
     exo_icon_view_set_item_width (EXO_ICON_VIEW (iconview), TEXT_WIDTH + ICON_WIDTH);
+    xfce_settings_manager_dialog_set_hover_style (dialog);
     gtk_widget_show (iconview);
 
     /* list used for unselecting */
@@ -1131,16 +1166,12 @@ xfce_settings_manager_dialog_add_category (XfceSettingsManagerDialog *dialog,
                   "follow-state", TRUE,
                   NULL);
 
-    /* FIXME (maybe) - Use XfceTextRenderer */
-    //render = xfce_text_renderer_new ();
     render = gtk_cell_renderer_text_new ();
     gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (iconview), render, FALSE);
     gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (iconview), render, "text", COLUMN_NAME);
     g_object_set (G_OBJECT (render),
                   "wrap-mode", PANGO_WRAP_WORD,
                   "wrap-width", TEXT_WIDTH,
-                  //"follow-prelit", TRUE,
-                  //"follow-state", TRUE,
                   NULL);
 
     g_object_unref (G_OBJECT (filter));
diff --git a/xfce4-settings-manager/xfce-text-renderer.c b/xfce4-settings-manager/xfce-text-renderer.c
deleted file mode 100644
index 65b521e..0000000
--- a/xfce4-settings-manager/xfce-text-renderer.c
+++ /dev/null
@@ -1,583 +0,0 @@
-/*-
- * Copyright (c) 2008      Jannis Pohlmann <jannis at xfce.org>
- * Copyright (c) 2005-2006 Benedikt Meurer <benny at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <exo/exo.h>
-
-#include "xfce-text-renderer.h"
-
-
-
-enum
-{
-  PROP_0,
-  PROP_FOLLOW_PRELIT,
-  PROP_FOLLOW_STATE,
-  PROP_TEXT,
-  PROP_WRAP_MODE,
-  PROP_WRAP_WIDTH,
-};
-
-enum
-{
-  EDITED,
-  LAST_SIGNAL,
-};
-
-
-
-static void xfce_text_renderer_finalize     (GObject               *object);
-static void xfce_text_renderer_get_property (GObject               *object,
-                                             guint                  prop_id,
-                                             GValue                *value,
-                                             GParamSpec            *pspec);
-static void xfce_text_renderer_set_property (GObject               *object,
-                                             guint                  prop_id,
-                                             const GValue          *value,
-                                             GParamSpec            *pspec);
-static void xfce_text_renderer_render       (GtkCellRenderer       *renderer,
-                                             cairo_t               *cr,
-                                             GtkWidget             *widget,
-                                             const GdkRectangle    *background_area,
-                                             const GdkRectangle    *cell_area,
-                                             GtkCellRendererState   flags);
-static void xfce_text_renderer_invalidate   (XfceTextRenderer      *text_renderer);
-static void xfce_text_renderer_set_widget   (XfceTextRenderer      *text_renderer,
-                                             GtkWidget             *widget);
-
-
-
-struct _XfceTextRendererClass
-{
-  GtkCellRendererClass __parent__;
-};
-
-struct _XfceTextRenderer
-{
-  GtkCellRenderer __parent__;
-
-  PangoLayout  *layout;
-  GtkWidget    *widget;
-  gboolean      text_static;
-  gchar        *text;
-  gint          char_width;
-  gint          char_height;
-  PangoWrapMode wrap_mode;
-  gint          wrap_width;
-  gboolean      follow_state;
-  gint          focus_width;;
-
-  /* underline prelited rows */
-  gboolean      follow_prelit;
-};
-
-
-
-G_DEFINE_TYPE (XfceTextRenderer, xfce_text_renderer, GTK_TYPE_CELL_RENDERER)
-
-
-
-static void
-xfce_text_renderer_class_init (XfceTextRendererClass *klass)
-{
-  GtkCellRendererClass *gtkcell_renderer_class;
-  GObjectClass         *gobject_class;
-
-  gobject_class = G_OBJECT_CLASS (klass);
-  gobject_class->finalize = xfce_text_renderer_finalize;
-  gobject_class->get_property = xfce_text_renderer_get_property;
-  gobject_class->set_property = xfce_text_renderer_set_property;
-
-  gtkcell_renderer_class = GTK_CELL_RENDERER_CLASS (klass);
-  gtkcell_renderer_class->render = xfce_text_renderer_render;
-
-  /**
-   * XfceTextRenderer:follow-prelit:
-   *
-   * Whether to underline prelited cells. This is used for the single
-   * click support in the detailed list view.
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_FOLLOW_PRELIT,
-                                   g_param_spec_boolean ("follow-prelit",
-                                                         "follow-prelit",
-                                                         "follow-prelit",
-                                                         FALSE,
-                                                         EXO_PARAM_READWRITE));
-
-  /**
-   * XfceTextRenderer:follow-state:
-   *
-   * Specifies whether the text renderer should render text
-   * based on the selection state of the items. This is necessary
-   * for #ExoIconView, which doesn't draw any item state indicators
-   * itself.
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_FOLLOW_STATE,
-                                   g_param_spec_boolean ("follow-state",
-                                                         "follow-state",
-                                                         "follow-state",
-                                                         FALSE,
-                                                         EXO_PARAM_READWRITE));
-
-  /**
-   * XfceTextRenderer:text:
-   *
-   * The text to render.
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_TEXT,
-                                   g_param_spec_string ("text",
-                                                        "text",
-                                                        "text",
-                                                        NULL,
-                                                        EXO_PARAM_READWRITE));
-
-  /**
-   * XfceTextRenderer:wrap-mode:
-   *
-   * Specifies how to break the string into multiple lines, if the cell renderer
-   * does not have enough room to display the entire string. This property has
-   * no effect unless the wrap-width property is set.
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_WRAP_MODE,
-                                   g_param_spec_enum ("wrap-mode",
-                                                      "wrap-mode",
-                                                      "wrap-mode",
-                                                      PANGO_TYPE_WRAP_MODE,
-                                                      PANGO_WRAP_CHAR,
-                                                      EXO_PARAM_READWRITE));
-
-  /**
-   * XfceTextRenderer:wrap-width:
-   *
-   * Specifies the width at which the text is wrapped. The wrap-mode property can
-   * be used to influence at what character positions the line breaks can be placed.
-   * Setting wrap-width to -1 turns wrapping off.
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_WRAP_WIDTH,
-                                   g_param_spec_int ("wrap-width",
-                                                     "wrap-width",
-                                                     "wrap-width",
-                                                     -1, G_MAXINT, -1,
-                                                     EXO_PARAM_READWRITE));
-}
-
-
-
-static void
-xfce_text_renderer_init (XfceTextRenderer *text_renderer)
-{
-  text_renderer->wrap_width = -1;
-}
-
-
-
-static void
-xfce_text_renderer_finalize (GObject *object)
-{
-  XfceTextRenderer *text_renderer = XFCE_TEXT_RENDERER (object);
-
-  /* release text (if not static) */
-  if (!text_renderer->text_static)
-    g_free (text_renderer->text);
-
-  /* drop the cached widget */
-  xfce_text_renderer_set_widget (text_renderer, NULL);
-
-  (*G_OBJECT_CLASS (xfce_text_renderer_parent_class)->finalize) (object);
-}
-
-
-
-static void
-xfce_text_renderer_get_property (GObject    *object,
-                                 guint       prop_id,
-                                 GValue     *value,
-                                 GParamSpec *pspec)
-{
-  XfceTextRenderer *text_renderer = XFCE_TEXT_RENDERER (object);
-
-  switch (prop_id)
-    {
-    case PROP_FOLLOW_PRELIT:
-      g_value_set_boolean (value, text_renderer->follow_prelit);
-      break;
-
-    case PROP_FOLLOW_STATE:
-      g_value_set_boolean (value, text_renderer->follow_state);
-      break;
-
-    case PROP_TEXT:
-      g_value_set_string (value, text_renderer->text);
-      break;
-
-    case PROP_WRAP_MODE:
-      g_value_set_enum (value, text_renderer->wrap_mode);
-      break;
-
-    case PROP_WRAP_WIDTH:
-      g_value_set_int (value, text_renderer->wrap_width);
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-
-
-static void
-xfce_text_renderer_set_property (GObject      *object,
-                                 guint         prop_id,
-                                 const GValue *value,
-                                 GParamSpec   *pspec)
-{
-  XfceTextRenderer *text_renderer = XFCE_TEXT_RENDERER (object);
-  const gchar      *sval;
-
-  switch (prop_id)
-    {
-    case PROP_FOLLOW_PRELIT:
-      text_renderer->follow_prelit = g_value_get_boolean (value);
-      break;
-
-    case PROP_FOLLOW_STATE:
-      text_renderer->follow_state = g_value_get_boolean (value);
-      break;
-
-    case PROP_TEXT:
-      /* release the previous text (if not static) */
-      if (!text_renderer->text_static)
-        g_free (text_renderer->text);
-      sval = g_value_get_string (value);
-      text_renderer->text_static = (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS);
-      text_renderer->text = (sval == NULL) ? "" : (gchar *)sval;
-      if (!text_renderer->text_static)
-        text_renderer->text = g_strdup (text_renderer->text);
-      break;
-
-    case PROP_WRAP_MODE:
-      text_renderer->wrap_mode = g_value_get_enum (value);
-      break;
-
-    case PROP_WRAP_WIDTH:
-      /* be sure to reset fixed height if wrapping is requested */
-      text_renderer->wrap_width = g_value_get_int (value);
-      if (G_LIKELY (text_renderer->wrap_width >= 0))
-        gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (text_renderer), -1, -1);
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-      break;
-    }
-}
-
-
-
-static PangoAttrList*
-xfce_pango_attr_list_wrap (PangoAttribute *attribute, ...)
-{
-  PangoAttrList *attr_list;
-  va_list        args;
-
-  /* allocate a new attribute list */
-  attr_list = pango_attr_list_new ();
-
-  /* add all specified attributes */
-  va_start (args, attribute);
-  while (attribute != NULL)
-    {
-      attribute->start_index = 0;
-      attribute->end_index = -1;
-      pango_attr_list_insert (attr_list, attribute);
-      attribute = va_arg (args, PangoAttribute *);
-    }
-  va_end (args);
-
-  return attr_list;
-}
-
-
-
-/**
- * xfce_pango_attr_list_underline_single:
- *
- * Returns a #PangoAttrList for underlining text using a single line.
- * The returned list is owned by the callee and must not be freed
- * or modified by the caller.
- *
- * Return value: a #PangoAttrList for underlining text using a single line.
- **/
-static PangoAttrList*
-xfce_pango_attr_list_underline_single (void)
-{
-  static PangoAttrList *attr_list = NULL;
-  if (G_UNLIKELY (attr_list == NULL))
-    attr_list = xfce_pango_attr_list_wrap (pango_attr_underline_new (PANGO_UNDERLINE_SINGLE), NULL);
-  return attr_list;
-}
-
-
-
-static void
-xfce_text_renderer_render (GtkCellRenderer     *renderer,
-                           cairo_t             *cr,
-                           GtkWidget           *widget,
-                           const GdkRectangle  *background_area,
-                           const GdkRectangle  *cell_area,
-                           GtkCellRendererState flags)
-{
-  XfceTextRenderer *text_renderer = XFCE_TEXT_RENDERER (renderer);
-  GtkStateType      state;
-  gint              x0, x1, y0, y1;
-  gint              text_width;
-  gint              text_height;
-  gint              x_offset;
-  gint              y_offset;
-  gint              x_pad;
-  gint              y_pad;
-  gfloat            x_align;
-  gfloat            y_align;
-
-  GtkStyleContext  *ctx = gtk_widget_get_style_context (widget);
-  GdkRGBA          *color;
-
-  /* setup the new widget */
-  xfce_text_renderer_set_widget (text_renderer, widget);
-
-  if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
-    {
-      if (gtk_widget_has_focus (widget))
-        state = GTK_STATE_SELECTED;
-      else
-        state = GTK_STATE_ACTIVE;
-    }
-  else if ((flags & GTK_CELL_RENDERER_PRELIT) == GTK_CELL_RENDERER_PRELIT
-        && gtk_widget_get_state_flags (widget) & GTK_STATE_PRELIGHT)
-    {
-      state = GTK_STATE_PRELIGHT;
-    }
-  else
-    {
-      if (gtk_widget_get_state_flags (widget) & GTK_STATE_INSENSITIVE)
-        state = GTK_STATE_INSENSITIVE;
-      else
-        state = GTK_STATE_NORMAL;
-    }
-
-  /* check if we should follow the prelit state (used for single click support) */
-  if (text_renderer->follow_prelit && (flags & GTK_CELL_RENDERER_PRELIT) != 0)
-    pango_layout_set_attributes (text_renderer->layout, xfce_pango_attr_list_underline_single ());
-  else
-    pango_layout_set_attributes (text_renderer->layout, NULL);
-
-  /* setup the wrapping */
-  if (text_renderer->wrap_width < 0)
-    {
-      pango_layout_set_width (text_renderer->layout, -1);
-      pango_layout_set_wrap (text_renderer->layout, PANGO_WRAP_CHAR);
-    }
-  else
-    {
-      pango_layout_set_width (text_renderer->layout, text_renderer->wrap_width * PANGO_SCALE);
-      pango_layout_set_wrap (text_renderer->layout, text_renderer->wrap_mode);
-    }
-
-  pango_layout_set_text (text_renderer->layout, text_renderer->text, -1);
-
-  /* calculate the real text dimension */
-  pango_layout_get_pixel_size (text_renderer->layout, &text_width, &text_height);
-
-  /* take into account the state indicator (required for calculation) */
-  if (text_renderer->follow_state)
-    {
-      text_width += 2 * text_renderer->focus_width;
-      text_height += 2 * text_renderer->focus_width;
-    }
-
-  gtk_cell_renderer_get_padding(renderer, &x_pad, &y_pad);
-  gtk_cell_renderer_get_alignment(renderer, &x_align, &y_align);
-
-  /* calculate the real x-offset */
-  x_offset = ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? (1.0 - x_align) : x_align)
-           * (cell_area->width - text_width - (2 * x_pad));
-  x_offset = MAX (x_offset, 0);
-
-  /* calculate the real y-offset */
-  y_offset = y_align * (cell_area->height - text_height - (2 * y_pad));
-  y_offset = MAX (y_offset, 0);
-
-  /* render the state indicator */
-  if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED && text_renderer->follow_state)
-    {
-      /* calculate the text bounding box (including the focus padding/width) */
-      x0 = cell_area->x + x_offset;
-      y0 = cell_area->y + y_offset;
-      x1 = x0 + text_width;
-      y1 = y0 + text_height;
-
-      /* get the color */
-      gtk_style_context_get (ctx,
-                             state,
-                             "background-color", &color,
-                             NULL);
-
-      /* Cairo produces nicer results than using a polygon
-       * and so we use it directly if possible.
-       */
-      cairo_move_to (cr, x0 + 5, y0);
-      cairo_line_to (cr, x1 - 5, y0);
-      cairo_curve_to (cr, x1 - 5, y0, x1, y0, x1, y0 + 5);
-      cairo_line_to (cr, x1, y1 - 5);
-      cairo_curve_to (cr, x1, y1 - 5, x1, y1, x1 - 5, y1);
-      cairo_line_to (cr, x0 + 5, y1);
-      cairo_curve_to (cr, x0 + 5, y1, x0, y1, x0, y1 - 5);
-      cairo_line_to (cr, x0, y0 + 5);
-      cairo_curve_to (cr, x0, y0 + 5, x0, y0, x0 + 5, y0);
-      gdk_cairo_set_source_rgba (cr, color);
-      cairo_fill (cr);
-      //cairo_destroy (cr);
-    }
-
-  /* draw the focus indicator */
-  if (text_renderer->follow_state && (flags & GTK_CELL_RENDERER_FOCUSED) != 0)
-    {
-      gtk_render_focus (ctx, cr, cell_area->x + x_offset, cell_area->y + y_offset, text_width, text_height);
-    }
-
-  /* get proper sizing for the layout drawing */
-  if (text_renderer->follow_state)
-    {
-      text_width -= 2 * text_renderer->focus_width;
-      text_height -= 2 * text_renderer->focus_width;
-      x_offset += text_renderer->focus_width;
-      y_offset += text_renderer->focus_width;
-    }
-
-  /* draw the text */
-  gtk_render_layout (ctx, cr,
-                     cell_area->x + x_offset + x_pad,
-                     cell_area->y + y_offset + y_pad,
-                     text_renderer->layout);
-}
-
-
-
-static void
-xfce_text_renderer_invalidate (XfceTextRenderer *text_renderer)
-{
-  xfce_text_renderer_set_widget (text_renderer, NULL);
-}
-
-
-
-static void
-xfce_text_renderer_set_widget (XfceTextRenderer *text_renderer,
-                               GtkWidget          *widget)
-{
-  PangoFontMetrics *metrics;
-  PangoContext     *context;
-  PangoFontDescription *desc;
-  gint              focus_padding;
-  gint              focus_line_width;
-
-  if (G_LIKELY (widget == text_renderer->widget))
-    return;
-
-  /* disconnect from the previously set widget */
-  if (G_UNLIKELY (text_renderer->widget != NULL))
-    {
-      g_signal_handlers_disconnect_by_func (G_OBJECT (text_renderer->widget), xfce_text_renderer_invalidate, text_renderer);
-      g_object_unref (G_OBJECT (text_renderer->layout));
-      g_object_unref (G_OBJECT (text_renderer->widget));
-    }
-
-  /* activate the new widget */
-  text_renderer->widget = widget;
-
-  /* connect to the new widget */
-  if (G_LIKELY (widget != NULL))
-    {
-      /* take a reference on the widget */
-      g_object_ref (G_OBJECT (widget));
-
-      /* we need to recalculate the metrics when a new style (and thereby a new font) is set */
-      g_signal_connect_swapped (G_OBJECT (text_renderer->widget), "destroy", G_CALLBACK (xfce_text_renderer_invalidate), text_renderer);
-      g_signal_connect_swapped (G_OBJECT (text_renderer->widget), "style-set", G_CALLBACK (xfce_text_renderer_invalidate), text_renderer);
-
-      /* allocate a new pango layout for this widget */
-      context = gtk_widget_get_pango_context (widget);
-      text_renderer->layout = pango_layout_new (context);
-
-      /* disable automatic text direction, but use the direction specified by Gtk+ */
-      pango_layout_set_auto_dir (text_renderer->layout, FALSE);
-
-      /* we don't want to interpret line separators in file names */
-      pango_layout_set_single_paragraph_mode (text_renderer->layout, TRUE);
-
-      desc = pango_context_get_font_description (context);
-
-      /* calculate the average character dimensions */
-      metrics = pango_context_get_metrics (context, desc, pango_context_get_language (context));
-      text_renderer->char_width = PANGO_PIXELS (pango_font_metrics_get_approximate_char_width (metrics));
-      text_renderer->char_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics));
-      pango_font_metrics_unref (metrics);
-
-      /* tell the cell renderer about the fixed height if we're not wrapping text */
-      if (G_LIKELY (text_renderer->wrap_width < 0))
-        gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (text_renderer), -1, text_renderer->char_height);
-
-      /* determine the focus-padding and focus-line-width style properties from the widget */
-      gtk_widget_style_get (widget, "focus-padding", &focus_padding, "focus-line-width", &focus_line_width, NULL);
-      text_renderer->focus_width = focus_padding + focus_line_width;
-    }
-  else
-    {
-      text_renderer->layout = NULL;
-      text_renderer->char_width = 0;
-      text_renderer->char_height = 0;
-    }
-}
-
-
-
-/**
- * xfce_text_renderer_new:
- **/
-GtkCellRenderer*
-xfce_text_renderer_new (void)
-{
-  return g_object_new (XFCE_TYPE_TEXT_RENDERER, NULL);
-}
diff --git a/xfce4-settings-manager/xfce-text-renderer.h b/xfce4-settings-manager/xfce-text-renderer.h
deleted file mode 100644
index b4a2384..0000000
--- a/xfce4-settings-manager/xfce-text-renderer.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * Copyright (c) 2008 Jannis Pohlmann <jannis at xfce.org>
- * Copyright (c) 2005 Benedikt Meurer <benny at xfce.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __XFCE_TEXT_RENDERER_H__
-#define __XFCE_TEXT_RENDERER_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS;
-
-typedef struct _XfceTextRendererClass XfceTextRendererClass;
-typedef struct _XfceTextRenderer      XfceTextRenderer;
-
-#define XFCE_TYPE_TEXT_RENDERER            (xfce_text_renderer_get_type ())
-#define XFCE_TEXT_RENDERER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFCE_TYPE_TEXT_RENDERER, XfceTextRenderer))
-#define XFCE_TEXT_RENDERER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), XFCE_TYPE_TEXT_RENDERER, XfceTextRendererClass))
-#define XFCE_IS_TEXT_RENDERER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFCE_TYPE_TEXT_RENDERER))
-#define XFCE_IS_TEXT_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFCE_TYPE_TEXT_RENDERER))
-#define XFCE_TEXT_RENDERER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), XFCE_TYPE_TEXT_RENDERER, XfceTextRendererClass))
-
-GType            xfce_text_renderer_get_type (void) G_GNUC_CONST;
-
-GtkCellRenderer *xfce_text_renderer_new      (void) G_GNUC_MALLOC;
-
-G_END_DECLS;
-
-#endif /* !__XFCE_TEXT_RENDERER_H__ */

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


More information about the Xfce4-commits mailing list