]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkinfobar.c
Updated Slovenian translation
[~andy/gtk] / gtk / gtkinfobar.c
index db96dbb21921f50bc86386c5118f8b2a63b0ef66..87f6d3bc4e4ac09d7edd3ad570f34915c6905975 100644 (file)
@@ -36,8 +36,8 @@
 #include "gtkinfobar.h"
 #include "gtkaccessible.h"
 #include "gtkbuildable.h"
+#include "gtkbbox.h"
 #include "gtkbox.h"
-#include "gtkvbbox.h"
 #include "gtklabel.h"
 #include "gtkbutton.h"
 #include "gtkenums.h"
@@ -46,7 +46,8 @@
 #include "gtkintl.h"
 #include "gtkprivate.h"
 #include "gtkstock.h"
-#include "gdkkeysyms.h"
+#include "gtkorientable.h"
+#include "gtktypebuiltins.h"
 
 /**
  * SECTION:gtkinfobar
@@ -157,8 +158,7 @@ static void     gtk_info_bar_get_property (GObject        *object,
                                            guint           prop_id,
                                            GValue         *value,
                                            GParamSpec     *pspec);
-static void     gtk_info_bar_style_set    (GtkWidget      *widget,
-                                           GtkStyle       *prev_style);
+static void     gtk_info_bar_style_updated (GtkWidget      *widget);
 static gboolean gtk_info_bar_draw         (GtkWidget      *widget,
                                            cairo_t        *cr);
 static void     gtk_info_bar_buildable_interface_init     (GtkBuildableIface *iface);
@@ -178,7 +178,7 @@ static void      gtk_info_bar_buildable_custom_finished    (GtkBuildable  *build
                                                             gpointer       user_data);
 
 
-G_DEFINE_TYPE_WITH_CODE (GtkInfoBar, gtk_info_bar, GTK_TYPE_HBOX,
+G_DEFINE_TYPE_WITH_CODE (GtkInfoBar, gtk_info_bar, GTK_TYPE_BOX,
                          G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
                                                 gtk_info_bar_buildable_interface_init))
 
@@ -188,11 +188,7 @@ gtk_info_bar_set_property (GObject      *object,
                            const GValue *value,
                            GParamSpec   *pspec)
 {
-  GtkInfoBar *info_bar;
-  GtkInfoBarPrivate *priv;
-
-  info_bar = GTK_INFO_BAR (object);
-  priv = info_bar->priv;
+  GtkInfoBar *info_bar = GTK_INFO_BAR (object);
 
   switch (prop_id)
     {
@@ -211,11 +207,7 @@ gtk_info_bar_get_property (GObject    *object,
                            GValue     *value,
                            GParamSpec *pspec)
 {
-  GtkInfoBar *info_bar;
-  GtkInfoBarPrivate *priv;
-
-  info_bar = GTK_INFO_BAR (object);
-  priv = info_bar->priv;
+  GtkInfoBar *info_bar = GTK_INFO_BAR (object);
 
   switch (prop_id)
     {
@@ -300,29 +292,34 @@ gtk_info_bar_draw (GtkWidget      *widget,
                    cairo_t        *cr)
 {
   GtkInfoBarPrivate *priv = GTK_INFO_BAR (widget)->priv;
-  const char* type_detail[] = {
-    "infobar-info",
-    "infobar-warning",
-    "infobar-question",
-    "infobar-error",
-    "infobar"
+  const char* type_class[] = {
+    GTK_STYLE_CLASS_INFO,
+    GTK_STYLE_CLASS_WARNING,
+    GTK_STYLE_CLASS_QUESTION,
+    GTK_STYLE_CLASS_ERROR,
+    NULL
   };
 
   if (priv->message_type != GTK_MESSAGE_OTHER)
     {
-      const char *detail;
-
-      detail = type_detail[priv->message_type];
-
-      gtk_cairo_paint_box (gtk_widget_get_style (widget),
-                     cr,
-                     GTK_STATE_NORMAL,
-                     GTK_SHADOW_OUT,
-                     widget,
-                     detail,
-                     0, 0,
-                     gtk_widget_get_allocated_width (widget),
-                     gtk_widget_get_allocated_height (widget));
+      GtkStyleContext *context;
+
+      context = gtk_widget_get_style_context (widget);
+
+      gtk_style_context_save (context);
+
+      if (type_class[priv->message_type])
+        gtk_style_context_add_class (context,
+                                     type_class[priv->message_type]);
+
+      gtk_render_background (context, cr, 0, 0,
+                             gtk_widget_get_allocated_width (widget),
+                             gtk_widget_get_allocated_height (widget));
+      gtk_render_frame (context, cr, 0, 0,
+                        gtk_widget_get_allocated_width (widget),
+                        gtk_widget_get_allocated_height (widget));
+
+      gtk_style_context_restore (context);
     }
 
   if (GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->draw)
@@ -345,7 +342,7 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass)
   object_class->set_property = gtk_info_bar_set_property;
   object_class->finalize = gtk_info_bar_finalize;
 
-  widget_class->style_set = gtk_info_bar_style_set;
+  widget_class->style_updated = gtk_info_bar_style_updated;
   widget_class->draw = gtk_info_bar_draw;
 
   klass->close = gtk_info_bar_close;
@@ -491,91 +488,7 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass)
 }
 
 static void
-gtk_info_bar_update_colors (GtkInfoBar *info_bar)
-{
-  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 };
-  GdkColor warning_default_fill_color    = { 0, 0xfc00, 0xaf00, 0x3e00 };
-  GdkColor question_default_border_color = { 0, 0x6200, 0x7b00, 0xd960 };
-  GdkColor question_default_fill_color   = { 0, 0x8c00, 0xb000, 0xd700 };
-  GdkColor error_default_border_color    = { 0, 0xa800, 0x2700, 0x2700 };
-  GdkColor error_default_fill_color      = { 0, 0xf000, 0x3800, 0x3800 };
-  GdkColor other_default_border_color    = { 0, 0xb800, 0xad00, 0x9d00 };
-  GdkColor other_default_fill_color      = { 0, 0xff00, 0xff00, 0xbf00 };
-  GdkColor *fg, *bg;
-  GdkColor sym_fg, sym_bg;
-  GtkStyle *style;
-  const char* fg_color_name[] = {
-    "info_fg_color",
-    "warning_fg_color",
-    "question_fg_color",
-    "error_fg_color",
-    "other_fg_color"
-  };
-  const char* bg_color_name[] = {
-    "info_bg_color",
-    "warning_bg_color",
-    "question_bg_color",
-    "error_bg_color",
-    "other_bg_color"
-  };
-
-  style = gtk_widget_get_style (widget);
-
-  if (gtk_style_lookup_color (style, fg_color_name[priv->message_type], &sym_fg) &&
-      gtk_style_lookup_color (style, bg_color_name[priv->message_type], &sym_bg))
-    {
-      fg = &sym_fg;
-      bg = &sym_bg;
-    }
-  else
-    {
-      switch (priv->message_type)
-        {
-        case GTK_MESSAGE_INFO:
-          fg = &info_default_border_color;
-          bg = &info_default_fill_color;
-          break;
-
-        case GTK_MESSAGE_WARNING:
-          fg = &warning_default_border_color;
-          bg = &warning_default_fill_color;
-          break;
-
-        case GTK_MESSAGE_QUESTION:
-          fg = &question_default_border_color;
-          bg = &question_default_fill_color;
-          break;
-
-        case GTK_MESSAGE_ERROR:
-          fg = &error_default_border_color;
-          bg = &error_default_fill_color;
-          break;
-
-        case GTK_MESSAGE_OTHER:
-          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, &style->bg[GTK_STATE_NORMAL]))
-    gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, bg);
-  if (!gdk_color_equal (fg, &style->fg[GTK_STATE_NORMAL]))
-    gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, fg);
-}
-
-static void
-gtk_info_bar_style_set (GtkWidget *widget,
-                        GtkStyle  *prev_style)
+gtk_info_bar_style_updated (GtkWidget *widget)
 {
   GtkInfoBar *info_bar = GTK_INFO_BAR (widget);
   gint button_spacing;
@@ -583,6 +496,8 @@ gtk_info_bar_style_set (GtkWidget *widget,
   gint content_area_spacing;
   gint content_area_border;
 
+  GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->style_updated (widget);
+
   gtk_widget_style_get (widget,
                         "button-spacing", &button_spacing,
                         "action-area-border", &action_area_border,
@@ -596,13 +511,12 @@ gtk_info_bar_style_set (GtkWidget *widget,
   gtk_box_set_spacing (GTK_BOX (info_bar->priv->content_area), content_area_spacing);
   gtk_container_set_border_width (GTK_CONTAINER (info_bar->priv->content_area),
                                   content_area_border);
-
-  gtk_info_bar_update_colors (info_bar);
 }
 
 static void
 gtk_info_bar_init (GtkInfoBar *info_bar)
 {
+  GtkWidget *widget = GTK_WIDGET (info_bar);
   GtkWidget *content_area;
   GtkWidget *action_area;
 
@@ -612,22 +526,24 @@ gtk_info_bar_init (GtkInfoBar *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);
+  gtk_widget_set_app_paintable (widget, TRUE);
+  gtk_widget_set_redraw_on_allocate (widget, TRUE);
 
   info_bar->priv->content_area = content_area;
   info_bar->priv->action_area = action_area;
 
   gtk_widget_pop_composite_child ();
+
+  gtk_info_bar_style_updated (widget);
 }
 
 static GtkBuildableIface *parent_buildable_iface;
@@ -778,7 +694,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: (transfer none): the button widget that was added
+ * Returns: (transfer none): the #GtkButton widget that was added
  *
  * Since: 2.18
  */
@@ -1182,7 +1098,6 @@ gtk_info_bar_set_message_type (GtkInfoBar     *info_bar,
     {
       priv->message_type = message_type;
 
-      gtk_info_bar_update_colors (info_bar);
       gtk_widget_queue_draw (GTK_WIDGET (info_bar));
 
       atk_obj = gtk_widget_get_accessible (GTK_WIDGET (info_bar));