[gimp/gtk3-port: 226/226] foo



commit e47ab4c9e0bbdf1cece4f911b26c4a4ad548d81e
Author: Michael Natterer <mitch gimp org>
Date:   Tue Feb 21 01:15:47 2012 +0100

    foo

 Makefile.am                    |    2 +-
 app/display/gimpdisplayshell.c |   26 +++--
 app/widgets/gimpsessioninfo.c  |   14 ++--
 app/widgets/gimpspinscale.c    |  228 +++++++++++++++++++++++++++++++---------
 plug-ins/Makefile.am           |    8 +-
 plug-ins/common/Makefile.am    |    4 +-
 6 files changed, 208 insertions(+), 74 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 53b4ca7..48f653d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,7 +28,7 @@ SUBDIRS = \
 	$(GIMP_MODULES)	\
 	$(GIMP_PLUGINS)	\
 	etc		\
-	devel-docs	\
+##	devel-docs	\
 	docs		\
 	build
 
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index b954bdd..82b5857 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -173,14 +173,6 @@ G_DEFINE_TYPE_WITH_CODE (GimpDisplayShell, gimp_display_shell,
 static guint display_shell_signals[LAST_SIGNAL] = { 0 };
 
 
-static const gchar display_rc_style[] =
-  "style \"check-button-style\"\n"
-  "{\n"
-  "  GtkToggleButton::child-displacement-x = 0\n"
-  "  GtkToggleButton::child-displacement-y = 0\n"
-  "}\n"
-  "widget \"*\" style \"check-button-style\"";
-
 static void
 gimp_display_shell_class_init (GimpDisplayShellClass *klass)
 {
@@ -262,8 +254,6 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
                                    g_param_spec_object ("icon", NULL, NULL,
                                                         GDK_TYPE_PIXBUF,
                                                         GIMP_PARAM_READWRITE));
-
-  gtk_rc_parse_string (display_rc_style);
 }
 
 static void
@@ -275,9 +265,25 @@ gimp_color_managed_iface_init (GimpColorManagedInterface *iface)
 static void
 gimp_display_shell_init (GimpDisplayShell *shell)
 {
+  GtkCssProvider *css;
+  const gchar    *str;
+
   gtk_orientable_set_orientation (GTK_ORIENTABLE (shell),
                                   GTK_ORIENTATION_VERTICAL);
 
+  str =
+    "GimpDisplayShell GtkCheckButton {\n"
+    "    -GtkButton-child-displacement-x: 0;\n"
+    "    -GtkButton-child-displacement-y: 0;\n"
+    "}\n";
+
+  css = gtk_css_provider_new ();
+  gtk_css_provider_load_from_data (css, str, -1, NULL);
+  gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (shell)),
+                                  GTK_STYLE_PROVIDER (css),
+                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  g_object_unref (css);
+
   shell->options            = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS, NULL);
   shell->fullscreen_options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN, NULL);
   shell->no_image_options   = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_NO_IMAGE, NULL);
diff --git a/app/widgets/gimpsessioninfo.c b/app/widgets/gimpsessioninfo.c
index 1403566..8c83bab 100644
--- a/app/widgets/gimpsessioninfo.c
+++ b/app/widgets/gimpsessioninfo.c
@@ -44,7 +44,7 @@
 #include "gimpsessioninfo-dock.h"
 #include "gimpsessioninfo-private.h"
 #include "gimpsessionmanaged.h"
- 
+
 #include "gimp-log.h"
 
 
@@ -496,14 +496,14 @@ gimp_session_info_restore_docks (GimpRestoreDocksData *data)
                 }
             }
         }
-
-      g_object_unref (dialog);
-      g_object_unref (screen);
-      g_object_unref (factory);
-      g_object_unref (info);
-      g_slice_free (GimpRestoreDocksData, data);
     }
 
+  g_object_unref (dialog);
+  g_object_unref (screen);
+  g_object_unref (factory);
+  g_object_unref (info);
+  g_slice_free (GimpRestoreDocksData, data);
+
   gimp_session_info_clear_info (info);
 
   return FALSE;
diff --git a/app/widgets/gimpspinscale.c b/app/widgets/gimpspinscale.c
index 43bb9ad..35babcc 100644
--- a/app/widgets/gimpspinscale.c
+++ b/app/widgets/gimpspinscale.c
@@ -79,6 +79,9 @@ static void       gimp_spin_scale_get_property   (GObject          *object,
                                                   GValue           *value,
                                                   GParamSpec       *pspec);
 
