[gnumeric] GUI: Simplify pseudo-tooltip handling.



commit edb1198084ab58d99aadee1c016643e092cc8451
Author: Morten Welinder <terra gnome org>
Date:   Thu Mar 28 13:40:34 2013 -0400

    GUI: Simplify pseudo-tooltip handling.

 src/dialogs/dialog-formula-guru.c |    2 +-
 src/gnumeric.css                  |   12 ++++---
 src/gui-util.c                    |   57 +++++++++----------------------------
 src/gui-util.h                    |    2 -
 src/widgets/gnumeric-expr-entry.c |    2 +-
 5 files changed, 23 insertions(+), 52 deletions(-)
---
diff --git a/src/dialogs/dialog-formula-guru.c b/src/dialogs/dialog-formula-guru.c
index 47b80c5..a4b11ed 100644
--- a/src/dialogs/dialog-formula-guru.c
+++ b/src/dialogs/dialog-formula-guru.c
@@ -829,7 +829,7 @@ cb_dialog_formula_guru_query_tooltip (G_GNUC_UNUSED GtkWidget  *widget,
                if (markup == NULL || markup[0]=='\0')
                        return FALSE;
                if (!state->tooltip_widget) {
-                       state->tooltip_label = gnumeric_create_tooltip_widget ();
+                       state->tooltip_label = gtk_label_new ("");
                        state->tooltip_widget
                                = gtk_widget_get_toplevel (state->tooltip_label);
                        gtk_widget_show_all (state->tooltip_widget);
diff --git a/src/gnumeric.css b/src/gnumeric.css
index 552144d..90c688b 100644
--- a/src/gnumeric.css
+++ b/src/gnumeric.css
@@ -139,15 +139,17 @@ GnmNotebook {
 /* ------------------------------------------------------------------------- */
 
 GtkHandleBox {
-  color: transparent;
+  color: rgba(0,0,0,0);
   padding: 0px;
 }
 
 /* ------------------------------------------------------------------------- */
-/* When we stuff a GtkTextView into a tooltip, we need to prevent it from
-   having its own background.  Ideally the theme would handle this.  */
-.tooltip GtkTextView {
-  background-color: transparent;
+/* Add a little bit of space around our pseudo tooltips, but not so much as
+   to be a problem if the theme somehow adds its own.  */
+
+GtkWindow>GtkFrame.pseudo-tooltip {
+  border-width: 0;
+  padding: 5/*px*/;
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/src/gui-util.c b/src/gui-util.c
index 469af39..35dc3d7 100644
--- a/src/gui-util.c
+++ b/src/gui-util.c
@@ -490,44 +490,12 @@ gnumeric_tooltip_set_style (GtkWidget *widget)
 {
        gtk_style_context_add_class (gtk_widget_get_style_context (widget),
                                     GTK_STYLE_CLASS_TOOLTIP);
-}
-
-/**
- * gnumeric_create_tooltip_text_view_widget:
- *
- * Returns: (transfer full): the newly allocated #GtkWidget.
- **/
-GtkWidget *
-gnumeric_create_tooltip_text_view_widget (void)
-{
-       GtkWidget *label, *frame;
-
-       frame = gtk_frame_new (NULL);
-       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
-       label = gtk_text_view_new ();
-
-       gtk_container_add (GTK_CONTAINER (frame), label);
-
-       return label;
-}
-
-/**
- * gnumeric_create_tooltip_widget:
- *
- * Returns: (transfer full): the newly allocated #GtkWidget.
- **/
-GtkWidget *
-gnumeric_create_tooltip_widget (void)
-{
-       GtkWidget *label, *frame;
-
-       frame = gtk_frame_new (NULL);
-       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
-       label = gtk_label_new ("");
-
-       gtk_container_add (GTK_CONTAINER (frame), label);
-
-       return label;
+       gtk_style_context_add_class (gtk_widget_get_style_context (widget),
+                                    "pseudo-tooltip");
+       if (GTK_IS_CONTAINER (widget))
+               gtk_container_forall (GTK_CONTAINER (widget),
+                                     (GtkCallback) (gnumeric_tooltip_set_style),
+                                     NULL);
 }
 
 /**
@@ -541,19 +509,22 @@ GtkWidget *
 gnumeric_convert_to_tooltip (GtkWidget *ref_widget, GtkWidget *widget)
 {
        GtkWidget *tip, *frame;
+       GdkScreen *screen = gtk_widget_get_screen (ref_widget);
 
        tip = gtk_window_new (GTK_WINDOW_POPUP);
        gtk_window_set_type_hint (GTK_WINDOW (tip),
                                  GDK_WINDOW_TYPE_HINT_TOOLTIP);
        gtk_window_set_resizable (GTK_WINDOW (tip), FALSE);
        gtk_window_set_gravity (GTK_WINDOW (tip), GDK_GRAVITY_NORTH_WEST);
-       gtk_window_set_screen (GTK_WINDOW (tip), gtk_widget_get_screen (ref_widget));
-
-       frame = gtk_widget_get_toplevel (widget);
+       gtk_window_set_screen (GTK_WINDOW (tip), screen);
+       gtk_widget_set_name (tip, "gtk-tooltip");
 
+       frame = gtk_frame_new (NULL);
+       gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+       gtk_widget_show (frame);
+       gtk_container_add (GTK_CONTAINER (frame), widget);
        gtk_container_add (GTK_CONTAINER (tip), frame);
 
-       gnumeric_tooltip_set_style (frame);
        gnumeric_tooltip_set_style (tip);
 
        return widget;
@@ -567,7 +538,7 @@ gnumeric_convert_to_tooltip (GtkWidget *ref_widget, GtkWidget *widget)
 GtkWidget *
 gnumeric_create_tooltip (GtkWidget *ref_widget)
 {
-       return gnumeric_convert_to_tooltip (ref_widget, gnumeric_create_tooltip_widget ());
+       return gnumeric_convert_to_tooltip (ref_widget, gtk_label_new (""));
 }
 
 void
diff --git a/src/gui-util.h b/src/gui-util.h
index 326b4b5..da14707 100644
--- a/src/gui-util.h
+++ b/src/gui-util.h
@@ -40,8 +40,6 @@ void gnumeric_popup_menu (GtkMenu *menu, GdkEventButton *event);
  */
 void        gnumeric_position_tooltip (GtkWidget *tip, int px, int py,
                                       gboolean horizontal);
-GtkWidget  *gnumeric_create_tooltip_widget (void);
-GtkWidget  *gnumeric_create_tooltip_text_view_widget (void);
 GtkWidget  *gnumeric_create_tooltip (GtkWidget *ref_widget);
 GtkWidget  *gnumeric_convert_to_tooltip (GtkWidget *ref_widget,
                                         GtkWidget *widget);
diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c
index 0b1bc8e..c9948b0 100644
--- a/src/widgets/gnumeric-expr-entry.c
+++ b/src/widgets/gnumeric-expr-entry.c
@@ -805,7 +805,7 @@ gee_create_tooltip (GnmExprEntry *gee, gchar const *str,
                        (G_OBJECT (toplevel), "focus-out-event",
                         G_CALLBACK (cb_gee_focus_out_event), gee);
 
-       label = gnumeric_convert_to_tooltip (toplevel, gnumeric_create_tooltip_text_view_widget ());
+       label = gnumeric_convert_to_tooltip (toplevel, gtk_text_view_new ());
        tip = gtk_widget_get_toplevel (label);
 
        if (str)


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