]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkinfobar.c
gtk: remove "gboolean homogeneous" from gtk_box_new()
[~andy/gtk] / gtk / gtkinfobar.c
index 568bd798ef24b4f3b9ee4333b72d3ec910709f7c..86859786e05d4a02021c93efba947a0bf2e2941e 100644 (file)
@@ -47,8 +47,6 @@
 #include "gtkprivate.h"
 #include "gtkstock.h"
 #include "gdkkeysyms.h"
-#include "gtkalias.h"
-
 
 /**
  * SECTION:gtkinfobar
  * </refsect2>
  */
 
-#define GTK_INFO_BAR_GET_PRIVATE(object) \
-  (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
-                                GTK_TYPE_INFO_BAR, \
-                                GtkInfoBarPrivate))
-
 enum
 {
   PROP_0,
@@ -166,8 +159,8 @@ static void     gtk_info_bar_get_property (GObject        *object,
                                            GParamSpec     *pspec);
 static void     gtk_info_bar_style_set    (GtkWidget      *widget,
                                            GtkStyle       *prev_style);
-static gboolean gtk_info_bar_expose       (GtkWidget      *widget,
-                                           GdkEventExpose *event);
+static gboolean gtk_info_bar_draw         (GtkWidget      *widget,
+                                           cairo_t        *cr);
 static void     gtk_info_bar_buildable_interface_init     (GtkBuildableIface *iface);
 static GObject *gtk_info_bar_buildable_get_internal_child (GtkBuildable  *buildable,
                                                            GtkBuilder    *builder,
@@ -199,7 +192,7 @@ gtk_info_bar_set_property (GObject      *object,
   GtkInfoBarPrivate *priv;
 
   info_bar = GTK_INFO_BAR (object);
-  priv = GTK_INFO_BAR_GET_PRIVATE (info_bar);
+  priv = info_bar->priv;
 
   switch (prop_id)
     {
@@ -222,7 +215,7 @@ gtk_info_bar_get_property (GObject    *object,
   GtkInfoBarPrivate *priv;
 
   info_bar = GTK_INFO_BAR (object);
-  priv = GTK_INFO_BAR_GET_PRIVATE (info_bar);
+  priv = info_bar->priv;
 
   switch (prop_id)
     {
@@ -303,10 +296,10 @@ gtk_info_bar_close (GtkInfoBar *info_bar)
 }
 
 static gboolean
-gtk_info_bar_expose (GtkWidget      *widget,
-                     GdkEventExpose *event)
+gtk_info_bar_draw (GtkWidget      *widget,
+                   cairo_t        *cr)
 {
-  GtkInfoBarPrivate *priv = GTK_INFO_BAR_GET_PRIVATE (widget);
+  GtkInfoBarPrivate *priv = GTK_INFO_BAR (widget)->priv;
   const char* type_detail[] = {
     "infobar-info",
     "infobar-warning",
@@ -321,21 +314,19 @@ gtk_info_bar_expose (GtkWidget      *widget,
 
       detail = type_detail[priv->message_type];
 
-      gtk_paint_box (widget->style,
-                     widget->window,
+      gtk_paint_box (gtk_widget_get_style (widget),
+                     cr,
                      GTK_STATE_NORMAL,
                      GTK_SHADOW_OUT,
-                     NULL,
                      widget,
                      detail,
-                     widget->allocation.x,
-                     widget->allocation.y,
-                     widget->allocation.width + 1,
-                     widget->allocation.height + 1);
+                     0, 0,
+                     gtk_widget_get_allocated_width (widget),
+                     gtk_widget_get_allocated_height (widget));
     }
 
-  if (GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->expose_event)
-    GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->expose_event (widget, event);
+  if (GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->draw)
+    GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->draw (widget, cr);
 
   return FALSE;
 }
@@ -355,7 +346,7 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass)
   object_class->finalize = gtk_info_bar_finalize;
 
   widget_class->style_set = gtk_info_bar_style_set;
-  widget_class->expose_event = gtk_info_bar_expose;
+  widget_class->draw = gtk_info_bar_draw;
 
   klass->close = gtk_info_bar_close;
 
@@ -494,7 +485,7 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass)
 
   binding_set = gtk_binding_set_by_class (klass);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "close", 0);
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
 
   g_type_class_add_private (object_class, sizeof (GtkInfoBarPrivate));
 }
@@ -502,8 +493,8 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass)
 static void
 gtk_info_bar_update_colors (GtkInfoBar *info_bar)
 {
-  GtkWidget *widget = (GtkWidget*)info_bar;
-  GtkInfoBarPrivate *priv;
+  GtkWidget *widget = GTK_WIDGET (info_bar);
+  GtkInfoBarPrivate *priv = info_bar->priv;
   GdkColor info_default_border_color     = { 0, 0xb800, 0xad00, 0x9d00 };
   GdkColor info_default_fill_color       = { 0, 0xff00, 0xff00, 0xbf00 };
   GdkColor warning_default_border_color  = { 0, 0xb000, 0x7a00, 0x2b00 };
@@ -532,7 +523,6 @@ gtk_info_bar_update_colors (GtkInfoBar *info_bar)
     "other_bg_color"
   };
 
-  priv = GTK_INFO_BAR_GET_PRIVATE (info_bar);
   style = gtk_widget_get_style (widget);
 
   if (gtk_style_lookup_color (style, fg_color_name[priv->message_type], &sym_fg) &&
@@ -569,12 +559,17 @@ gtk_info_bar_update_colors (GtkInfoBar *info_bar)
           fg = &other_default_border_color;
           bg = &other_default_fill_color;
           break;
+
+        default:
+          g_assert_not_reached();
+          fg = NULL;
+          bg = NULL;
         }
     }
 