+static void       gimp_spin_scale_get_height     (GtkWidget        *widget,
+                                                  gint             *minimum,
+                                                  gint             *natural);
 static void       gimp_spin_scale_style_updated  (GtkWidget        *widget);
 static gboolean   gimp_spin_scale_draw           (GtkWidget        *widget,
                                                   cairo_t          *cr);
@@ -91,6 +94,12 @@ static gboolean   gimp_spin_scale_motion_notify  (GtkWidget        *widget,
 static gboolean   gimp_spin_scale_leave_notify   (GtkWidget        *widget,
                                                   GdkEventCrossing *event);
 
+static void       gimp_spin_scale_get_text_area  (GtkEntry         *entry,
+                                                  gint             *x,
+                                                  gint             *y,
+                                                  gint             *width,
+                                                  gint             *height);
+
 static void       gimp_spin_scale_value_changed  (GtkSpinButton    *spin_button);
 
 
@@ -104,6 +113,7 @@ gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
 {
   GObjectClass       *object_class      = G_OBJECT_CLASS (klass);
   GtkWidgetClass     *widget_class      = GTK_WIDGET_CLASS (klass);
+  GtkEntryClass      *entry_class       = GTK_ENTRY_CLASS (klass);
   GtkSpinButtonClass *spin_button_class = GTK_SPIN_BUTTON_CLASS (klass);
 
   object_class->dispose              = gimp_spin_scale_dispose;
@@ -111,6 +121,7 @@ gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
   object_class->set_property         = gimp_spin_scale_set_property;
   object_class->get_property         = gimp_spin_scale_get_property;
 
+  widget_class->get_preferred_height = gimp_spin_scale_get_height;
   widget_class->style_updated        = gimp_spin_scale_style_updated;
   widget_class->draw                 = gimp_spin_scale_draw;
   widget_class->button_press_event   = gimp_spin_scale_button_press;
@@ -118,6 +129,8 @@ gimp_spin_scale_class_init (GimpSpinScaleClass *klass)
   widget_class->motion_notify_event  = gimp_spin_scale_motion_notify;
   widget_class->leave_notify_event   = gimp_spin_scale_leave_notify;
 
+  entry_class->get_text_area_size    = gimp_spin_scale_get_text_area;
+
   spin_button_class->value_changed   = gimp_spin_scale_value_changed;
 
   g_object_class_install_property (object_class, PROP_LABEL,
@@ -132,7 +145,6 @@ static void
 gimp_spin_scale_init (GimpSpinScale *scale)
 {
   gtk_entry_set_alignment (GTK_ENTRY (scale), 1.0);
-  gtk_entry_set_has_frame (GTK_ENTRY (scale), FALSE);
   gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (scale), TRUE);
 }
 
@@ -207,30 +219,34 @@ gimp_spin_scale_get_property (GObject    *object,
 }
 
 static void
-gimp_spin_scale_style_updated (GtkWidget *widget)
+gimp_spin_scale_get_height (GtkWidget *widget,
+                            gint      *minimum,
+                            gint      *natural)
 {
-  GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-  PangoContext         *context = gtk_widget_get_pango_context (widget);
-  PangoFontMetrics     *metrics;
-  gint                  height;
-  GtkBorder             border;
+  PangoContext     *context = gtk_widget_get_pango_context (widget);
+  PangoFontMetrics *metrics;
+  gint              height;
 
-  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (parent_class)->get_preferred_height (widget,
+                                                         minimum, natural);
 
   metrics = pango_context_get_metrics (context,
                                        pango_context_get_font_description (context),
                                        pango_context_get_language (context));
 
-  height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics));
+  height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
+                         pango_font_metrics_get_descent (metrics));
 
-  pango_font_metrics_unref (metrics);
+  *minimum += height;
+  *natural += height;
+}
 
-  border.left   = 2;
-  border.right  = 2;
-  border.top    = height + 2;
-  border.bottom = 2;
+static void
+gimp_spin_scale_style_updated (GtkWidget *widget)
+{
+  GimpSpinScalePrivate *private = GET_PRIVATE (widget);
 
-  gtk_entry_set_inner_border (GTK_ENTRY (widget), &border);
+  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
 
   if (private->layout)
     {
@@ -239,37 +255,60 @@ gimp_spin_scale_style_updated (GtkWidget *widget)
     }
 }
 
