Commit c3fff63a authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

Cleanup deprecations all around.

GtkColorChooser APIs now used for color editing
GladeBaseEditor now uses a GtkGrid for it's last GtkTable

In some places to support deprecated types, we explicitly
add G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS statements.
parent b1146ba1
......@@ -202,8 +202,6 @@ glade_init_check (void)
return;
/* Make sure path accessors work on osx */
g_type_init ();
build_package_paths ();
bindtextdomain (GETTEXT_PACKAGE, locale_dir);
......
......@@ -1799,22 +1799,28 @@ glade_base_editor_init (GladeBaseEditor *editor)
gtk_container_add (GTK_CONTAINER (scroll), e->treeview);
/* Add/Remove buttons */
button_table = gtk_table_new (1, 2, TRUE);
button_table = gtk_grid_new ();
gtk_orientable_set_orientation (GTK_ORIENTABLE (button_table),
GTK_ORIENTATION_VERTICAL);
gtk_grid_set_column_homogeneous (GTK_GRID (button_table), TRUE);
gtk_widget_show (button_table);
gtk_table_set_col_spacings (GTK_TABLE (button_table), 8);
gtk_grid_set_column_spacing (GTK_GRID (button_table), 8);
gtk_box_pack_start (GTK_BOX (tree_vbox), button_table, FALSE, TRUE, 0);
button = gtk_button_new_from_stock (GTK_STOCK_ADD);
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_show (button);
g_signal_connect (button, "clicked",
G_CALLBACK (glade_base_editor_add_activate), editor);
gtk_table_attach_defaults (GTK_TABLE (button_table), button, 0, 1, 0, 1);
gtk_grid_attach (GTK_GRID (button_table), button, 0, 0, 1, 1);
e->remove_button = button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
gtk_widget_show (button);
gtk_widget_set_hexpand (button, TRUE);
g_signal_connect (button, "clicked",
G_CALLBACK (glade_base_editor_delete_activate), editor);
gtk_table_attach_defaults (GTK_TABLE (button_table), button, 1, 2, 0, 1);
gtk_grid_attach (GTK_GRID (button_table), button, 1, 0, 1, 1);
/* Properties Vbox */
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
......@@ -1837,8 +1843,7 @@ glade_base_editor_init (GladeBaseEditor *editor)
gtk_grid_set_column_spacing (GTK_GRID (e->table), 4);
gtk_grid_set_row_spacing (GTK_GRID (e->table), 4);
gtk_widget_show (e->table);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll),
e->table);
gtk_container_add (GTK_CONTAINER (scroll), e->table);
/* Signal Editor */
e->signal_editor = glade_signal_editor_new ();
......@@ -1911,8 +1916,7 @@ glade_base_editor_new (GObject *container, GladeEditable *main_editable, ...)
glade_editable_load (main_editable, gcontainer);
gtk_widget_show (GTK_WIDGET (main_editable));
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (e->main_scroll),
GTK_WIDGET (main_editable));
gtk_container_add (GTK_CONTAINER (e->main_scroll), GTK_WIDGET (main_editable));
child_type = g_new0 (ChildTypeTab, 1);
child_type->parent_type = G_OBJECT_TYPE (container);
......
......@@ -1940,7 +1940,7 @@ glade_design_layout_drag_begin (GtkWidget *widget, GdkDragContext *context)
gdk_window_set_background_pattern (gtk_widget_get_window (window), pattern);
gtk_window_set_opacity (GTK_WINDOW (window), .5);
gtk_widget_set_opacity (window, .5);
gtk_drag_set_icon_widget (context, window, priv->drag_x, priv->drag_y);
cairo_destroy (cr);
......
......@@ -1245,21 +1245,30 @@ glade_eprop_color_load (GladeEditorProperty *eprop, GladeProperty *property)
if (pspec->value_type == GDK_TYPE_COLOR)
{
if ((color = g_value_get_boxed (glade_property_inline_value (property))) != NULL)
gtk_color_button_set_color (GTK_COLOR_BUTTON (eprop_color->cbutton), color);
{
GdkRGBA copy;
copy.red = color->red / 65535.0;
copy.green = color->green / 65535.0;
copy.blue = color->blue / 65535.0;
copy.alpha = 1.0;
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (eprop_color->cbutton), &copy);
}
else
{
GdkColor black = { 0, };
GdkRGBA black = { 0, };
/* Manually fill it with black for an NULL value.
*/
if (gdk_color_parse ("Black", &black))
gtk_color_button_set_color (GTK_COLOR_BUTTON (eprop_color->cbutton), &black);
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)
gtk_color_button_set_rgba (GTK_COLOR_BUTTON (eprop_color->cbutton), rgba);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (eprop_color->cbutton), rgba);
else
{
GdkRGBA black = { 0, };
......@@ -1267,7 +1276,7 @@ glade_eprop_color_load (GladeEditorProperty *eprop, GladeProperty *property)
/* Manually fill it with black for an NULL value.
*/
if (gdk_rgba_parse (&black, "Black"))
gtk_color_button_set_rgba (GTK_COLOR_BUTTON (eprop_color->cbutton), &black);
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (eprop_color->cbutton), &black);
}
}
}
......@@ -1276,7 +1285,6 @@ glade_eprop_color_load (GladeEditorProperty *eprop, GladeProperty *property)
static void
glade_eprop_color_changed (GtkWidget *button, GladeEditorProperty *eprop)
{
GdkColor color = { 0, };
GdkRGBA rgba = { 0, };
GValue value = { 0, };
GParamSpec *pspec;
......@@ -1287,20 +1295,22 @@ glade_eprop_color_changed (GtkWidget *button, GladeEditorProperty *eprop)
pspec = glade_property_class_get_pspec (eprop->priv->klass);
g_value_init (&value, pspec->value_type);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
if (pspec->value_type == GDK_TYPE_COLOR)
{
gtk_color_button_get_color (GTK_COLOR_BUTTON (button), &color);
GdkColor 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)
{
gtk_color_button_get_rgba (GTK_COLOR_BUTTON (button), &rgba);
g_value_set_boxed (&value, &rgba);
}
g_value_set_boxed (&value, &rgba);
glade_editor_property_commit_no_callback (eprop, &value);
glade_editor_property_commit (eprop, &value);
g_value_unset (&value);
}
......@@ -1327,7 +1337,9 @@ glade_eprop_color_create_input (GladeEditorProperty *eprop)
gtk_box_pack_start (GTK_BOX (hbox), eprop_color->cbutton, FALSE, FALSE, 0);
if (pspec->value_type == GDK_TYPE_RGBA)
gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (eprop_color->cbutton), TRUE);
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (eprop_color->cbutton), TRUE);
else
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (eprop_color->cbutton), FALSE);
g_signal_connect (G_OBJECT (eprop_color->cbutton), "color-set",
G_CALLBACK (glade_eprop_color_changed), eprop);
......@@ -1633,12 +1645,18 @@ glade_eprop_text_load (GladeEditorProperty *eprop, GladeProperty *property)
else if (GTK_IS_TEXT_VIEW (eprop_text->text_entry))
{
GtkTextBuffer *buffer;
GType value_array_type;
/* Deprecated GValueArray */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
value_array_type = G_TYPE_VALUE_ARRAY;
G_GNUC_END_IGNORE_DEPRECATIONS;
buffer =
gtk_text_view_get_buffer (GTK_TEXT_VIEW (eprop_text->text_entry));
if (pspec->value_type == G_TYPE_STRV ||
pspec->value_type == G_TYPE_VALUE_ARRAY)
pspec->value_type == value_array_type)
{
GladePropertyClass *pclass = glade_property_get_class (property);
gchar *text = glade_widget_adaptor_string_from_value
......@@ -1682,11 +1700,17 @@ glade_eprop_text_changed_common (GladeEditorProperty *eprop,
GValue *val;
GParamSpec *pspec;
gchar *prop_text;
GType value_array_type;
/* Deprecated GValueArray */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
value_array_type = G_TYPE_VALUE_ARRAY;
G_GNUC_END_IGNORE_DEPRECATIONS;
pspec = glade_property_class_get_pspec (eprop->priv->klass);
if (pspec->value_type == G_TYPE_STRV ||
pspec->value_type == G_TYPE_VALUE_ARRAY ||
pspec->value_type == value_array_type ||
pspec->value_type == GDK_TYPE_PIXBUF)
{
GladeWidget *gwidget = glade_property_get_widget (eprop->priv->property);
......@@ -2113,6 +2137,12 @@ glade_eprop_text_create_input (GladeEditorProperty *eprop)
GladePropertyClass *klass;
GParamSpec *pspec;
GtkWidget *hbox;
GType value_array_type;
/* Deprecated GValueArray */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
value_array_type = G_TYPE_VALUE_ARRAY;
G_GNUC_END_IGNORE_DEPRECATIONS;
klass = eprop->priv->klass;
pspec = glade_property_class_get_pspec (klass);
......@@ -2164,7 +2194,7 @@ glade_eprop_text_create_input (GladeEditorProperty *eprop)
}
else if (glade_property_class_multiline (klass) ||
pspec->value_type == G_TYPE_STRV ||
pspec->value_type == G_TYPE_VALUE_ARRAY)
pspec->value_type == value_array_type)
{
GtkWidget *swindow;
GtkTextBuffer *buffer;
......
......@@ -142,8 +142,6 @@ G_DEFINE_TYPE (GladeEditor, glade_editor, GTK_TYPE_VBOX);
static GParamSpec *properties[N_PROPERTIES];
static void glade_editor_reset_dialog (GladeEditor *editor);
static void
glade_editor_set_property (GObject *object,
guint prop_id,
......@@ -314,8 +312,7 @@ glade_editor_notebook_page (GladeEditor *editor,
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw),
container);
gtk_container_add (GTK_CONTAINER (sw), container);
gtk_notebook_insert_page (GTK_NOTEBOOK (editor->priv->notebook), sw,
label_widget, page++);
......@@ -929,7 +926,7 @@ glade_editor_reset_toggled (GtkCellRendererToggle *cell,
}
static GtkWidget *
glade_editor_reset_view ()
glade_editor_reset_view (void)
{
GtkWidget *view_widget;
GtkTreeModel *model;
......
......@@ -264,8 +264,6 @@ glade_inspector_init (GladeInspector *inspector)
inspector->priv = priv = GLADE_INSPECTOR_GET_PRIVATE (inspector);
gtk_widget_push_composite_child ();
priv->project = NULL;
priv->view = gtk_tree_view_new ();
......@@ -293,8 +291,6 @@ glade_inspector_init (GladeInspector *inspector)
gtk_widget_show (priv->view);
gtk_widget_show (sw);
gtk_widget_pop_composite_child ();
}
static void
......
......@@ -1396,9 +1396,6 @@ glade_named_icon_chooser_dialog_init (GladeNamedIconChooserDialog * dialog)
if (standard_icon_quarks == NULL)
standard_icon_quarks = create_standard_icon_quarks ();
gtk_widget_push_composite_child ();
contents = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_widget_show (contents);
......@@ -1503,8 +1500,6 @@ glade_named_icon_chooser_dialog_init (GladeNamedIconChooserDialog * dialog)
0);
gtk_box_pack_start (GTK_BOX (content_area), contents, TRUE, TRUE, 0);
gtk_widget_pop_composite_child ();
/* underlying model */
dialog->priv->icons_store = gtk_list_store_new (ICONS_N_COLUMNS,
G_TYPE_UINT,
......
......@@ -2393,8 +2393,7 @@ glade_project_verify_dialog (GladeProject *project,
gtk_text_buffer_set_text (buffer, string->str, -1);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swindow),
textview);
gtk_container_add (GTK_CONTAINER (swindow), textview);
gtk_container_add (GTK_CONTAINER (expander), swindow);
gtk_widget_show_all (expander);
......
......@@ -806,17 +806,25 @@ glade_property_class_make_gvalue_from_string (GladePropertyClass *property_class
}
else if (G_IS_PARAM_SPEC_VALUE_ARRAY (property_class->pspec))
{
GValueArray *value_array = g_value_array_new (0);
GValueArray *value_array;
GValue str_value = { 0, };
gint i;
/* Require deprecated code */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
value_array = g_value_array_new (0);
G_GNUC_END_IGNORE_DEPRECATIONS;
g_value_init (&str_value, G_TYPE_STRING);
strv = g_strsplit (string, "\n", 0);
for (i = 0; strv[i]; i++)
{
g_value_set_static_string (&str_value, strv[i]);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
value_array = g_value_array_append (value_array, &str_value);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
g_value_take_boxed (value, value_array);
g_strfreev (strv);
......
......@@ -261,6 +261,9 @@ glade_util_ui_message (GtkWidget *parent,
(gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
widget, TRUE, TRUE, 2);
gtk_widget_show (widget);
/* If theres additional content, make it resizable */
gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
}
response = gtk_dialog_run (GTK_DIALOG (dialog));
......@@ -1642,7 +1645,6 @@ glade_utils_hijack_key_press (GtkWindow *win,
}
void
glade_utils_cairo_draw_line (cairo_t *cr,
GdkColor *color,
......
......@@ -1233,8 +1233,11 @@ glade_widget_adaptor_get_eprop_type (GParamSpec *pspec)
type = GLADE_TYPE_EPROP_FLAGS;
else if (G_IS_PARAM_SPEC_VALUE_ARRAY (pspec))
{
/* Require deprecated code */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (pspec->value_type == G_TYPE_VALUE_ARRAY)
type = GLADE_TYPE_EPROP_TEXT;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
}
else if (G_IS_PARAM_SPEC_BOXED (pspec))
{
......
......@@ -164,9 +164,11 @@ glade_gtk_table_refresh_placeholders (GtkTable * table)
{
if (!placeholder)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_table_attach_defaults (table,
glade_placeholder_new (),
i, i + 1, j, j + 1);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
}
}
......@@ -278,10 +280,12 @@ glade_gtk_table_set_n_common (GObject * object, const GValue * value,
widget = glade_widget_get_from_gobject (GTK_WIDGET (table));
g_return_if_fail (widget != NULL);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (for_rows)
gtk_table_resize (table, new_size, n_columns);
else
gtk_table_resize (table, n_rows, new_size);
G_GNUC_END_IGNORE_DEPRECATIONS;
/* Fill table with placeholders */
glade_gtk_table_refresh_placeholders (table);
......@@ -336,9 +340,12 @@ glade_gtk_table_set_n_common (GObject * object, const GValue * value,
}
g_list_free (list_to_free);
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_table_resize (table,
for_rows ? new_size : n_rows,
for_rows ? n_columns : new_size);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
}
......
......@@ -4090,13 +4090,20 @@ glade_gtk_color_button_refresh_color (GtkColorButton * button,
GladeWidget * gbutton)
{
GladeProperty *property;
GdkRGBA rgba = { 0, };
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
if ((property = glade_widget_get_property (gbutton, "color")) != NULL)
{
if (glade_property_get_enabled (property))
{
GdkColor color = { 0, };
gtk_color_button_get_color (button, &color);
color.red = (gint16) (rgba.red * 65535);
color.green = (gint16) (rgba.green * 65535);
color.blue = (gint16) (rgba.blue * 65535);
glade_command_set_property (property, &color);
}
}
......@@ -4104,11 +4111,7 @@ glade_gtk_color_button_refresh_color (GtkColorButton * button,
if ((property = glade_widget_get_property (gbutton, "rgba")) != NULL)
{
if (glade_property_get_enabled (property))
{
GdkRGBA rgba = { 0, };
gtk_color_button_get_rgba (button, &rgba);
glade_command_set_property (property, &rgba);
}
glade_command_set_property (property, &rgba);
}
}
......@@ -4124,15 +4127,24 @@ glade_gtk_color_button_set_property (GladeWidgetAdaptor * adaptor,
{
if ((property = glade_widget_get_property (gwidget, "color")) != NULL &&
glade_property_get_enabled (property) && g_value_get_boxed (value))
gtk_color_button_set_color (GTK_COLOR_BUTTON (object),
(GdkColor *) g_value_get_boxed (value));
{
GdkColor *color = g_value_get_boxed (value);
GdkRGBA copy;
copy.red = color->red / 65535.0;
copy.green = color->green / 65535.0;
copy.blue = color->blue / 65535.0;
copy.alpha = 1.0;
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (object), &copy);
}
}
else if (!strcmp (id, "rgba"))
{
if ((property = glade_widget_get_property (gwidget, "rgba")) != NULL &&
glade_property_get_enabled (property) && g_value_get_boxed (value))
gtk_color_button_set_rgba (GTK_COLOR_BUTTON (object),
(GdkRGBA *) g_value_get_boxed (value));
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (object),
(GdkRGBA *) g_value_get_boxed (value));
}
else
GWA_GET_CLASS (GTK_TYPE_BUTTON)->set_property (adaptor, object, id, value);
......@@ -4368,7 +4380,6 @@ glade_gtk_write_icon_size (GladeWidget * widget,
{
GladeXmlNode *prop_node;
GladeProperty *size_prop;
GladePropertyClass *pclass;
GtkIconSize icon_size;
gchar *value;
......@@ -4383,7 +4394,6 @@ glade_gtk_write_icon_size (GladeWidget * widget,
glade_util_replace (write_prop_name, '-', '_');
pclass = glade_property_get_class (size_prop);
prop_node = glade_xml_node_new (context, GLADE_TAG_PROPERTY);
glade_xml_node_append_child (node, prop_node);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment