]> Pileus Git - ~andy/gtk/commitdiff
Make the arrow and separator regular children of an hbox inside the
authorMatthias Clasen <mclasen@redhat.com>
Wed, 14 Apr 2004 20:26:26 +0000 (20:26 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 14 Apr 2004 20:26:26 +0000 (20:26 +0000)
2004-04-14  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkcombobox.c: Make the arrow and separator regular
children of an hbox inside the button, and propagate state
changes from the button to the cell view.  (part of the fix
for #138650, should also fix #137535)

* gtk/gtkcellview.c (gtk_cell_view_expose): Pass the PRELIT
state to gtk_cell_renderer_render() when prelighted. (part
of the fix for #138650)

* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render):
Use PRELIGHT state when appropriate.  (part of the fix for
#138650)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcellrenderertext.c
gtk/gtkcellview.c
gtk/gtkcombobox.c

index 524a6aad2f65b39dc6a917894ad79b0d1c8773a4..63b88144472014662e7b3feb80de60cf24fd056e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2004-04-14  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c: Make the arrow and separator regular
+       children of an hbox inside the button, and propagate state
+       changes from the button to the cell view.  (part of the fix
+       for #138650, should also fix #137535)
+
+       * gtk/gtkcellview.c (gtk_cell_view_expose): Pass the PRELIT
+       state to gtk_cell_renderer_render() when prelighted. (part 
+       of the fix for #138650)
+
+       * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): 
+       Use PRELIGHT state when appropriate.  (part of the fix for 
+       #138650)
+
        * gtk/gtkcombobox.c (gtk_combo_box_relayout): Don't spit 
        out warnings if called before the combo box is 
        realized.  (#139742, Philip Langdale)
index 524a6aad2f65b39dc6a917894ad79b0d1c8773a4..63b88144472014662e7b3feb80de60cf24fd056e 100644 (file)
@@ -1,5 +1,18 @@
 2004-04-14  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c: Make the arrow and separator regular
+       children of an hbox inside the button, and propagate state
+       changes from the button to the cell view.  (part of the fix
+       for #138650, should also fix #137535)
+
+       * gtk/gtkcellview.c (gtk_cell_view_expose): Pass the PRELIT
+       state to gtk_cell_renderer_render() when prelighted. (part 
+       of the fix for #138650)
+
+       * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): 
+       Use PRELIGHT state when appropriate.  (part of the fix for 
+       #138650)
+
        * gtk/gtkcombobox.c (gtk_combo_box_relayout): Don't spit 
        out warnings if called before the combo box is 
        realized.  (#139742, Philip Langdale)
index 524a6aad2f65b39dc6a917894ad79b0d1c8773a4..63b88144472014662e7b3feb80de60cf24fd056e 100644 (file)
@@ -1,5 +1,18 @@
 2004-04-14  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c: Make the arrow and separator regular
+       children of an hbox inside the button, and propagate state
+       changes from the button to the cell view.  (part of the fix
+       for #138650, should also fix #137535)
+
+       * gtk/gtkcellview.c (gtk_cell_view_expose): Pass the PRELIT
+       state to gtk_cell_renderer_render() when prelighted. (part 
+       of the fix for #138650)
+
+       * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): 
+       Use PRELIGHT state when appropriate.  (part of the fix for 
+       #138650)
+
        * gtk/gtkcombobox.c (gtk_combo_box_relayout): Don't spit 
        out warnings if called before the combo box is 
        realized.  (#139742, Philip Langdale)
index 524a6aad2f65b39dc6a917894ad79b0d1c8773a4..63b88144472014662e7b3feb80de60cf24fd056e 100644 (file)
@@ -1,5 +1,18 @@
 2004-04-14  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c: Make the arrow and separator regular
+       children of an hbox inside the button, and propagate state
+       changes from the button to the cell view.  (part of the fix
+       for #138650, should also fix #137535)
+
+       * gtk/gtkcellview.c (gtk_cell_view_expose): Pass the PRELIT
+       state to gtk_cell_renderer_render() when prelighted. (part 
+       of the fix for #138650)
+
+       * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): 
+       Use PRELIGHT state when appropriate.  (part of the fix for 
+       #138650)
+
        * gtk/gtkcombobox.c (gtk_combo_box_relayout): Don't spit 
        out warnings if called before the combo box is 
        realized.  (#139742, Philip Langdale)
index 524a6aad2f65b39dc6a917894ad79b0d1c8773a4..63b88144472014662e7b3feb80de60cf24fd056e 100644 (file)
@@ -1,5 +1,18 @@
 2004-04-14  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkcombobox.c: Make the arrow and separator regular
+       children of an hbox inside the button, and propagate state
+       changes from the button to the cell view.  (part of the fix
+       for #138650, should also fix #137535)
+
+       * gtk/gtkcellview.c (gtk_cell_view_expose): Pass the PRELIT
+       state to gtk_cell_renderer_render() when prelighted. (part 
+       of the fix for #138650)
+
+       * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_render): 
+       Use PRELIGHT state when appropriate.  (part of the fix for 
+       #138650)
+
        * gtk/gtkcombobox.c (gtk_combo_box_relayout): Don't spit 
        out warnings if called before the combo box is 
        realized.  (#139742, Philip Langdale)
index 72031a244d58b9997275ad76616204e9083bc064..c3e090005717db726ab21e287794e4fabe37a170 100644 (file)
@@ -1382,6 +1382,11 @@ gtk_cell_renderer_text_render (GtkCellRenderer      *cell,
       else
        state = GTK_STATE_ACTIVE;
     }
+  else if ((flags & GTK_CELL_RENDERER_PRELIT) == GTK_CELL_RENDERER_PRELIT &&
+          GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT)
+    {
+      state = GTK_STATE_PRELIGHT;
+    }
   else
     {
       if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE)
index 1b44316e3339b7a016fc48f84457df57517f2b62..8ca33fd9989277cc05bc93693b8f7b0d81e071ae 100644 (file)
@@ -408,6 +408,7 @@ gtk_cell_view_expose (GtkWidget      *widget,
   GList *i;
   GtkCellView *cellview;
   GdkRectangle area;
+  GtkCellRendererState state;
   gboolean rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
 
   cellview = GTK_CELL_VIEW (widget);
@@ -450,6 +451,11 @@ gtk_cell_view_expose (GtkWidget      *widget,
   area.x = widget->allocation.x + (rtl ? widget->allocation.width : 0); 
   area.y = widget->allocation.y;
 
+  if (GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT)
+    state = GTK_CELL_RENDERER_PRELIT;
+  else
+    state = 0;
+      
   /* PACK_START */
   for (i = cellview->priv->cell_list; i; i = i->next)
     {
@@ -469,7 +475,7 @@ gtk_cell_view_expose (GtkWidget      *widget,
                                 event->window,
                                 widget,
                                 /* FIXME! */
-                                &area, &area, &event->area, 0);
+                                &area, &area, &event->area, state);
 
       if (!rtl)                                           
          area.x += info->real_width;
@@ -496,7 +502,7 @@ gtk_cell_view_expose (GtkWidget      *widget,
                                 widget->window,
                                 widget,
                                 /* FIXME ! */
-                                &area, &area, &event->area, 0);
+                                &area, &area, &event->area, state);
       if (rtl)
          area.x += info->real_width;
     }
index 759d5a089e94cf853e115f8f30fc4b77e7e24ea3..b72919c9a76f32cce4c6413dcdd025774e281b37 100644 (file)
@@ -28,6 +28,7 @@
 #include "gtkcellviewmenuitem.h"
 #include "gtkeventbox.h"
 #include "gtkframe.h"
+#include "gtkhbox.h"
 #include "gtkliststore.h"
 #include "gtkmain.h"
 #include "gtkmenu.h"
@@ -83,6 +84,7 @@ struct _GtkComboBoxPrivate
   GtkWidget *cell_view_frame;
 
   GtkWidget *button;
+  GtkWidget *box;
   GtkWidget *arrow;
   GtkWidget *separator;
 
@@ -335,6 +337,9 @@ static void     gtk_combo_box_menu_row_changed     (GtkTreeModel     *model,
 static gboolean gtk_combo_box_menu_key_press       (GtkWidget        *widget,
                                                    GdkEventKey      *event,
                                                    gpointer          data);
+static void     gtk_combo_box_menu_state_changed   (GtkWidget        *widget,
+                                                   GtkStateType      previous,
+                                                   gpointer          data);
 
 /* cell layout */
 static void     gtk_combo_box_cell_layout_pack_start         (GtkCellLayout         *layout,
@@ -715,15 +720,10 @@ gtk_combo_box_add (GtkContainer *container,
 
       if (!combo_box->priv->tree_view && combo_box->priv->separator)
         {
-          gtk_widget_unparent (combo_box->priv->separator);
+         gtk_container_remove (GTK_CONTAINER (combo_box->priv->separator->parent),
+                               combo_box->priv->separator);
          combo_box->priv->separator = NULL;
 
-          g_object_ref (G_OBJECT (combo_box->priv->arrow));
-          gtk_widget_unparent (combo_box->priv->arrow);
-          gtk_container_add (GTK_CONTAINER (combo_box->priv->button),
-                             combo_box->priv->arrow);
-          g_object_unref (G_OBJECT (combo_box->priv->arrow));
-
           gtk_widget_queue_resize (GTK_WIDGET (container));
         }
       else if (combo_box->priv->cell_view_frame)
@@ -1502,6 +1502,8 @@ gtk_combo_box_forall (GtkContainer *container,
     {
       if (combo_box->priv->button)
        (* callback) (combo_box->priv->button, callback_data);
+      if (combo_box->priv->box)
+       (* callback) (combo_box->priv->box, callback_data);
       if (combo_box->priv->separator)
        (* callback) (combo_box->priv->separator, callback_data);
       if (combo_box->priv->arrow)
@@ -1524,16 +1526,6 @@ gtk_combo_box_expose_event (GtkWidget      *widget,
     {
       gtk_container_propagate_expose (GTK_CONTAINER (widget),
                                       combo_box->priv->button, event);
-
-      if (combo_box->priv->separator)
-        {
-          gtk_container_propagate_expose (GTK_CONTAINER (combo_box->priv->button),
-                                          combo_box->priv->separator, event);
-
-          /* if not in this case, arrow gets its expose event from button */
-          gtk_container_propagate_expose (GTK_CONTAINER (combo_box->priv->button),
-                                          combo_box->priv->arrow, event);
-        }
     }
   else
     {
@@ -1616,7 +1608,7 @@ static void
 gtk_combo_box_menu_setup (GtkComboBox *combo_box,
                           gboolean     add_children)
 {
-  GtkWidget *box;
+  GtkWidget *menu;
 
   if (combo_box->priv->cell_view)
     {
@@ -1628,23 +1620,19 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
       gtk_widget_set_parent (combo_box->priv->button,
                              GTK_BIN (combo_box)->child->parent);
 
+      combo_box->priv->box = gtk_hbox_new (FALSE, 0);
+      gtk_container_add (GTK_CONTAINER (combo_box->priv->button), 
+                        combo_box->priv->box);
+
       combo_box->priv->separator = gtk_vseparator_new ();
-      gtk_widget_set_parent (combo_box->priv->separator,
-                             combo_box->priv->button);
-      gtk_widget_show (combo_box->priv->separator);
+      gtk_container_add (GTK_CONTAINER (combo_box->priv->box), 
+                        combo_box->priv->separator);
 
       combo_box->priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
-      gtk_widget_set_parent (combo_box->priv->arrow, combo_box->priv->button);
-      gtk_widget_show (combo_box->priv->arrow);
+      gtk_container_add (GTK_CONTAINER (combo_box->priv->box), 
+                        combo_box->priv->arrow);
 
       gtk_widget_show_all (combo_box->priv->button);
-
-      if (GTK_WIDGET_MAPPED (GTK_BIN (combo_box)->child))
-        {
-          /* I have no clue why, but we need to manually map in this case. */
-          gtk_widget_map (combo_box->priv->separator);
-          gtk_widget_map (combo_box->priv->arrow);
-        }
     }
   else
     {
@@ -1665,12 +1653,15 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
   g_signal_connect (combo_box->priv->button, "button_press_event",
                     G_CALLBACK (gtk_combo_box_menu_button_press),
                     combo_box);
+  g_signal_connect (combo_box->priv->button, "state_changed",
+                   G_CALLBACK (gtk_combo_box_menu_state_changed), 
+                   combo_box);
 
   /* create our funky menu */
-  box = gtk_menu_new ();
-  g_signal_connect (box, "key_press_event",
+  menu = gtk_menu_new ();
+  g_signal_connect (menu, "key_press_event",
                    G_CALLBACK (gtk_combo_box_menu_key_press), combo_box);
-  gtk_combo_box_set_popup_widget (combo_box, box);
+  gtk_combo_box_set_popup_widget (combo_box, menu);
 
   /* add items */
   if (add_children)
@@ -1723,27 +1714,18 @@ gtk_combo_box_menu_destroy (GtkComboBox *combo_box)
                                         G_SIGNAL_MATCH_DATA,
                                         0, 0, NULL,
                                         gtk_combo_box_menu_button_press, NULL);
+  g_signal_handlers_disconnect_matched (combo_box->priv->button,
+                                        G_SIGNAL_MATCH_DATA,
+                                        0, 0, NULL,
+                                        gtk_combo_box_menu_state_changed, NULL);
 
   /* unparent will remove our latest ref */
-  if (combo_box->priv->cell_view)
-    {
-      gtk_widget_unparent (combo_box->priv->arrow);
-      combo_box->priv->arrow = NULL;
-
-      gtk_widget_unparent (combo_box->priv->separator);
-      combo_box->priv->separator = NULL;
-
-      gtk_widget_unparent (combo_box->priv->button);
-      combo_box->priv->button = NULL;
-    }
-  else
-    {
-      /* will destroy the arrow too */
-      gtk_widget_unparent (combo_box->priv->button);
-
-      combo_box->priv->button = NULL;
-      combo_box->priv->arrow = NULL;
-    }
+  gtk_widget_unparent (combo_box->priv->button);
+  
+  combo_box->priv->box = NULL;
+  combo_box->priv->button = NULL;
+  combo_box->priv->arrow = NULL;
+  combo_box->priv->separator = NULL;
 
   /* changing the popup window will unref the menu and the children */
 }
@@ -1919,6 +1901,22 @@ gtk_combo_box_menu_button_press (GtkWidget      *widget,
   return FALSE;
 }
 
+static void
+gtk_combo_box_menu_state_changed (GtkWidget    *widget,
+                                 GtkStateType  previous,
+                                 gpointer      user_data)
+{
+  GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+
+  if (combo_box->priv->cell_view)
+    {
+      gtk_widget_set_state (combo_box->priv->cell_view, 
+                           GTK_WIDGET_STATE (widget));
+      
+      gtk_widget_queue_draw (combo_box->priv->cell_view);
+    }
+}
+
 static void
 gtk_combo_box_menu_item_activate (GtkWidget *item,
                                   gpointer   user_data)
@@ -2241,7 +2239,10 @@ gtk_combo_box_list_destroy (GtkComboBox *combo_box)
       g_object_set (G_OBJECT (combo_box->priv->cell_view),
                     "background_set", FALSE,
                     NULL);
+    }
 
+  if (combo_box->priv->cell_view_frame)
+    {
       gtk_widget_unparent (combo_box->priv->cell_view_frame);
       combo_box->priv->cell_view_frame = NULL;
     }