+static void
+get_border (GtkWidget *widget,
+            GtkBorder *border)
+{
+  GtkStyleContext *context = gtk_widget_get_style_context (widget);
+  gint             focus_width;
+  gboolean         interior_focus;
+
+  gtk_style_context_get_padding (context, 0, border);
+
+  if (gtk_entry_get_has_frame (GTK_ENTRY (widget)))
+    {
+      GtkBorder tmp;
+
+      gtk_style_context_get_border (context, 0, &tmp);
+
+      border->top    += tmp.top;
+      border->right  += tmp.right;
+      border->bottom += tmp.bottom;
+      border->left   += tmp.left;
+    }
+
+  gtk_widget_style_get (widget,
+                        "focus-line-width", &focus_width,
+                        "interior-focus",   &interior_focus,
+                        NULL);
+
+  if (! interior_focus)
+    {
+      border->top    += focus_width;
+      border->right  += focus_width;
+      border->bottom += focus_width;
+      border->left   += focus_width;
+    }
+}
+
 static gboolean
 gimp_spin_scale_draw (GtkWidget *widget,
                       cairo_t   *cr)
 {
   GimpSpinScalePrivate *private = GET_PRIVATE (widget);
-  GtkStyleContext      *style   = gtk_widget_get_style_context (widget);
-  GtkAllocation         allocation;
-  GdkRGBA               color;
-  gboolean              rtl;
 
   cairo_save (cr);
   GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
   cairo_restore (cr);
 
-  rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
-
-  gtk_widget_get_allocation (widget, &allocation);
-
-  cairo_set_line_width (cr, 1.0);
-
-  cairo_rectangle (cr, 0.5, 0.5,
-                   allocation.width - 1.0, allocation.height - 1.0);
-  gtk_style_context_get_color (style, gtk_widget_get_state_flags (widget),
-                               &color);
-  gdk_cairo_set_source_rgba (cr, &color);
-  cairo_stroke (cr);
-
   if (private->label)
     {
-      const GtkBorder *border;
-      gint             layout_width;
+      GtkAllocation allocation;
+      GtkBorder     border;
+      gint          layout_width;
+
+      gtk_widget_get_allocation (widget, &allocation);
+      get_border (widget, &border);
 
       if (! private->layout)
         private->layout = gtk_widget_create_pango_layout (widget,
@@ -277,22 +316,14 @@ gimp_spin_scale_draw (GtkWidget *widget,
 
       pango_layout_get_pixel_size (private->layout, &layout_width, NULL);
 
-      border = gtk_entry_get_inner_border (GTK_ENTRY (widget));
-
       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
         {
-          if (border)
-            cairo_move_to (cr, allocation.width - layout_width - border->right,
-                           border->right /* sic! */);
-          else
-            cairo_move_to (cr, allocation.width - layout_width - 2, 2);
+          cairo_move_to (cr, allocation.width - layout_width - border.right,
+                         border.top);
         }
       else
         {
-          if (border)
-            cairo_move_to (cr, border->left, border->left /* sic! */);
-          else
-            cairo_move_to (cr, 2, 2);
+          cairo_move_to (cr, border.left, border.top);
         }
 
       pango_cairo_show_layout (cr, private->layout);
@@ -365,17 +396,89 @@ gimp_spin_scale_event_to_widget_coords (GtkWidget *widget,
   *widget_y = event_y;
 }
 
+static void
+get_progress_area (GtkWidget *widget,
+                   gint       *x,
+                   gint       *y,
+                   gint       *width,
+                   gint       *height)
+{
+  GtkEntry        *entry = GTK_ENTRY (widget);
+  GtkStyleContext *context;
+  GtkAllocation    allocation;
+  GtkBorder        margin, entry_borders;
+  GdkRectangle     text_area;
+  gint             focus_width;
+  gboolean         interior_focus;
+
+  context = gtk_widget_get_style_context (widget);
+  gtk_widget_get_allocation (widget, &allocation);
+  get_border (widget, &entry_borders);
+  gtk_entry_get_text_area (entry, &text_area);
+
+  *width = text_area.width;
+  *height = text_area.height;
+
+  *width += entry_borders.left + entry_borders.right;
+  *height += entry_borders.top + entry_borders.bottom;
+  *y = 0;
+
+  if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
+    *x = text_area.x;
+  else
+    *x = 0;
+
+  gtk_widget_style_get (widget,
+                        "focus-line-width", &focus_width,
+                        "interior-focus",   &interior_focus,
+                        NULL);
+
+  if (!interior_focus)
+    {
+      *x -= focus_width;
+      *y -= focus_width;
+    }
+
+  /* if the text area got resized by a subclass, subtract the left/right
+   * border width, as the progress bar won't extend over the resized
+   * text area.
+   */
+  if (*width != allocation.width)
+    {
+      gtk_style_context_get_border (context, 0, &entry_borders);
+      if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
+        *width -= entry_borders.left;
+      else
+        *width -= entry_borders.right;
+    }
+
+  gtk_style_context_save (context);
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+  gtk_style_context_get_margin (context, 0, &margin);
+  gtk_style_context_restore (context);
+
+  *x += margin.left;
+  *y += margin.top;
+  *width -= margin.left + margin.right;
+  *height -= margin.top + margin.bottom;
+}
+
 static SpinScaleTarget
 gimp_spin_scale_get_target (GtkWidget *widget,
                             gdouble    x,
                             gdouble    y)
 {
-  GdkRectangle text_area;
+  gint progress_x;
+  gint progress_y;
+  gint progress_width;
+  gint progress_height;
 
-  gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
+  get_progress_area (widget,
+                     &progress_x, &progress_y,
+                     &progress_width, &progress_height);
 
-  if (x >= text_area.x && x < text_area.width &&
-      y >= text_area.y && y < text_area.height)
+  if (x >= progress_x && x < progress_width &&
+      y >= progress_y && y < progress_height)
     {
       gint layout_x;
       gint layout_y;
@@ -386,7 +489,7 @@ gimp_spin_scale_get_target (GtkWidget *widget,
         {
           return TARGET_NUMBER;
         }
-      else if (y > text_area.height / 2)
+      else if (y > progress_height / 2)
         {
           return TARGET_LOWER;
         }
@@ -594,6 +697,31 @@ gimp_spin_scale_leave_notify (GtkWidget        *widget,
 }
 
 static void
+gimp_spin_scale_get_text_area (GtkEntry *entry,
+                               gint     *x,
+                               gint     *y,
+                               gint     *width,
+                               gint     *height)
+{
+  PangoContext     *context;
+  PangoFontMetrics *metrics;
+  gint              ascent;
+
+  GTK_ENTRY_CLASS (parent_class)->get_text_area_size (entry, x, y, width, height);
+
+  context = gtk_widget_get_pango_context (GTK_WIDGET (entry));
+  metrics = pango_context_get_metrics (context,
+                                       pango_context_get_font_description (context),
+                                       pango_context_get_language (context));
+
+  ascent = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
+                         pango_font_metrics_get_descent (metrics));
+
+  if (y)
+    *y += ascent / 2;
+}
+
+static void
 gimp_spin_scale_value_changed (GtkSpinButton *spin_button)
 {
   GtkAdjustment *adjustment = gtk_spin_button_get_adjustment (spin_button);
diff --git a/plug-ins/Makefile.am b/plug-ins/Makefile.am
index 676ded2..6d19b67 100644
--- a/plug-ins/Makefile.am
+++ b/plug-ins/Makefile.am
@@ -56,7 +56,7 @@ endif
 
 SUBDIRS = \
 	$(script_fu)		\
-	$(pygimp)		\
+##	$(pygimp)		\
 	color-rotate		\
 	file-bmp		\
 	$(file_compressor)	\
@@ -72,12 +72,12 @@ SUBDIRS = \
 	flame			\
 	fractal-explorer	\
 	gfig			\
-	gimpressionist		\
+##	gimpressionist		\
 	gradient-flare		\
 	help			\
 	$(help_browser)		\
-	ifs-compose		\
-	imagemap		\
+##	ifs-compose		\
+##	imagemap		\
 	lighting		\
 	map-object		\
 	maze			\
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index ac40506..3fddc92 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -46,7 +46,7 @@ libexec_PROGRAMS = \
 	alien-map \
 	align-layers \
 	animation-optimize \
-	animation-play \
+##	animation-play \
 	antialias \
 	apply-canvas \
 	blinds \
@@ -75,7 +75,7 @@ libexec_PROGRAMS = \
 	crop-auto \
 	crop-zealous \
 	cubism \
-	curve-bend \
+##	curve-bend \
 	decompose \
 	deinterlace \
 	depth-merge \



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