[gnome-panel/gtk3] notification_area: Port to GtkStyleContext



commit 6d390be628ce8fccbfee5c5cca4e240fa391cdda
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sun Jan 23 12:00:17 2011 +0100

    notification_area: Port to GtkStyleContext

 applets/notification_area/fixedtip.c |   21 ++++++++++++++++-----
 applets/notification_area/main.c     |   27 ++++++++++++---------------
 2 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/applets/notification_area/fixedtip.c b/applets/notification_area/fixedtip.c
index e581a97..0e3c217 100644
--- a/applets/notification_area/fixedtip.c
+++ b/applets/notification_area/fixedtip.c
@@ -54,16 +54,27 @@ button_press_handler (GtkWidget      *fixedtip,
 static gboolean
 na_fixed_tip_draw (GtkWidget *widget, cairo_t *cr)
 {
+  GtkStyleContext *context;
+  GtkStateFlags state;
   int width, height;
 
   width = gtk_widget_get_allocated_width (widget);
   height = gtk_widget_get_allocated_height (widget);
 
-  gtk_paint_flat_box (gtk_widget_get_style (widget),
-                      cr,
-                      GTK_STATE_NORMAL, GTK_SHADOW_OUT, 
-                      widget, "tooltip",
-                      0, 0, width, height);
+  state = gtk_widget_get_state_flags (widget);
+  context = gtk_widget_get_style_context (widget);
+  gtk_style_context_save (context);
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLTIP);
+  gtk_style_context_set_state (context, state);
+
+  cairo_save (cr);
+  gtk_render_background (context, cr,
+                         0., 0.,
+                         (gdouble)width,
+                         (gdouble)height);
+  cairo_restore (cr);
+
+  gtk_style_context_restore (context);
 
   return FALSE;
 }
diff --git a/applets/notification_area/main.c b/applets/notification_area/main.c
index 2465a21..c716439 100644
--- a/applets/notification_area/main.c
+++ b/applets/notification_area/main.c
@@ -264,21 +264,18 @@ on_applet_realized (GtkWidget *widget,
 static inline void
 force_no_focus_padding (GtkWidget *widget)
 {
-  static gboolean first_time = TRUE;
-
-  if (first_time)
-    {
-      gtk_rc_parse_string ("\n"
-                           "   style \"na-tray-style\"\n"
-                           "   {\n"
-                           "      GtkWidget::focus-line-width=0\n"
-                           "      GtkWidget::focus-padding=0\n"
-                           "   }\n"
-                           "\n"
-                           "    widget \"*.na-tray\" style \"na-tray-style\"\n"
-                           "\n");
-      first_time = FALSE;
-    }
+  GtkCssProvider *provider;
+
+  provider = gtk_css_provider_new ();
+  gtk_css_provider_load_from_data (provider,
+                                   "#na-tray {\n"
+                                   " -GtkWidget-focus-line-width: 0px;\n"
+                                   " -GtkWidget-focus-padding: 0px; }",
+                                   -1, NULL);
+  gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+                                  GTK_STYLE_PROVIDER (provider),
+                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  g_object_unref (provider);
 
   gtk_widget_set_name (widget, "na-tray");
 }



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