-  if (!gdk_color_equal (bg, &widget->style->bg[GTK_STATE_NORMAL]))
+  if (!gdk_color_equal (bg, &style->bg[GTK_STATE_NORMAL]))
     gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, bg);
-  if (!gdk_color_equal (fg, &widget->style->fg[GTK_STATE_NORMAL]))
+  if (!gdk_color_equal (fg, &style->fg[GTK_STATE_NORMAL]))
     gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, fg);
 }
 
@@ -613,18 +608,21 @@ gtk_info_bar_init (GtkInfoBar *info_bar)
 
   gtk_widget_push_composite_child ();
 
-  info_bar->priv = GTK_INFO_BAR_GET_PRIVATE (info_bar);
+  info_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (info_bar,
+                                                GTK_TYPE_INFO_BAR,
+                                                GtkInfoBarPrivate);
 
-  content_area = gtk_hbox_new (FALSE, 0);
+  content_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
   gtk_widget_show (content_area);
   gtk_box_pack_start (GTK_BOX (info_bar), content_area, TRUE, TRUE, 0);
 
-  action_area = gtk_vbutton_box_new ();
+  action_area = gtk_button_box_new (GTK_ORIENTATION_VERTICAL);
   gtk_widget_show (action_area);
   gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area), GTK_BUTTONBOX_END);
   gtk_box_pack_start (GTK_BOX (info_bar), action_area, FALSE, TRUE, 0);
 
   gtk_widget_set_app_paintable (GTK_WIDGET (info_bar), TRUE);
+  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (info_bar), TRUE);
 
   info_bar->priv->content_area = content_area;
   info_bar->priv->action_area = action_area;
@@ -738,7 +736,7 @@ gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
  *
  * Returns the action area of @info_bar.
  *
- * Returns: the action area.
+ * Returns: (transfer none): the action area
  *
  * Since: 2.18
  */
@@ -756,7 +754,7 @@ gtk_info_bar_get_action_area (GtkInfoBar *info_bar)
  *
  * Returns the content area of @info_bar.
  *
- * Returns: the content area.
+ * Returns: (transfer none): the content area
  *
  * Since: 2.18
  */
@@ -780,7 +778,7 @@ gtk_info_bar_get_content_area (GtkInfoBar *info_bar)
  * to the end of the info bars's action area. The button widget is
  * returned, but usually you don't need it.
  *
- * Returns: the button widget that was added
+ * Returns: (transfer none): the button widget that was added
  *
  * Since: 2.18
  */
@@ -796,7 +794,7 @@ gtk_info_bar_add_button (GtkInfoBar  *info_bar,
 
   button = gtk_button_new_from_stock (button_text);
 
-  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+  gtk_widget_set_can_default (button, TRUE);
 
   gtk_widget_show (button);
 
@@ -876,7 +874,7 @@ gtk_info_bar_new (void)
 
 /**
  * gtk_info_bar_new_with_buttons:
- * @first_button_text: stock ID or text to go in first button, or %NULL
+ * @first_button_text: (allow-none): stock ID or text to go in first button, or %NULL
  * @...: response ID for first button, then additional buttons, ending
  *    with %NULL
  *
@@ -950,6 +948,9 @@ gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
  * the given response_id as the default widget for the dialog.
  * Pressing "Enter" normally activates the default widget.
  *
+ * Note that this function currently requires @info_bar to
+ * be added to a widget hierarchy. 
+ *
  * Since: 2.18
  */
 void
@@ -1175,7 +1176,7 @@ gtk_info_bar_set_message_type (GtkInfoBar     *info_bar,
 
   g_return_if_fail (GTK_IS_INFO_BAR (info_bar));
 
-  priv = GTK_INFO_BAR_GET_PRIVATE (info_bar);
+  priv = info_bar->priv;
 
   if (priv->message_type != message_type)
     {
@@ -1242,15 +1243,7 @@ gtk_info_bar_set_message_type (GtkInfoBar     *info_bar,
 GtkMessageType
 gtk_info_bar_get_message_type (GtkInfoBar *info_bar)
 {
-  GtkInfoBarPrivate *priv;
-
   g_return_val_if_fail (GTK_IS_INFO_BAR (info_bar), GTK_MESSAGE_OTHER);
 
-  priv = GTK_INFO_BAR_GET_PRIVATE (info_bar);
-
-  return priv->message_type;
+  return info_bar->priv->message_type;
 }
-
-
-#define __GTK_INFO_BAR_C__
-#include "gtkaliasdef.c"