[metacity/wip/gtk-theme: 8/51] resize-popup: use a tooltip style for the resize popup window



commit bc24d5ae1b0af90484176e741775e197f940dff0
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jan 28 16:47:47 2013 -0500

    resize-popup: use a tooltip style for the resize popup window
    
    - set GTK_STYLE_CLASS_TOOLTIP on the window, and use the same code of
      GtkTooltip to paint it
    - set GDK_WINDOW_TYPE_HINT_TOOLTIP and make the window non-resizable, so
      it doesn't get an incorrect shadow from the WM
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692741

 src/ui/resizepopup.c |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)
---
diff --git a/src/ui/resizepopup.c b/src/ui/resizepopup.c
index bc929e6..f0c7a08 100644
--- a/src/ui/resizepopup.c
+++ b/src/ui/resizepopup.c
@@ -65,21 +65,51 @@ meta_ui_resize_popup_free (MetaResizePopup *popup)
   g_free (popup);
 }
 
+static gboolean
+size_window_draw (GtkWidget       *widget,
+                  cairo_t         *cr,
+                  MetaResizePopup *popup)
+{
+  GtkStyleContext *context;
+  gint width, height;
+
+  context = gtk_widget_get_style_context (widget);
+  width = gtk_widget_get_allocated_width (widget);
+  height = gtk_widget_get_allocated_height (widget);
+
+  gtk_render_background (context, cr, 0, 0, width, height);
+  gtk_render_frame (context, cr, 0, 0, width, height);
+
+  return FALSE;
+}
+
 static void
 ensure_size_window (MetaResizePopup *popup)
 {
+  GdkVisual *visual;
+  GdkScreen *screen;
+
   if (popup->size_window)
     return;
 
   popup->size_window = gtk_window_new (GTK_WINDOW_POPUP);
-
-  gtk_window_set_screen (GTK_WINDOW (popup->size_window),
-                        gdk_display_get_screen (gdk_x11_lookup_xdisplay (popup->display),
-                                                popup->screen_number));
-
-  /* never shrink the size window */
-  gtk_window_set_resizable (GTK_WINDOW (popup->size_window),
-                            TRUE);
+  screen = gdk_display_get_screen (gdk_x11_lookup_xdisplay (popup->display),
+                                   popup->screen_number);
+  visual = gdk_screen_get_rgba_visual (screen);
+
+  gtk_window_set_screen (GTK_WINDOW (popup->size_window), screen);
+  if (visual != NULL)
+    gtk_widget_set_visual (popup->size_window, visual);
+
+  gtk_window_set_type_hint (GTK_WINDOW (popup->size_window),
+                            GDK_WINDOW_TYPE_HINT_TOOLTIP);
+  gtk_window_set_resizable (GTK_WINDOW (popup->size_window), FALSE);
+
+  gtk_widget_set_app_paintable (popup->size_window, TRUE);
+  gtk_style_context_add_class (gtk_widget_get_style_context (popup->size_window),
+                               GTK_STYLE_CLASS_TOOLTIP);
+  g_signal_connect (popup->size_window, "draw",
+                    G_CALLBACK (size_window_draw), popup);
 
   popup->size_label = gtk_label_new ("");
 


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