[gtk+] tests: Get rid of GtkEventBox
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] tests: Get rid of GtkEventBox
- Date: Tue, 1 Aug 2017 23:15:26 +0000 (UTC)
commit 69da7836f951d0a0324cf0f4f855972260238524
Author: Benjamin Otte <otte redhat com>
Date: Tue Aug 1 23:49:42 2017 +0100
tests: Get rid of GtkEventBox
tests/testadjustsize.c | 6 ++--
tests/testbaseline.c | 9 +----
tests/testdnd2.c | 73 ++++++++++++++++++-----------------------
tests/testellipsise.c | 27 ---------------
tests/testgrid.c | 4 +-
tests/testheaderbar.c | 11 ++----
tests/testimage.c | 20 +++++------
tests/testlist3.c | 12 +++----
tests/testoverlay.c | 24 +++++++-------
tests/testoverlaystyleclass.c | 10 ++---
10 files changed, 73 insertions(+), 123 deletions(-)
---
diff --git a/tests/testadjustsize.c b/tests/testadjustsize.c
index 8bd24b2..1f099d8 100644
--- a/tests/testadjustsize.c
+++ b/tests/testadjustsize.c
@@ -167,16 +167,16 @@ create_widget_visible_border (const char *text)
GtkWidget *test_widget;
GtkWidget *label;
- outer_box = gtk_event_box_new ();
+ outer_box = gtk_overlay_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (outer_box), "black-bg");
- inner_box = gtk_event_box_new ();
+ inner_box = gtk_overlay_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (inner_box), "blue-bg");
gtk_container_add (GTK_CONTAINER (outer_box), inner_box);
- test_widget = gtk_event_box_new ();
+ test_widget = gtk_overlay_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (test_widget), "red-bg");
gtk_container_add (GTK_CONTAINER (inner_box), test_widget);
diff --git a/tests/testbaseline.c b/tests/testbaseline.c
index 9dd5358..62a663f 100644
--- a/tests/testbaseline.c
+++ b/tests/testbaseline.c
@@ -71,7 +71,7 @@ main (int argc,
char **argv)
{
GtkWidget *window, *label, *entry, *button, *grid, *notebook;
- GtkWidget *vbox, *hbox, *grid_hbox, *spin, *spin2, *toggle, *combo, *image, *ebox;
+ GtkWidget *vbox, *hbox, *grid_hbox, *spin, *spin2, *toggle, *combo, *image;
GtkAdjustment *adjustment;
int i, j;
GtkCssProvider *provider;
@@ -193,16 +193,11 @@ main (int argc,
gtk_container_add (GTK_CONTAINER (hbox), button);
}
- ebox = gtk_event_box_new ();
- if (j == 0)
- gtk_widget_set_valign (ebox, GTK_ALIGN_BASELINE);
- gtk_container_add (GTK_CONTAINER (hbox), ebox);
-
image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON);
gtk_image_set_pixel_size (GTK_IMAGE (image), 34);
if (j == 0)
gtk_widget_set_valign (image, GTK_ALIGN_BASELINE);
- gtk_container_add (GTK_CONTAINER (ebox), image);
+ gtk_container_add (GTK_CONTAINER (hbox), image);
button = gtk_toggle_button_new_with_label ("│Xyj,Ö");
if (j == 0)
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index 1b7a9bf..3a0b872 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -81,12 +81,12 @@ drag_widget_destroyed (GtkWidget *image, gpointer data)
}
static void
-window_drag_end (GtkWidget *ebox, GdkDragContext *context, gpointer data)
+window_drag_end (GtkWidget *widget, GdkDragContext *context, gpointer data)
{
GtkWidget *window = data;
gtk_widget_destroy (window);
- g_signal_handlers_disconnect_by_func (ebox, window_drag_end, data);
+ g_signal_handlers_disconnect_by_func (widget, window_drag_end, data);
}
static void
@@ -121,7 +121,7 @@ window_drag_begin (GtkWidget *widget,
}
static void
-update_source_target_list (GtkWidget *ebox, GtkWidget *image)
+update_source_target_list (GtkWidget *image)
{
GtkTargetList *target_list;
@@ -131,13 +131,13 @@ update_source_target_list (GtkWidget *ebox, GtkWidget *image)
if (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_ICON_NAME)
gtk_target_list_add_text_targets (target_list, TARGET_TEXT);
- gtk_drag_source_set_target_list (ebox, target_list);
+ gtk_drag_source_set_target_list (image, target_list);
gtk_target_list_unref (target_list);
}
static void
-update_dest_target_list (GtkWidget *ebox)
+update_dest_target_list (GtkWidget *image)
{
GtkTargetList *target_list;
@@ -146,7 +146,7 @@ update_dest_target_list (GtkWidget *ebox)
gtk_target_list_add_image_targets (target_list, TARGET_IMAGE, FALSE);
gtk_target_list_add_text_targets (target_list, TARGET_TEXT);
- gtk_drag_dest_set_target_list (ebox, target_list);
+ gtk_drag_dest_set_target_list (image, target_list);
gtk_target_list_unref (target_list);
}
@@ -218,51 +218,45 @@ image_drag_data_received (GtkWidget *widget,
GtkWidget *
make_image (const gchar *icon_name, int hotspot)
{
- GtkWidget *image, *ebox;
+ GtkWidget *image;
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
- ebox = gtk_event_box_new ();
- gtk_drag_source_set (ebox, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
- update_source_target_list (ebox, image);
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ update_source_target_list (image);
g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
- g_signal_connect (ebox, "drag-begin", G_CALLBACK (image_drag_begin), image);
- g_signal_connect (ebox, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
-
- gtk_drag_dest_set (ebox, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
- g_signal_connect (ebox, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
- update_dest_target_list (ebox);
+ g_signal_connect (image, "drag-begin", G_CALLBACK (image_drag_begin), image);
+ g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
- gtk_container_add (GTK_CONTAINER (ebox), image);
+ gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
+ g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
+ update_dest_target_list (image);
- return ebox;
+ return image;
}
GtkWidget *
make_image2 (const gchar *icon_name, int hotspot)
{
- GtkWidget *image, *ebox;
+ GtkWidget *image;
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
- ebox = gtk_event_box_new ();
- gtk_drag_source_set (ebox, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
- update_source_target_list (ebox, image);
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ update_source_target_list (image);
g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
- g_signal_connect (ebox, "drag-begin", G_CALLBACK (window_drag_begin), image);
- g_signal_connect (ebox, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
+ g_signal_connect (image, "drag-begin", G_CALLBACK (window_drag_begin), image);
+ g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
- gtk_drag_dest_set (ebox, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
- g_signal_connect (ebox, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
- update_dest_target_list (ebox);
+ gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
+ g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
+ update_dest_target_list (image);
- gtk_container_add (GTK_CONTAINER (ebox), image);
-
- return ebox;
+ return image;
}
static void
@@ -325,23 +319,20 @@ spinner_drag_data_get (GtkWidget *widget,
static GtkWidget *
make_spinner (void)
{
- GtkWidget *spinner, *ebox;
+ GtkWidget *spinner;
spinner = gtk_spinner_new ();
gtk_spinner_start (GTK_SPINNER (spinner));
- ebox = gtk_event_box_new ();
-
- gtk_drag_source_set (ebox, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
- gtk_drag_source_add_text_targets (ebox);
- g_signal_connect (ebox, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
- g_signal_connect (ebox, "drag-end", G_CALLBACK (spinner_drag_end), spinner);
- g_signal_connect (ebox, "drag-failed", G_CALLBACK (spinner_drag_failed), spinner);
- g_signal_connect (ebox, "drag-data-get", G_CALLBACK (spinner_drag_data_get), spinner);
+ gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_source_add_text_targets (spinner);
- gtk_container_add (GTK_CONTAINER (ebox), spinner);
+ g_signal_connect (spinner, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
+ g_signal_connect (spinner, "drag-end", G_CALLBACK (spinner_drag_end), spinner);
+ g_signal_connect (spinner, "drag-failed", G_CALLBACK (spinner_drag_failed), spinner);
+ g_signal_connect (spinner, "drag-data-get", G_CALLBACK (spinner_drag_data_get), spinner);
- return ebox;
+ return spinner;
}
int
diff --git a/tests/testellipsise.c b/tests/testellipsise.c
index e9f525d..a0d7cc1 100644
--- a/tests/testellipsise.c
+++ b/tests/testellipsise.c
@@ -25,21 +25,6 @@
#include <gtk/gtk.h>
static void
-redraw_event_box (GtkWidget *widget)
-{
- while (widget)
- {
- if (GTK_IS_EVENT_BOX (widget))
- {
- gtk_widget_queue_draw (widget);
- break;
- }
-
- widget = gtk_widget_get_parent (widget);
- }
-}
-
-static void
combo_changed_cb (GtkWidget *combo,
gpointer data)
{
@@ -48,16 +33,6 @@ combo_changed_cb (GtkWidget *combo,
active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
gtk_label_set_ellipsize (GTK_LABEL (label), (PangoEllipsizeMode)active);
- redraw_event_box (label);
-}
-
-static void
-scale_changed_cb (GtkRange *range,
- gpointer data)
-{
- GtkWidget *label = GTK_WIDGET (data);
-
- redraw_event_box (label);
}
static void
@@ -163,8 +138,6 @@ main (int argc, char *argv[])
g_object_set_data (G_OBJECT (label), "combo", combo);
g_signal_connect (combo, "changed", G_CALLBACK (combo_changed_cb), label);
- g_signal_connect (scale, "value-changed", G_CALLBACK (scale_changed_cb), label);
-
gtk_widget_show (window);
diff --git a/tests/testgrid.c b/tests/testgrid.c
index 43e1783..afd3f12 100644
--- a/tests/testgrid.c
+++ b/tests/testgrid.c
@@ -9,9 +9,9 @@ oriented_test_widget (const gchar *label, const gchar *color)
gchar *data;
widget = gtk_label_new (label);
- box = gtk_event_box_new ();
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
provider = gtk_css_provider_new ();
- data = g_strdup_printf ("GtkEventBox { background-color: %s; }", color);
+ data = g_strdup_printf ("box { background: %s; }", color);
gtk_css_provider_load_from_data (provider, data, -1);
gtk_style_context_add_provider (gtk_widget_get_style_context (box),
GTK_STYLE_PROVIDER (provider),
diff --git a/tests/testheaderbar.c b/tests/testheaderbar.c
index c12ebf1..0165ca7 100644
--- a/tests/testheaderbar.c
+++ b/tests/testheaderbar.c
@@ -81,22 +81,19 @@ change_header (GtkButton *button, gpointer data)
GtkWidget *label;
GtkWidget *widget;
GtkWidget *image;
- GtkWidget *box;
if (button && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{
- header = gtk_event_box_new ();
+ header = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_style_context_add_class (gtk_widget_get_style_context (header), "titlebar");
gtk_style_context_add_class (gtk_widget_get_style_context (header), "header-bar");
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
- g_object_set (box, "margin", 10, NULL);
- gtk_container_add (GTK_CONTAINER (header), box);
+ g_object_set (header, "margin", 10, NULL);
label = gtk_label_new ("Label");
- gtk_box_pack_start (GTK_BOX (box), label);
+ gtk_box_pack_start (GTK_BOX (header), label);
widget = gtk_level_bar_new ();
gtk_level_bar_set_value (GTK_LEVEL_BAR (widget), 0.4);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_box_pack_start (GTK_BOX (box), widget);
+ gtk_box_pack_start (GTK_BOX (header), widget);
}
else
{
diff --git a/tests/testimage.c b/tests/testimage.c
index a49bfe8..47b9c55 100644
--- a/tests/testimage.c
+++ b/tests/testimage.c
@@ -79,7 +79,7 @@ int
main (int argc, char **argv)
{
GtkWidget *window, *grid;
- GtkWidget *label, *image, *box;
+ GtkWidget *label, *image;
GtkIconTheme *theme;
GdkPixbuf *pixbuf;
gchar *icon_name = "gnome-terminal";
@@ -111,24 +111,22 @@ main (int argc, char **argv)
theme = gtk_icon_theme_get_default ();
pixbuf = gtk_icon_theme_load_icon (theme, icon_name, 48, 0, NULL);
image = gtk_image_new_from_pixbuf (pixbuf);
- box = gtk_event_box_new ();
- gtk_container_add (GTK_CONTAINER (box), image);
- gtk_grid_attach (GTK_GRID (grid), box, 2, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), image, 2, 1, 1, 1);
- gtk_drag_source_set (box, GDK_BUTTON1_MASK,
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK,
NULL, 0,
GDK_ACTION_COPY);
- gtk_drag_source_add_image_targets (box);
- g_signal_connect (box, "drag_begin", G_CALLBACK (drag_begin), image);
- g_signal_connect (box, "drag_data_get", G_CALLBACK (drag_data_get), image);
+ gtk_drag_source_add_image_targets (image);
+ g_signal_connect (image, "drag_begin", G_CALLBACK (drag_begin), image);
+ g_signal_connect (image, "drag_data_get", G_CALLBACK (drag_data_get), image);
- gtk_drag_dest_set (box,
+ gtk_drag_dest_set (image,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_DROP,
NULL, 0, GDK_ACTION_COPY);
- gtk_drag_dest_add_image_targets (box);
- g_signal_connect (box, "drag_data_received",
+ gtk_drag_dest_add_image_targets (image);
+ g_signal_connect (image, "drag_data_received",
G_CALLBACK (drag_data_received), image);
label = gtk_label_new ("GTK_IMAGE_ICON_NAME");
diff --git a/tests/testlist3.c b/tests/testlist3.c
index 686cf8a..2c216b3 100644
--- a/tests/testlist3.c
+++ b/tests/testlist3.c
@@ -82,23 +82,21 @@ drag_data_received (GtkWidget *widget,
static GtkWidget *
create_row (const gchar *text)
{
- GtkWidget *row, *ebox, *box, *label, *image;
+ GtkWidget *row, *box, *label, *image;
row = gtk_list_box_row_new ();
- ebox = gtk_event_box_new ();
image = gtk_image_new_from_icon_name ("open-menu-symbolic", 1);
- gtk_container_add (GTK_CONTAINER (ebox), image);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
g_object_set (box, "margin-start", 10, "margin-end", 10, NULL);
label = gtk_label_new (text);
gtk_container_add (GTK_CONTAINER (row), box);
gtk_widget_set_hexpand (label, TRUE);
gtk_container_add (GTK_CONTAINER (box), label);
- gtk_container_add (GTK_CONTAINER (box), ebox);
+ gtk_container_add (GTK_CONTAINER (box), image);
- gtk_drag_source_set (ebox, GDK_BUTTON1_MASK, entries, 1, GDK_ACTION_MOVE);
- g_signal_connect (ebox, "drag-begin", G_CALLBACK (drag_begin), NULL);
- g_signal_connect (ebox, "drag-data-get", G_CALLBACK (drag_data_get), NULL);
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, entries, 1, GDK_ACTION_MOVE);
+ g_signal_connect (image, "drag-begin", G_CALLBACK (drag_begin), NULL);
+ g_signal_connect (image, "drag-data-get", G_CALLBACK (drag_data_get), NULL);
gtk_drag_dest_set (row, GTK_DEST_DEFAULT_ALL, entries, 1, GDK_ACTION_MOVE);
g_signal_connect (row, "drag-data-received", G_CALLBACK (drag_data_received), NULL);
diff --git a/tests/testoverlay.c b/tests/testoverlay.c
index 583443b..9c3b001 100644
--- a/tests/testoverlay.c
+++ b/tests/testoverlay.c
@@ -394,7 +394,7 @@ test_stacking (void)
grid = gtk_grid_new ();
overlay = gtk_overlay_new ();
- main_child = gtk_event_box_new ();
+ main_child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (main_child), "overlay-green");
gtk_widget_set_hexpand (main_child, TRUE);
gtk_widget_set_vexpand (main_child, TRUE);
@@ -489,7 +489,7 @@ test_child_order (void)
GtkWidget *overlay;
GtkWidget *button;
GtkWidget *label;
- GtkWidget *ebox;
+ GtkWidget *box;
int i;
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -503,7 +503,7 @@ test_child_order (void)
char *style_classes[] = {
"transparent-red", "transparent-green", "transparent-blue", "transparent-purple"
};
- ebox = gtk_event_box_new ();
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
button = gtk_button_new_with_label (g_strdup_printf ("Child %d", i));
g_signal_connect (button, "clicked", G_CALLBACK (reorder_overlay), overlay);
gtk_widget_set_margin_start (button, 20);
@@ -511,24 +511,24 @@ test_child_order (void)
gtk_widget_set_margin_top (button, 10);
gtk_widget_set_margin_bottom (button, 10);
- gtk_container_add (GTK_CONTAINER (ebox), button);
+ gtk_container_add (GTK_CONTAINER (box), button);
- gtk_style_context_add_class (gtk_widget_get_style_context (ebox), style_classes[i]);
+ gtk_style_context_add_class (gtk_widget_get_style_context (box), style_classes[i]);
- gtk_widget_set_halign (ebox, (i == 0 || i == 3) ? GTK_ALIGN_START : GTK_ALIGN_END);
- gtk_widget_set_valign (ebox, i < 2 ? GTK_ALIGN_START : GTK_ALIGN_END);
- gtk_overlay_add_overlay (GTK_OVERLAY (overlay), ebox);
+ gtk_widget_set_halign (box, (i == 0 || i == 3) ? GTK_ALIGN_START : GTK_ALIGN_END);
+ gtk_widget_set_valign (box, i < 2 ? GTK_ALIGN_START : GTK_ALIGN_END);
+ gtk_overlay_add_overlay (GTK_OVERLAY (overlay), box);
}
- ebox = gtk_event_box_new ();
- gtk_style_context_add_class (gtk_widget_get_style_context (ebox), "overlay-white");
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_style_context_add_class (gtk_widget_get_style_context (box), "overlay-white");
label = gtk_label_new ("Main\n"
"Main\n"
"Main\n"
"Main\n");
- gtk_container_add (GTK_CONTAINER (ebox), label);
- gtk_container_add (GTK_CONTAINER (overlay), ebox);
+ gtk_container_add (GTK_CONTAINER (box), label);
+ gtk_container_add (GTK_CONTAINER (overlay), box);
return win;
}
diff --git a/tests/testoverlaystyleclass.c b/tests/testoverlaystyleclass.c
index e9787d5..2ceeac9 100644
--- a/tests/testoverlaystyleclass.c
+++ b/tests/testoverlaystyleclass.c
@@ -63,12 +63,10 @@ main (int argc, char *argv[])
gtk_window_set_default_size (GTK_WINDOW (win), 600, 600);
grid = gtk_grid_new ();
- child = gtk_event_box_new ();
- gtk_widget_set_hexpand (child, TRUE);
- gtk_widget_set_vexpand (child, TRUE);
- gtk_container_add (GTK_CONTAINER (grid), child);
label = gtk_label_new ("Out of overlay");
- gtk_container_add (GTK_CONTAINER (child), label);
+ gtk_widget_set_hexpand (label, TRUE);
+ gtk_widget_set_vexpand (label, TRUE);
+ gtk_container_add (GTK_CONTAINER (grid), label);
overlay = gtk_overlay_new ();
sw = gtk_scrolled_window_new (NULL, NULL);
@@ -77,7 +75,7 @@ main (int argc, char *argv[])
GTK_POLICY_ALWAYS);
gtk_container_add (GTK_CONTAINER (overlay), sw);
- main_child = gtk_event_box_new ();
+ main_child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (sw), main_child);
gtk_widget_set_hexpand (main_child, TRUE);
gtk_widget_set_vexpand (main_child, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]