[gimp/gtk3-port: 398/451] app: undeprecate about-dialog.c, and clean out a lot of cruft



commit dce2d8e0222f581a69c2e72d98228ca81a6277cf
Author: Michael Natterer <mitch gimp org>
Date:   Thu May 10 20:04:24 2018 +0200

    app: undeprecate about-dialog.c, and clean out a lot of cruft

 app/dialogs/about-dialog.c         |  158 ++++++++----------------------------
 app/dialogs/about-dialog.h         |    2 +-
 app/dialogs/dialogs-constructors.c |    2 +-
 3 files changed, 35 insertions(+), 127 deletions(-)
---
diff --git a/app/dialogs/about-dialog.c b/app/dialogs/about-dialog.c
index 2ec54fe..36d90e8 100644
--- a/app/dialogs/about-dialog.c
+++ b/app/dialogs/about-dialog.c
@@ -28,11 +28,6 @@
 
 #include "dialogs-types.h"
 
-#include "core/gimp.h"
-#include "core/gimpcontext.h"
-
-#include "pdb/gimppdb.h"
-
 #include "about.h"
 #include "git-version.h"
 
@@ -63,7 +58,6 @@ typedef struct
 
   gint         index;
   gint         animstep;
-  gint         textrange[2];
   gint         state;
   gboolean     visible;
 } GimpAboutDialog;
@@ -89,12 +83,10 @@ static void        about_dialog_add_unstable_message
 
 
 GtkWidget *
