summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2020-02-16 14:24:03 +0100
committerBenjamin Otte <otte@redhat.com>2020-02-16 20:10:30 +0100
commit8d2ed36a1bdc4f5c5c7a5eab39562764c69139ce (patch)
treee2abac8376acdf46f9f239d20df3ea6ff83d991b /tests
parent762c4602fbb88e3712336426a326adf813e5b280 (diff)
downloadgtk+-8d2ed36a1bdc4f5c5c7a5eab39562764c69139ce.tar.gz
contentprovider: Add gdk_content_provider_new_typed()
Gets around the boilerplate required to create and initialize a GValue by having this function doing it via G_VALUE_COLLECT().
Diffstat (limited to 'tests')
-rw-r--r--tests/testclipboard2.c5
-rw-r--r--tests/testdnd.c6
-rw-r--r--tests/testdnd2.c6
-rw-r--r--tests/testentryicons.c6
-rw-r--r--tests/testlist3.c10
5 files changed, 5 insertions, 28 deletions
diff --git a/tests/testclipboard2.c b/tests/testclipboard2.c
index d09c06050f..da812f6782 100644
--- a/tests/testclipboard2.c
+++ b/tests/testclipboard2.c
@@ -344,13 +344,10 @@ get_button_list (GdkClipboard *clipboard,
"GdkPixbuf");
g_value_unset (&value);
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, "Hello Clipboard ☺");
add_provider_button (box,
- gdk_content_provider_new_for_value (&value),
+ gdk_content_provider_new_typed (G_TYPE_STRING, "Hello Clipboard ☺"),
clipboard,
"gchararry");
- g_value_unset (&value);
add_provider_button (box,
gdk_content_provider_new_for_bytes ("text/plain;charset=utf-8",
diff --git a/tests/testdnd.c b/tests/testdnd.c
index 41a5109240..40ec72d60c 100644
--- a/tests/testdnd.c
+++ b/tests/testdnd.c
@@ -605,7 +605,6 @@ main (int argc, char **argv)
GdkPixbuf *drag_icon;
GdkTexture *texture;
GdkContentProvider *content;
- GValue value = G_VALUE_INIT;
GtkDragSource *source;
GdkContentFormats *targets;
GtkDropTarget *dest;
@@ -673,10 +672,7 @@ main (int argc, char **argv)
button = gtk_label_new ("Drag Here\n");
source = gtk_drag_source_new ();
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, "I'm data!");
- content = gdk_content_provider_new_for_value (&value);
- g_value_unset (&value);
+ content = gdk_content_provider_new_typed (G_TYPE_STRING, "I'm data!");
gtk_drag_source_set_content (source, content);
g_object_unref (content);
gtk_drag_source_set_actions (source, GDK_ACTION_COPY|GDK_ACTION_MOVE);
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index 608c955b03..cfb0da65c5 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -439,21 +439,17 @@ make_spinner (void)
GtkWidget *spinner;
GtkDragSource *source;
GdkContentProvider *content;
- GValue value = G_VALUE_INIT;
spinner = gtk_spinner_new ();
gtk_spinner_start (GTK_SPINNER (spinner));
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, "ACTIVE");
- content = gdk_content_provider_new_for_value (&value);
+ content = gdk_content_provider_new_typed (G_TYPE_STRING, "ACTIVE");
source = gtk_drag_source_new ();
gtk_drag_source_set_content (source, content);
g_signal_connect (source, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
gtk_widget_add_controller (spinner, GTK_EVENT_CONTROLLER (source));
g_object_unref (content);
- g_value_unset (&value);
return spinner;
}
diff --git a/tests/testentryicons.c b/tests/testentryicons.c
index 796295a61f..14d3cb6b5d 100644
--- a/tests/testentryicons.c
+++ b/tests/testentryicons.c
@@ -100,7 +100,6 @@ main (int argc, char **argv)
GtkWidget *button4;
GIcon *icon;
GdkContentProvider *content;
- GValue value = G_VALUE_INIT;
gboolean done = FALSE;
gtk_init ();
@@ -165,10 +164,7 @@ main (int argc, char **argv)
GTK_ENTRY_ICON_PRIMARY,
"Save a file");
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, "Amazing");
- content = gdk_content_provider_new_for_value (&value);
- g_value_unset (&value);
+ content = gdk_content_provider_new_typed (G_TYPE_STRING, "Amazing");
gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
GTK_ENTRY_ICON_PRIMARY,
content, GDK_ACTION_COPY);
diff --git a/tests/testlist3.c b/tests/testlist3.c
index 4240d78172..fb5fd1addd 100644
--- a/tests/testlist3.c
+++ b/tests/testlist3.c
@@ -6,15 +6,7 @@ prepare (GtkDragSource *source,
double y,
GtkWidget *row)
{
- GdkContentProvider *content;
- GValue value = G_VALUE_INIT;
-
- g_value_init (&value, GTK_TYPE_LIST_BOX_ROW);
- g_value_set_object (&value, row);
- content = gdk_content_provider_new_for_value (&value);
- g_value_unset (&value);
-
- return content;
+ return gdk_content_provider_new_typed (GTK_TYPE_LIST_BOX_ROW, row);
}
static void