[glade/tintou/decrease-deprecation] Replace some functions by Gtk 3.22 ones



commit bc347902350e6b835123222a0638dff6529bc786
Author: Corentin Noël <corentin noel collabora com>
Date:   Mon Jun 3 10:27:41 2019 +0200

    Replace some functions by Gtk 3.22 ones
    
    And reduce the amount of deprecation warnings

 gladeui/glade-command.c                  |  6 +--
 gladeui/glade-editor-property.c          | 68 ++++++++++++++++++--------------
 plugins/gtk+/glade-attributes.c          | 14 +++----
 plugins/gtk+/glade-gtk-button.c          |  2 +-
 plugins/gtk+/glade-icon-factory-editor.c | 44 ++++++++++-----------
 5 files changed, 69 insertions(+), 65 deletions(-)
---
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index b3469d18..8b02ae09 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -926,7 +926,7 @@ glade_command_set_properties (GladeProperty *property,
       g_assert (G_IS_VALUE (nvalue));
 
       sdata = g_new (GCSetPropData, 1);
-      sdata->property = g_object_ref (G_OBJECT (prop));
+      sdata->property = g_object_ref (prop);
       sdata->old_value = g_new0 (GValue, 1);
       sdata->new_value = g_new0 (GValue, 1);
       g_value_init (sdata->old_value, G_VALUE_TYPE (ovalue));
@@ -1260,7 +1260,7 @@ glade_command_add (GList            *widgets,
       adaptor = glade_widget_get_adaptor (widget);
 
       /* Widget */
-      cdata->widget = g_object_ref (G_OBJECT (widget));
+      cdata->widget = g_object_ref (widget);
 
       /* Parentless ref */
       if ((cdata->reffed =
@@ -1426,7 +1426,7 @@ glade_command_remove (GList *widgets)
       widget = list->data;
 
       cdata = g_new0 (CommandData, 1);
-      cdata->widget = g_object_ref (G_OBJECT (widget));
+      cdata->widget = g_object_ref (widget);
       cdata->parent = glade_widget_get_parent (widget);
 
       if ((cdata->reffed =
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index 40625f52..981220c0 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -451,7 +451,7 @@ glade_editor_property_constructed (GObject *object)
   if (glade_property_class_optional (eprop->priv->klass))
     {
       eprop->priv->check = gtk_check_button_new ();
-      gtk_button_set_focus_on_click (GTK_BUTTON (eprop->priv->check), FALSE);
+      gtk_widget_set_focus_on_click (eprop->priv->check, FALSE);
 
       if (!eprop->priv->disable_check)
         gtk_widget_show (eprop->priv->check);
@@ -1440,6 +1440,7 @@ glade_eprop_color_load (GladeEditorProperty *eprop, GladeProperty *property)
   GladeEPropColor *eprop_color = GLADE_EPROP_COLOR (eprop);
   GParamSpec *pspec;
   GdkColor *color;
+  PangoColor *pango_color;
   GdkRGBA *rgba;
   gchar *text;
 
@@ -1481,6 +1482,29 @@ glade_eprop_color_load (GladeEditorProperty *eprop, GladeProperty *property)
                 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (eprop_color->cbutton), &black);
             }
         }
+      else if (pspec->value_type == PANGO_TYPE_COLOR)
+        {
+          if ((pango_color = g_value_get_boxed (glade_property_inline_value (property))) != NULL)
+            {
+              GdkRGBA copy;
+
+              copy.red   = pango_color->red   / 65535.0;
+              copy.green = pango_color->green / 65535.0;
+              copy.blue  = pango_color->blue  / 65535.0;
+              copy.alpha = 1.0;
+
+              gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (eprop_color->cbutton), &copy);
+            }
+          else
+            {
+              GdkRGBA black = { 0, };
+
+              /* Manually fill it with black for an NULL value.
+               */
+              if (gdk_rgba_parse (&black, "Black"))
+                gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (eprop_color->cbutton), &black);
+            }
+        }
       else if (pspec->value_type == GDK_TYPE_RGBA)
         {
           if ((rgba = g_value_get_boxed (glade_property_inline_value (property))) != NULL)
@@ -1521,6 +1545,16 @@ glade_eprop_color_changed (GtkWidget *button, GladeEditorProperty *eprop)
       color.green = (gint16) (rgba.green * 65535);
       color.blue  = (gint16) (rgba.blue * 65535);
 
+      g_value_set_boxed (&value, &color);
+    }
+  else if (pspec->value_type == PANGO_TYPE_COLOR)
+    {
+      PangoColor color = { 0, };
+
+      color.red   = (gint16) (rgba.red * 65535);
+      color.green = (gint16) (rgba.green * 65535);
+      color.blue  = (gint16) (rgba.blue * 65535);
+
       g_value_set_boxed (&value, &color);
     }
   else if (pspec->value_type == GDK_TYPE_RGBA)
@@ -1630,7 +1664,7 @@ glade_eprop_named_icon_changed_common (GladeEditorProperty *eprop,
    */
   if (prop_text == NULL && text && text[0] == '\0')
     g_value_set_string (val, NULL);
-  else if (text == NULL && prop_text && prop_text == '\0')
+  else if (text == NULL && prop_text && prop_text[0] == '\0')
     g_value_set_string (val, "");
   else
     g_value_set_string (val, text);
@@ -1953,7 +1987,7 @@ glade_eprop_text_changed_common (GladeEditorProperty *eprop,
        */
       if (prop_text == NULL && text && text[0] == '\0')
         g_value_set_string (val, NULL);
-      else if (text == NULL && prop_text && prop_text == '\0')
+      else if (text == NULL && prop_text && prop_text[0] == '\0')
         g_value_set_string (val, "");
       else
         g_value_set_string (val, text);
@@ -2034,10 +2068,6 @@ glade_editor_property_show_i18n_dialog (GtkWidget *parent,
 
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
-  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
-                                           GTK_RESPONSE_OK,
-                                           GTK_RESPONSE_CANCEL, -1);
-
   _glade_util_dialog_set_hig (GTK_DIALOG (dialog));
   content_area =  gtk_dialog_get_content_area (GTK_DIALOG (dialog));
   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
@@ -2235,10 +2265,6 @@ glade_editor_property_show_resource_dialog (GladeProject *project,
 
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
-  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
-                                           GTK_RESPONSE_OK,
-                                           GTK_RESPONSE_CANCEL, -1);
-
   _glade_util_dialog_set_hig (GTK_DIALOG (dialog));
 
   folder = glade_project_resource_fullpath (project, "");
@@ -2671,7 +2697,7 @@ glade_eprop_check_create_input (GladeEditorProperty *eprop)
   gtk_widget_show (label);
   
   eprop_check->button = gtk_check_button_new ();
-  gtk_button_set_focus_on_click (GTK_BUTTON (eprop_check->button), FALSE);
+  gtk_widget_set_focus_on_click (eprop_check->button, FALSE);
 
   gtk_container_add (GTK_CONTAINER (eprop_check->button), label);
 
@@ -3183,11 +3209,6 @@ glade_editor_property_show_object_dialog (GladeProject *project,
                                         _("C_lear"), GLADE_RESPONSE_CLEAR,
                                         _("_OK"), GTK_RESPONSE_OK, NULL);
 
-  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
-                                           GTK_RESPONSE_OK,
-                                           GTK_RESPONSE_CANCEL,
-                                           GLADE_RESPONSE_CLEAR, -1);
-
   gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500);
 
   gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
@@ -3296,12 +3317,6 @@ glade_eprop_object_show_dialog (GladeEditorProperty *eprop)
                                             _("_New"), GLADE_RESPONSE_CREATE,
                                             _("_OK"), GTK_RESPONSE_OK, NULL);
       g_free (title);
-
-      gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
-                                               GTK_RESPONSE_OK,
-                                               GLADE_RESPONSE_CREATE,
-                                               GTK_RESPONSE_CANCEL,
-                                               GLADE_RESPONSE_CLEAR, -1);
     }
   else
     {
@@ -3312,11 +3327,6 @@ glade_eprop_object_show_dialog (GladeEditorProperty *eprop)
                                             _("C_lear"), GLADE_RESPONSE_CLEAR,
                                             _("_OK"), GTK_RESPONSE_OK, NULL);
       g_free (title);
