[gnumeric] Gtk: export css helper function to goffice.



commit 91c2e9199449e60a958978ced60f6681cb5a5881
Author: Morten Welinder <terra gnome org>
Date:   Sun Dec 10 14:37:11 2017 -0500

    Gtk: export css helper function to goffice.

 configure.ac   |    2 +-
 src/gui-util.c |  150 --------------------------------------------------------
 src/gui-util.h |    3 -
 src/item-bar.c |    2 +-
 4 files changed, 2 insertions(+), 155 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bffe5ed..0f769ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -166,7 +166,7 @@ PKG_PROG_PKG_CONFIG(0.18)
 
 dnl *****************************
 libspreadsheet_reqs="
-       libgoffice-${GOFFICE_API_VER}   >= 0.10.28
+       libgoffice-${GOFFICE_API_VER}   >= 0.10.38
        libgsf-1                >= 1.14.33
        libxml-2.0              >= 2.4.12
 "
diff --git a/src/gui-util.c b/src/gui-util.c
index e6e2820..b0cfa04 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -1359,154 +1359,4 @@ gnm_style_context_get_color (GtkStyleContext *context,
        gtk_style_context_restore (context);
 }
 
-// ---------------------------------------------------------------------------
-// Foreign drawing style code copied from foreigndrawing.c
-
-#if GTK_CHECK_VERSION(3,20,0)
-static void
-append_element (GtkWidgetPath *path,
-                const char    *selector)
-{
-  static const struct {
-    const char    *name;
-    GtkStateFlags  state_flag;
-  } pseudo_classes[] = {
-    { "active",        GTK_STATE_FLAG_ACTIVE },
-    { "hover",         GTK_STATE_FLAG_PRELIGHT },
-    { "selected",      GTK_STATE_FLAG_SELECTED },
-    { "disabled",      GTK_STATE_FLAG_INSENSITIVE },
-    { "indeterminate", GTK_STATE_FLAG_INCONSISTENT },
-    { "focus",         GTK_STATE_FLAG_FOCUSED },
-    { "backdrop",      GTK_STATE_FLAG_BACKDROP },
-    { "dir(ltr)",      GTK_STATE_FLAG_DIR_LTR },
-    { "dir(rtl)",      GTK_STATE_FLAG_DIR_RTL },
-    { "link",          GTK_STATE_FLAG_LINK },
-    { "visited",       GTK_STATE_FLAG_VISITED },
-    { "checked",       GTK_STATE_FLAG_CHECKED },
-    { "drop(active)",  GTK_STATE_FLAG_DROP_ACTIVE }
-  };
-  const char *next;
-  char *name;
-  char type;
-  guint i;
-
-  next = strpbrk (selector, "#.:");
-  if (next == NULL)
-    next = selector + strlen (selector);
-
-  name = g_strndup (selector, next - selector);
-  if (g_ascii_isupper (selector[0]))
-    {
-      GType gtype;
-      gtype = g_type_from_name (name);
-      if (gtype == G_TYPE_INVALID)
-        {
-          g_critical ("Unknown type name `%s'", name);
-          g_free (name);
-          return;
-        }
-      gtk_widget_path_append_type (path, gtype);
-    }
-  else
-    {
-      /* Omit type, we're using name */
-      gtk_widget_path_append_type (path, G_TYPE_NONE);
-      gtk_widget_path_iter_set_object_name (path, -1, name);
-    }
-  g_free (name);
-
-  while (*next != '\0')
-    {
-      type = *next;
-      selector = next + 1;
-      next = strpbrk (selector, "#.:");
-      if (next == NULL)
-        next = selector + strlen (selector);
-      name = g_strndup (selector, next - selector);
-
-      switch (type)
-        {
-        case '#':
-          gtk_widget_path_iter_set_name (path, -1, name);
-          break;
-
-        case '.':
-          gtk_widget_path_iter_add_class (path, -1, name);
-          break;
-
-        case ':':
-          for (i = 0; i < G_N_ELEMENTS (pseudo_classes); i++)
-            {
-              if (g_str_equal (pseudo_classes[i].name, name))
-                {
-                  gtk_widget_path_iter_set_state (path,
-                                                  -1,
-                                                  gtk_widget_path_iter_get_state (path, -1)
-                                                  | pseudo_classes[i].state_flag);
-                  break;
-                }
-            }
-          if (i == G_N_ELEMENTS (pseudo_classes))
-            g_critical ("Unknown pseudo-class :%s", name);
-          break;
-
-        default:
-          g_assert_not_reached ();
-          break;
-        }
-
-      g_free (name);
-    }
-}
-
-static GtkStyleContext *
-create_context_for_path (GtkWidgetPath   *path,
-                         GtkStyleContext *parent)
-{
-  GtkStyleContext *context;
-
-  context = gtk_style_context_new ();
-  gtk_style_context_set_path (context, path);
-  gtk_style_context_set_parent (context, parent);
-  /* Unfortunately, we have to explicitly set the state again here
-   * for it to take effect
-   */
-  gtk_style_context_set_state (context, gtk_widget_path_iter_get_state (path, -1));
-  gtk_widget_path_unref (path);
-
-  return context;
-}
-#endif
-
-/**
- * gnm_style_context_from_selector:
- * @parent: (allow-none): style context for container
- * @selector: a css selector
- *
- * Returns: (transfer full): a new style context.
- */
-GtkStyleContext *
-gnm_style_context_from_selector (GtkStyleContext *parent,
-                                const char      *selector)
-{
-#if GTK_CHECK_VERSION(3,20,0)
-  GtkWidgetPath *path;
-
-  if (parent)
-    path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
-  else
-    path = gtk_widget_path_new ();
-
-  append_element (path, selector);
-
-  return create_context_for_path (path, parent);
-#else
-  g_return_val_if_fail (selector != NULL, NULL);
-  (void)parent;
-  (void)selector;
-  g_assert_not_reached ();
-  return NULL;
-#endif
-}
-
 // ----------------------------------------------------------------------------
diff --git a/src/gui-util.h b/src/gui-util.h
index 590e459..a8ad2cb 100644
--- a/src/gui-util.h
+++ b/src/gui-util.h
@@ -187,9 +187,6 @@ void gnm_style_context_get_color (GtkStyleContext *context,
                                  GtkStateFlags state,
                                  GdkRGBA *color);
 
-GtkStyleContext * gnm_style_context_from_selector (GtkStyleContext *parent,
-                                                  const char      *selector);
-
 G_END_DECLS
 
 #endif /* _GNM_GUI_UTIL_H_ */
diff --git a/src/item-bar.c b/src/item-bar.c
index a296afa..867c83f 100644
--- a/src/item-bar.c
+++ b/src/item-bar.c
@@ -155,7 +155,7 @@ ib_reload_sizing_style (GnmItemBar *ib)
 
                g_clear_object (&ib->styles[ui]);
 #if GTK_CHECK_VERSION(3,20,0)
-               context = gnm_style_context_from_selector (NULL, selection_styles[ui]);
+               context = go_style_context_from_selector (NULL, selection_styles[ui]);
 #else
                context = g_object_ref (goc_item_get_style_context (item));
 #endif


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