-about_dialog_create (GimpContext *context)
+about_dialog_create (void)
 {
   static GimpAboutDialog dialog;
 
-  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
-
   if (! dialog.dialog)
     {
       GtkWidget *widget;
@@ -283,17 +275,29 @@ about_dialog_anim_draw (GtkWidget       *widget,
   GtkStyleContext *style = gtk_widget_get_style_context (widget);
   GtkAllocation    allocation;
   GdkRGBA          color;
+  gdouble          alpha = 0.0;
   gint             x, y;
   gint             width, height;
 
   if (! dialog->visible)
     return FALSE;
 
-  gtk_style_context_save (style);
-  gtk_style_context_add_class (style, GTK_STYLE_CLASS_ENTRY);
-  gtk_style_context_get_color (style, 0, &color);
+  if (dialog->animstep < 16)
+    {
+      alpha = (gfloat) dialog->animstep / 15.0;
+    }
+  else if (dialog->animstep < 18)
+    {
+      alpha = 1.0;
+    }
+  else if (dialog->animstep < 33)
+    {
+      alpha = 1.0 - ((gfloat) (dialog->animstep - 17)) / 15.0;
+    }
+
+  gtk_style_context_get_color (style, gtk_style_context_get_state (style),
+                               &color);
   gdk_cairo_set_source_rgba (cr, &color);
-  gtk_style_context_restore (style);
 
   gtk_widget_get_allocation (widget, &allocation);
   pango_layout_get_pixel_size (dialog->layout, &width, &height);
@@ -301,24 +305,15 @@ about_dialog_anim_draw (GtkWidget       *widget,
   x = (allocation.width  - width)  / 2;
   y = (allocation.height - height) / 2;
 
-  if (dialog->textrange[1] > 0)
-    {
-      cairo_region_t *covered_region;
-
-      covered_region = gdk_pango_layout_get_clip_region (dialog->layout,
-                                                         x, y,
-                                                         dialog->textrange, 1);
-
-      gdk_cairo_region (cr, covered_region);
-      cairo_clip (cr);
-
-      cairo_region_destroy (covered_region);
-    }
-
   cairo_move_to (cr, x, y);
 
+  cairo_push_group (cr);
+
   pango_cairo_show_layout (cr, dialog->layout);
 
+  cairo_pop_group_to_source (cr);
+  cairo_paint_with_alpha (cr, alpha);
+
   return FALSE;
 }
 
@@ -345,77 +340,37 @@ insert_spacers (const gchar *string)
   return g_string_free (str, FALSE);
 }
 
-static inline void
-mix_colors (const GdkRGBA *start,
-            const GdkRGBA *end,
-            GdkRGBA       *target,
-            gdouble        pos)
-{
-  target->red   = start->red   * (1.0 - pos) + end->red   * pos;
-  target->green = start->green * (1.0 - pos) + end->green * pos;
-  target->blue  = start->blue  * (1.0 - pos) + end->blue  * pos;
-  target->alpha = start->alpha * (1.0 - pos) + end->alpha * pos;
-}
-
 static void
 decorate_text (GimpAboutDialog *dialog,
                gint             anim_type,
                gdouble          time)
 {
-  GtkStyleContext *style = gtk_widget_get_style_context (dialog->anim_area);
-  const gchar     *text;
-  const gchar     *ptr;
-  gint             letter_count = 0;
-  gint             text_length  = 0;
-  gint             text_bytelen = 0;
-  gint             cluster_start, cluster_end;
-  gunichar         unichr;
-  PangoAttrList   *attrlist = NULL;
-  PangoAttribute  *attr;
-  PangoRectangle   irect = {0, 0, 0, 0};
-  PangoRectangle   lrect = {0, 0, 0, 0};
-  GdkRGBA          fg;
-  GdkRGBA          bg;
-  GdkRGBA          mix;
-
-  gtk_style_context_get_color (style, 0, &fg);
-  gtk_style_context_get_background_color (style, 0, &bg);
-
-  mix_colors (&bg, &fg, &mix, time);
+  const gchar    *text;
+  const gchar    *ptr;
+  gint            letter_count = 0;
+  gint            cluster_start, cluster_end;
+  gunichar        unichr;
+  PangoAttrList  *attrlist = NULL;
+  PangoAttribute *attr;
+  PangoRectangle  irect = {0, 0, 0, 0};
+  PangoRectangle  lrect = {0, 0, 0, 0};
 
   text = pango_layout_get_text (dialog->layout);
-  g_return_if_fail (text != NULL);
 
-  text_length = g_utf8_strlen (text, -1);
-  text_bytelen = strlen (text);
+  g_return_if_fail (text != NULL);
 
   attrlist = pango_attr_list_new ();
 
-  dialog->textrange[0] = 0;
-  dialog->textrange[1] = text_bytelen;
-
   switch (anim_type)
     {
     case 0: /* Fade in */
-      attr = pango_attr_foreground_new (mix.red   * 0xffff,
-                                        mix.green * 0xffff,
-                                        mix.blue  * 0xffff);
-      attr->start_index = 0;
-      attr->end_index = text_bytelen;
-      pango_attr_list_insert (attrlist, attr);
       break;
 
     case 1: /* Fade in, spread */
-      attr = pango_attr_foreground_new (mix.red   * 0xffff,
-                                        mix.green * 0xffff,
-                                        mix.blue  * 0xffff);
-      attr->start_index = 0;
-      attr->end_index = text_bytelen;
-      pango_attr_list_change (attrlist, attr);
-
       ptr = text;
 
       cluster_start = 0;
+
       while ((unichr = g_utf8_get_char (ptr)))
         {
           ptr = g_utf8_next_char (ptr);
@@ -434,13 +389,6 @@ decorate_text (GimpAboutDialog *dialog,
       break;
 
     case 2: /* Fade in, sinewave */
-      attr = pango_attr_foreground_new (mix.red   * 0xffff,
-                                        mix.green * 0xffff,
-                                        mix.blue  * 0xffff);
-      attr->start_index = 0;
-      attr->end_index = text_bytelen;
-      pango_attr_list_change (attrlist, attr);
-
       ptr = text;
 
       cluster_start = 0;
@@ -465,46 +413,6 @@ decorate_text (GimpAboutDialog *dialog,
         }
       break;
 
-    case 3: /* letterwise Fade in */
-      ptr = text;
-
-      letter_count  = 0;
-      cluster_start = 0;
-
-      while ((unichr = g_utf8_get_char (ptr)))
-        {
-          gint    border = (text_length + 15) * time - 15;
-          gdouble pos;
-
-          if (letter_count < border)
-            pos = 0;
-          else if (letter_count > border + 15)
-            pos = 1;
-          else
-            pos = ((gdouble) (letter_count - border)) / 15;
-
-          mix_colors (&fg, &bg, &mix, pos);
-
-          ptr = g_utf8_next_char (ptr);
-
-          cluster_end = ptr - text;
-
-          attr = pango_attr_foreground_new (mix.red   * 0xffff,
-                                            mix.green * 0xffff,
-                                            mix.blue  * 0xffff);
-          attr->start_index = cluster_start;
-          attr->end_index = cluster_end;
-          pango_attr_list_change (attrlist, attr);
-
-          if (pos < 1.0)
-            dialog->textrange[1] = cluster_end;
-
-          letter_count++;
-          cluster_start = cluster_end;
-        }
-
-      break;
-
     default:
       g_printerr ("Unknown animation type %d\n", anim_type);
     }
diff --git a/app/dialogs/about-dialog.h b/app/dialogs/about-dialog.h
index 5c7cd09..02c489c 100644
--- a/app/dialogs/about-dialog.h
+++ b/app/dialogs/about-dialog.h
@@ -19,7 +19,7 @@
 #define __ABOUT_DIALOG_H__
 
 
-GtkWidget * about_dialog_create (GimpContext *context);
+GtkWidget * about_dialog_create (void);
 
 
 #endif /* __ABOUT_DIALOG_H__ */
diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c
index 07b93ba..3788f45 100644
--- a/app/dialogs/dialogs-constructors.c
+++ b/app/dialogs/dialogs-constructors.c
@@ -195,7 +195,7 @@ dialogs_about_get (GimpDialogFactory *factory,
                    GimpUIManager     *ui_manager,
                    gint               view_size)
 {
-  return about_dialog_create (context);
+  return about_dialog_create ();
 }
 
 GtkWidget *


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