-
-      gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
-                                               GTK_RESPONSE_OK,
-                                               GTK_RESPONSE_CANCEL,
-                                               GLADE_RESPONSE_CLEAR, -1);
     }
 
   gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500);
@@ -3386,7 +3396,6 @@ glade_eprop_object_show_dialog (GladeEditorProperty *eprop)
           GValue *value;
           GObject *new_object, *old_object = NULL;
           GladeWidget *new_widget;
-          const gchar *current_name;
 
           glade_project_selection_set (project, 
                                        glade_widget_get_object (widget),
@@ -3438,7 +3447,6 @@ glade_eprop_object_show_dialog (GladeEditorProperty *eprop)
     }
   else if (res == GLADE_RESPONSE_CREATE)
     {
-      GValue *value;
       GladeWidget *new_widget;
 
       /* translators: Creating 'a widget' for 'a property' of 'a widget' */
diff --git a/plugins/gtk+/glade-attributes.c b/plugins/gtk+/glade-attributes.c
index e7ac3157..b508ac0d 100644
--- a/plugins/gtk+/glade-attributes.c
+++ b/plugins/gtk+/glade-attributes.c
@@ -435,7 +435,7 @@ type_from_attr_type (PangoAttrType type)
       case PANGO_ATTR_UNDERLINE_COLOR:
       case PANGO_ATTR_STRIKETHROUGH_COLOR:
         /* boxed colours */
-        return GDK_TYPE_COLOR;
+        return PANGO_TYPE_COLOR;
 
         /* PangoAttrShape */
       case PANGO_ATTR_SHAPE:
@@ -459,7 +459,7 @@ glade_gtk_string_from_attr (GladeAttribute *gattr)
   gchar *ret = NULL;
   gint ival;
   gdouble fval;
-  GdkColor *color;
+  PangoColor *color;
 
   switch (gattr->type)
     {
@@ -517,7 +517,7 @@ glade_gtk_string_from_attr (GladeAttribute *gattr)
       case PANGO_ATTR_STRIKETHROUGH_COLOR:
         /* boxed colours */
         color = g_value_get_boxed (&(gattr->value));
-        ret = gdk_color_to_string (color);
+        ret = pango_color_to_string (color);
         break;
 
         /* PangoAttrShape */
@@ -540,7 +540,7 @@ GladeAttribute *
 glade_gtk_attribute_from_string (PangoAttrType type, const gchar *strval)
 {
   GladeAttribute *gattr;
-  GdkColor color;
+  PangoColor color;
 
   gattr = g_new0 (GladeAttribute, 1);
   gattr->type = type;
@@ -597,9 +597,9 @@ glade_gtk_attribute_from_string (PangoAttrType type, const gchar *strval)
       case PANGO_ATTR_UNDERLINE_COLOR:
       case PANGO_ATTR_STRIKETHROUGH_COLOR:
         /* boxed colours */
-        if (gdk_color_parse (strval, &color))
+        if (pango_color_parse (&color, strval))
           {
-            g_value_init (&(gattr->value), GDK_TYPE_COLOR);
+            g_value_init (&(gattr->value), PANGO_TYPE_COLOR);
             g_value_set_boxed (&(gattr->value), &color);
           }
         else
@@ -736,7 +736,7 @@ value_icon_activate (GtkCellRendererToggle *cell_renderer,
         if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
           {
             gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &color);
-            /* Use GdkColor string format */
+            /* Use PangoColor string format */
             if (((guint8)(color.red * 0xFF)) * 0x101 == (guint16)(color.red * 0xFFFF) &&
                 ((guint8)(color.green * 0xFF)) * 0x101 == (guint16)(color.green * 0xFFFF) &&
                 ((guint8)(color.blue * 0xFF)) * 0x101 == (guint16)(color.blue * 0xFFFF))
diff --git a/plugins/gtk+/glade-gtk-button.c b/plugins/gtk+/glade-gtk-button.c
index 3d846dfe..b4e87d16 100644
--- a/plugins/gtk+/glade-gtk-button.c
+++ b/plugins/gtk+/glade-gtk-button.c
@@ -45,7 +45,7 @@ glade_gtk_font_button_refresh_font_name (GtkFontButton *button,
 
   if ((property = glade_widget_get_property (gbutton, "font-name")) != NULL)
     glade_command_set_property (property,
-                                gtk_font_button_get_font_name (button));
+                                gtk_font_chooser_get_font (GTK_FONT_CHOOSER (button)));
 }
 
 
diff --git a/plugins/gtk+/glade-icon-factory-editor.c b/plugins/gtk+/glade-icon-factory-editor.c
index d5d67fe8..620426ea 100644
--- a/plugins/gtk+/glade-icon-factory-editor.c
+++ b/plugins/gtk+/glade-icon-factory-editor.c
@@ -126,7 +126,7 @@ glade_icon_factory_editor_new (GladeWidgetAdaptor *adaptor,
 {
   GladeIconFactoryEditor *factory_editor;
   GladeEditorProperty *eprop;
-  GtkWidget *label, *alignment, *frame, *vbox;
+  GtkWidget *label, *description_label, *vbox;
 
   g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
   g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
@@ -134,37 +134,33 @@ glade_icon_factory_editor_new (GladeWidgetAdaptor *adaptor,
   factory_editor = g_object_new (GLADE_TYPE_ICON_FACTORY_EDITOR, NULL);
   factory_editor->embed = GTK_WIDGET (embed);
 
-  /* Pack the parent on top... */
-  gtk_box_pack_start (GTK_BOX (factory_editor), GTK_WIDGET (embed), FALSE,
-                      FALSE, 0);
-
   /* Label item in frame label widget on top... */
   eprop =
       glade_widget_adaptor_create_eprop_by_name (adaptor, "sources", FALSE,
                                                  TRUE);
   factory_editor->properties =
       g_list_prepend (factory_editor->properties, eprop);
-  frame = gtk_frame_new (NULL);
-  gtk_frame_set_label_widget (GTK_FRAME (frame), glade_editor_property_get_item_label (eprop));
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
-  gtk_box_pack_start (GTK_BOX (factory_editor), frame, FALSE, FALSE, 12);
-
-  /* Alignment/Vbox in frame... */
-  alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
-  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
-  gtk_container_add (GTK_CONTAINER (frame), alignment);
-  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-  gtk_container_add (GTK_CONTAINER (alignment), vbox);
+
+  label = glade_editor_property_get_item_label (eprop);
 
   /* Add descriptive label */
-  label = gtk_label_new (_("First add a stock name in the entry below, "
-                           "then add and define sources for that icon "
-                           "in the treeview."));
-  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-  gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD);
-  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 8);
-
-  gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 8);
+  description_label = gtk_label_new (_("First add a stock name in the entry below, "
+                                       "then add and define sources for that icon "
+                                       "in the treeview."));
+  gtk_label_set_line_wrap (GTK_LABEL (description_label), TRUE);
+  gtk_label_set_line_wrap_mode (GTK_LABEL (description_label), PANGO_WRAP_WORD);
+
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_box_set_spacing (GTK_BOX (vbox), 6);
+
+  gtk_container_add (GTK_CONTAINER (vbox), label);
+  gtk_container_add (GTK_CONTAINER (vbox), description_label);
+  gtk_container_add (GTK_CONTAINER (vbox), GTK_WIDGET (eprop));
+  gtk_widget_set_margin_top (vbox, 6);
+
+  /* Pack the parent on top... */
+  gtk_container_add (GTK_CONTAINER (factory_editor), GTK_WIDGET (embed));
+  gtk_container_add (GTK_CONTAINER (factory_editor), vbox);
 
   gtk_widget_show_all (GTK_WIDGET (factory_editor));
 


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