[gtk+/extended-layout-jhs: 41/64] Consider natural size of the child. Expose natural size via
- From: Johannes Schmid <jhs src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/extended-layout-jhs: 41/64] Consider natural size of the child. Expose natural size via
- Date: Wed, 25 Nov 2009 11:22:21 +0000 (UTC)
commit 6b2aa37c9b35db9b768fd90adc135b1228d1eab7
Author: Mathias Hasselmann <mathias hasselmann gmx de>
Date: Fri Jul 27 18:36:20 2007 +0000
Consider natural size of the child. Expose natural size via
2007-07-27 Mathias Hasselmann <mathias hasselmann gmx de>
* gtk/gtkalignment.c, gtk/gtksocket.c, gtk/gtksocket-x11.c,
gtk/gtksocketprivate.h: Consider natural size of the child.
* gtk/gtkplug.c, gtk/gtkplug-x11.c, gtk/gtkplugprivate.h:
Expose natural size via _GTK_NATURAL_SIZE window property.
* tests/testextendedlayout.c: Test natural size handling
of GtkAlignment, GtkPlug and GtkSocket.
svn path=/branches/extended-layout/; revision=18551
ChangeLog.gtk-extended-layout | 9 ++
gtk/gtkalignment.c | 13 ++
gtk/gtkplug-x11.c | 26 +++++
gtk/gtkplug.c | 17 +++-
gtk/gtkplugprivate.h | 9 ++
gtk/gtksocket-x11.c | 64 +++++++++++-
gtk/gtksocket.c | 59 ++++++++++-
gtk/gtksocketprivate.h | 9 ++
tests/testextendedlayout.c | 249 +++++++++++++++++++++++++++++++++++++++--
9 files changed, 442 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog.gtk-extended-layout b/ChangeLog.gtk-extended-layout
index a9d8065..d999fd4 100644
--- a/ChangeLog.gtk-extended-layout
+++ b/ChangeLog.gtk-extended-layout
@@ -1,3 +1,12 @@
+2007-07-27 Mathias Hasselmann <mathias hasselmann gmx de>
+
+ * gtk/gtkalignment.c, gtk/gtksocket.c, gtk/gtksocket-x11.c,
+ gtk/gtksocketprivate.h: Consider natural size of the child.
+ * gtk/gtkplug.c, gtk/gtkplug-x11.c, gtk/gtkplugprivate.h:
+ Expose natural size via _GTK_NATURAL_SIZE window property.
+ * tests/testextendedlayout.c: Test natural size handling
+ of GtkAlignment, GtkPlug and GtkSocket.
+
2007-07-26 Mathias Hasselmann <mathias hasselmann gmx de>
* gtk/gtktable.c: Seems natural size for spanning cells worked already.
diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c
index 904fcbb..fafb18c 100644
--- a/gtk/gtkalignment.c
+++ b/gtk/gtkalignment.c
@@ -448,6 +448,7 @@ gtk_alignment_size_allocate (GtkWidget *widget,
GtkBin *bin;
GtkAllocation child_allocation;
GtkRequisition child_requisition;
+ GtkRequisition child_natural_size;
gint width, height;
gint border_width;
gint padding_horizontal, padding_vertical;
@@ -473,6 +474,18 @@ gtk_alignment_size_allocate (GtkWidget *widget,
width = allocation->width - padding_horizontal - 2 * border_width;
height = allocation->height - padding_vertical - 2 * border_width;
+ if (GTK_EXTENDED_LAYOUT_HAS_NATURAL_SIZE (bin->child))
+ {
+ gtk_extended_layout_get_natural_size (GTK_EXTENDED_LAYOUT (bin->child),
+ &child_natural_size);
+
+ child_requisition.width = MAX (child_requisition.width, child_natural_size.width);
+ child_requisition.width = MIN (child_requisition.width, width);
+
+ child_requisition.height = MAX (child_requisition.height, child_natural_size.height);
+ child_requisition.height = MIN (child_requisition.height, height);
+ }
+
if (width > child_requisition.width)
child_allocation.width = (child_requisition.width *
(1.0 - alignment->xscale) +
diff --git a/gtk/gtkplug-x11.c b/gtk/gtkplug-x11.c
index 028b2fe..721272e 100644
--- a/gtk/gtkplug-x11.c
+++ b/gtk/gtkplug-x11.c
@@ -32,6 +32,7 @@
#include "gtkplugprivate.h"
#include "x11/gdkx.h"
+#include <X11/Xatom.h>
#include "gtkxembed.h"
#include "gtkalias.h"
@@ -330,3 +331,28 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
return return_val;
}
+
+void
+_gtk_plug_windowing_publish_natural_size (GtkPlug *plug,
+ GtkRequisition *requisition)
+{
+ GtkWidget *widget = GTK_WIDGET (plug);
+ GdkDisplay *display;
+ GdkWindow *window;
+ gint32 data[2];
+ Atom property;
+
+ gtk_widget_realize (widget);
+
+ window = GTK_WIDGET (plug)->window;
+ display = gdk_drawable_get_display (window);
+ property = gdk_x11_get_xatom_by_name_for_display (display, "_GTK_NATURAL_SIZE");
+
+ data[0] = requisition->width;
+ data[1] = requisition->height;
+
+ XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XWINDOW (window), property,
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char*)data, 2);
+}
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index f9ca4ef..e4d7a15 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -33,6 +33,7 @@
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkplugprivate.h"
+#include "gtkextendedlayout.h"
#include "gtkalias.h"
@@ -668,11 +669,13 @@ static void
gtk_plug_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkBin *bin = GTK_BIN (widget);
+ GtkRequisition natural_size;
+
if (GTK_WIDGET_TOPLEVEL (widget))
GTK_WIDGET_CLASS (gtk_plug_parent_class)->size_allocate (widget, allocation);
else
{
- GtkBin *bin = GTK_BIN (widget);
widget->allocation = *allocation;
@@ -693,8 +696,18 @@ gtk_plug_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (bin->child, &child_allocation);
}
-
}
+
+ if (GTK_EXTENDED_LAYOUT_HAS_NATURAL_SIZE (bin->child))
+ {
+ gtk_extended_layout_get_natural_size (
+ GTK_EXTENDED_LAYOUT (bin->child),
+ &natural_size);
+
+ _gtk_plug_windowing_publish_natural_size (GTK_PLUG (widget), &natural_size);
+ }
+ else
+ _gtk_plug_windowing_publish_natural_size (GTK_PLUG (widget), &widget->requisition);
}
static gboolean
diff --git a/gtk/gtkplugprivate.h b/gtk/gtkplugprivate.h
index fb173c1..c9fa296 100644
--- a/gtk/gtkplugprivate.h
+++ b/gtk/gtkplugprivate.h
@@ -138,4 +138,13 @@ GdkFilterReturn _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
+/**
+ * _gtk_plug_windowing_publish_natural_size:
+ *
+ * @plug: a #GtkPlug
+ * @requisition: a requisition with the natural size
+ */
+void _gtk_plug_windowing_publish_natural_size (GtkPlug *plug,
+ GtkRequisition *requisition);
+
#endif /* __GTK_PLUG_PRIVATE_H__ */
diff --git a/gtk/gtksocket-x11.c b/gtk/gtksocket-x11.c
index 5d1f693..06c063a 100644
--- a/gtk/gtksocket-x11.c
+++ b/gtk/gtksocket-x11.c
@@ -39,6 +39,7 @@
#include "gtkdnd.h"
#include "x11/gdkx.h"
+#include <X11/Xatom.h>
#ifdef HAVE_XFIXES
#include <X11/extensions/Xfixes.h>
@@ -93,7 +94,7 @@ _gtk_socket_windowing_size_request (GtkSocket *socket)
socket->request_width = 1;
socket->request_height = 1;
-
+
if (XGetWMNormalHints (GDK_WINDOW_XDISPLAY (socket->plug_window),
GDK_WINDOW_XWINDOW (socket->plug_window),
&hints, &supplied))
@@ -115,6 +116,63 @@ _gtk_socket_windowing_size_request (GtkSocket *socket)
}
void
+_gtk_socket_windowing_get_natural_size (GtkSocket *socket)
+{
+ GtkSocketPrivate *priv;
+ GdkDisplay *display;
+
+ Atom property, type;
+ int format, status;
+
+ unsigned long nitems, bytes_after;
+ unsigned char *data;
+ gint32 *data_long;
+
+ priv = _gtk_socket_get_private (socket);
+
+ priv->natural_width = 1;
+ priv->natural_height = 1;
+
+ if (GTK_WIDGET_MAPPED (socket))
+ {
+ display = gdk_drawable_get_display (socket->plug_window);
+ property = gdk_x11_get_xatom_by_name_for_display (display, "_GTK_NATURAL_SIZE");
+
+ gdk_error_trap_push ();
+ status = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XWINDOW (socket->plug_window),
+ property, 0, 2, False, XA_CARDINAL,
+ &type, &format, &nitems, &bytes_after,
+ &data);
+ gdk_error_trap_pop ();
+
+ priv->have_natural_size = TRUE;
+
+ if (Success != status || !type)
+ return;
+
+ if (type != XA_CARDINAL)
+ {
+ g_warning ("_GTK_NATURAL_SIZE property has wrong type: %d\n", (int)type);
+ return;
+ }
+
+ if (nitems < 2)
+ {
+ g_warning ("_GTK_NATURAL_SIZE too short\n");
+ XFree (data);
+ return;
+ }
+
+ data_long = (long*) data;
+ priv->natural_width = MAX (1, data_long[0]);
+ priv->natural_height = MAX (1, data_long[1]);
+
+ XFree (data);
+ }
+}
+
+void
_gtk_socket_windowing_send_key_event (GtkSocket *socket,
GdkEvent *gdk_event,
gboolean mask_key_presses)
@@ -594,6 +652,10 @@ _gtk_socket_windowing_filter_func (GdkXEvent *gdk_xevent,
}
return_val = GDK_FILTER_REMOVE;
}
+ else if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_GTK_NATURAL_SIZE"))
+ {
+ _gtk_socket_windowing_get_natural_size (socket);
+ }
}
break;
case ReparentNotify:
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index 8f54f58..dba1148 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -36,6 +36,7 @@
#include "gtkprivate.h"
#include "gtksocket.h"
#include "gtksocketprivate.h"
+#include "gtkextendedlayout.h"
#include "gtkdnd.h"
#include "gtkintl.h"
@@ -67,6 +68,7 @@ static void gtk_socket_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
+static void gtk_socket_extended_layout_interface_init (GtkExtendedLayoutIface *iface);
/* Local data */
@@ -98,7 +100,9 @@ _gtk_socket_get_private (GtkSocket *socket)
return G_TYPE_INSTANCE_GET_PRIVATE (socket, GTK_TYPE_SOCKET, GtkSocketPrivate);
}
-G_DEFINE_TYPE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER)
+G_DEFINE_TYPE_WITH_CODE (GtkSocket, gtk_socket, GTK_TYPE_CONTAINER,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_EXTENDED_LAYOUT,
+ gtk_socket_extended_layout_interface_init))
static void
gtk_socket_finalize (GObject *object)
@@ -167,6 +171,8 @@ gtk_socket_class_init (GtkSocketClass *class)
static void
gtk_socket_init (GtkSocket *socket)
{
+ GtkSocketPrivate *priv;
+
socket->request_width = 0;
socket->request_height = 0;
socket->current_width = 0;
@@ -181,6 +187,9 @@ gtk_socket_init (GtkSocket *socket)
socket->accel_group = gtk_accel_group_new ();
g_object_set_data (G_OBJECT (socket->accel_group), I_("gtk-socket"), socket);
+
+ priv = _gtk_socket_get_private (socket);
+ priv->have_natural_size = FALSE;
}
/**
@@ -392,7 +401,7 @@ gtk_socket_size_request (GtkWidget *widget,
else
{
if (socket->is_mapped && !socket->have_size && socket->plug_window)
- _gtk_socket_windowing_size_request (socket);
+ _gtk_socket_windowing_get_natural_size (socket);
if (socket->is_mapped && socket->have_size)
{
@@ -997,5 +1006,51 @@ _gtk_socket_advance_toplevel_focus (GtkSocket *socket,
}
}
+static GtkExtendedLayoutFeatures
+gtk_socket_extended_layout_get_features (GtkExtendedLayout *layout)
+{
+ return GTK_EXTENDED_LAYOUT_NATURAL_SIZE;
+}
+
+static void
+gtk_socket_extended_layout_get_natural_size (GtkExtendedLayout *layout,
+ GtkRequisition *requisition)
+{
+ GtkSocket *socket = GTK_SOCKET (layout);
+ GtkSocketPrivate *priv;
+
+ if (socket->plug_widget)
+ {
+ gtk_extended_layout_get_natural_size (
+ GTK_EXTENDED_LAYOUT (socket->plug_widget),
+ requisition);
+ }
+ else
+ {
+ priv = _gtk_socket_get_private (socket);
+
+ if (socket->is_mapped && !priv->have_natural_size && socket->plug_window)
+ _gtk_socket_windowing_size_request (socket);
+
+ if (socket->is_mapped && priv->have_natural_size)
+ {
+ requisition->width = MAX (priv->natural_width, 1);
+ requisition->height = MAX (priv->natural_height, 1);
+ }
+ else
+ {
+ requisition->width = 1;
+ requisition->height = 1;
+ }
+ }
+}
+
+static void
+gtk_socket_extended_layout_interface_init (GtkExtendedLayoutIface *iface)
+{
+ iface->get_features = gtk_socket_extended_layout_get_features;
+ iface->get_natural_size = gtk_socket_extended_layout_get_natural_size;
+}
+
#define __GTK_SOCKET_C__
#include "gtkaliasdef.c"
diff --git a/gtk/gtksocketprivate.h b/gtk/gtksocketprivate.h
index 85852fb..3779e43 100644
--- a/gtk/gtksocketprivate.h
+++ b/gtk/gtksocketprivate.h
@@ -31,6 +31,9 @@ typedef struct _GtkSocketPrivate GtkSocketPrivate;
struct _GtkSocketPrivate
{
gint resize_count;
+ gint natural_width;
+ gint natural_height;
+ gboolean have_natural_size;
};
/* In gtksocket.c: */
@@ -84,6 +87,12 @@ void _gtk_socket_windowing_end_embedding_toplevel (GtkSocket *socket);
void _gtk_socket_windowing_size_request (GtkSocket *socket);
/**
+ * _gtk_socket_windowing_get_natural_size:
+ *
+ */
+void _gtk_socket_windowing_get_natural_size (GtkSocket *socket);
+
+/**
* _gtk_socket_windowing_send_key_event:
*
*/
diff --git a/tests/testextendedlayout.c b/tests/testextendedlayout.c
index d4b2213..d18cda1 100644
--- a/tests/testextendedlayout.c
+++ b/tests/testextendedlayout.c
@@ -22,6 +22,11 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
+#ifdef GDK_WINDOWING_X11
+#include "x11/gdkx.h"
+#endif
#define IS_VALID_BASELINE(Baseline) ((Baseline) >= 0)
@@ -451,6 +456,154 @@ create_natural_size_test (TestSuite *suite,
return test;
}
+static void
+on_socket_realized (GtkWidget *widget,
+ gpointer data)
+{
+ gtk_socket_add_id (GTK_SOCKET (widget),
+ GPOINTER_TO_INT (data));
+}
+
+static TestCase*
+create_natural_socket_size_test (TestSuite *suite,
+ gchar *arg0)
+{
+ GtkWidget *box, *label, *align, *child, *plug;
+ GdkNativeWindow plug_id;
+ TestCase *test;
+
+ gchar *argv[] = { arg0, "--action=create-plug", NULL, NULL, NULL };
+ GError *error = NULL;
+ gint child_stdout;
+ char buffer[32];
+
+ gint orientation, type;
+ gint i, j;
+
+ test = test_case_new (suite, "Natural Size", "GtkAlignment, GtkSocket",
+ gtk_alignment_new (0.5, 0.5, 0.6, 0.0));
+
+ box = gtk_vbox_new (FALSE, 12);
+
+ gtk_container_set_border_width (GTK_CONTAINER (test->widget), 6);
+ gtk_container_add (GTK_CONTAINER (test->widget), box);
+
+ for (orientation = 0; orientation < 2; ++orientation)
+ {
+ if (orientation)
+ {
+ child = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_end (GTK_BOX (box), child, FALSE, TRUE, 0);
+ gtk_box_pack_end (GTK_BOX (box), gtk_hseparator_new (), FALSE, TRUE, 0);
+ box = child;
+ }
+
+ for (type = 0; type < 3; ++type)
+ {
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label),
+ type > 1 ? "<b>GtkSocket with XEMBED</b>" :
+ type > 0 ? "<b>GtkSocket with GtkPlug</b>" :
+ "<b>GtkAligment</b>");
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
+
+ if (orientation)
+ gtk_label_set_angle (GTK_LABEL (label), 90);
+
+ for (i = 0; i < 2; ++i)
+ {
+ label = gtk_label_new ("Hello World");
+
+ gtk_label_set_ellipsize (GTK_LABEL (label),
+ i ? PANGO_ELLIPSIZE_END :
+ PANGO_ELLIPSIZE_NONE);
+
+ if (orientation)
+ gtk_label_set_angle (GTK_LABEL (label), 90);
+
+ switch (type)
+ {
+ case 0:
+ child = label;
+ break;
+
+ case 1:
+ plug = gtk_plug_new (0);
+ plug_id = gtk_plug_get_id (GTK_PLUG (plug));
+ gtk_container_add (GTK_CONTAINER (plug), label);
+ gtk_widget_show_all (plug);
+
+ child = gtk_socket_new ();
+ g_signal_connect (child, "realize",
+ G_CALLBACK (on_socket_realized),
+ GINT_TO_POINTER (plug_id));
+ break;
+
+ case 2:
+ plug_id = 0;
+ j = 2;
+
+ if (i)
+ argv[j++] = "--ellipsize";
+ if (orientation)
+ argv[j++] = "--vertical";
+
+ if (g_spawn_async_with_pipes (NULL, argv, NULL, 0,
+ NULL, NULL, NULL,
+ NULL, &child_stdout, NULL,
+ &error))
+ {
+ j = read (child_stdout, buffer, sizeof (buffer) - 1);
+ close (child_stdout);
+
+ if (j > 0)
+ {
+ buffer[j] = '\0';
+ plug_id = atoi (buffer);
+ }
+
+ g_print ("plug-id: %d\n", plug_id);
+
+ child = gtk_socket_new ();
+ g_signal_connect (child, "realize",
+ G_CALLBACK (on_socket_realized),
+ GINT_TO_POINTER (plug_id));
+ }
+ else
+ {
+ child = gtk_label_new (error ? error->message :
+ "Failed to create external plug");
+ g_clear_error (&error);
+ }
+
+ break;
+
+ default:
+ continue;
+ }
+
+ align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_box_pack_start (GTK_BOX (box), align, FALSE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (align), child);
+
+ set_widget_name (child, "%s-%s-ellipsize-%s",
+ orientation ? "vertical" : "horizontal",
+ type > 1 ? "socket-xembed" :
+ type > 0 ? "socket-gtkplug" : "align",
+ i ? "end" : "none");
+
+ test_case_append_guide (test, child,
+ orientation ? GUIDE_EXTERIOUR_HORIZONTAL
+ : GUIDE_EXTERIOUR_VERTICAL,
+ orientation);
+ }
+ }
+ }
+
+ return test;
+}
+
static TestCase*
create_height_for_width_test (TestSuite *suite)
{
@@ -1823,7 +1976,7 @@ test_suite_setup_ui (TestSuite *self)
}
static TestSuite*
-test_suite_new ()
+test_suite_new (gchar *arg0)
{
TestSuite* self = g_new0 (TestSuite, 1);
@@ -1832,6 +1985,7 @@ test_suite_new ()
test_suite_append (self, create_natural_size_test (self, TRUE, FALSE));
test_suite_append (self, create_natural_size_test (self, FALSE, TRUE));
test_suite_append (self, create_natural_size_test (self, TRUE, TRUE));
+ test_suite_append (self, create_natural_socket_size_test (self, arg0));
test_suite_append (self, create_height_for_width_test (self));
test_suite_append (self, create_baseline_test (self));
test_suite_append (self, create_baseline_test_bin (self));
@@ -1842,23 +1996,102 @@ test_suite_new ()
return self;
}
+static gboolean
+on_embedding_timeout (gpointer data)
+{
+ g_print ("Embedding timeout expired. Aborting.\n");
+ gtk_main_quit ();
+ return FALSE;
+}
+
+static void
+on_embedded (GtkWidget *widget,
+ gpointer data)
+{
+ g_source_remove (GPOINTER_TO_INT (data));
+}
+
+static void
+create_plug (gboolean ellipsize,
+ gboolean vertical)
+{
+ GtkWidget *plug, *label;
+ guint timeout;
+
+ label = gtk_label_new ("Hello World");
+
+ if (ellipsize)
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ if (vertical)
+ gtk_label_set_angle (GTK_LABEL (label), 90);
+
+ plug = gtk_plug_new (0);
+ gtk_container_add (GTK_CONTAINER (plug), label);
+ gtk_widget_show_all (plug);
+
+ timeout = g_timeout_add (5 * 1000, on_embedding_timeout, NULL);
+
+ g_signal_connect (plug, "embedded",
+ G_CALLBACK (on_embedded),
+ GINT_TO_POINTER (timeout));
+ g_signal_connect (plug, "delete-event",
+ G_CALLBACK (gtk_main_quit),
+ NULL);
+
+ g_print ("%d\n", gtk_plug_get_id (GTK_PLUG (plug)));
+}
+
int
main (int argc, char *argv[])
{
- TestSuite *suite;
+ GOptionContext *options;
+ TestSuite *suite = NULL;
+ GError *error = NULL;
+
+ gboolean ellipsize = FALSE;
+ gboolean vertical = FALSE;
+ gint initial_page = 0;
+ gchar *action = NULL;
+
+ GOptionEntry entries[] =
+ {
+ { "action", 'a', 0, G_OPTION_ARG_STRING, &action, "Action to perform", NULL },
+ { "initial-page", 'p', 0, G_OPTION_ARG_INT, &initial_page, "Initial page of the test suite", NULL },
+ { "ellipsize", 0, 0, G_OPTION_ARG_NONE, &ellipsize, "Add ellipses to labels", NULL },
+ { "vertical", 0, 0, G_OPTION_ARG_NONE, &vertical, "Render vertical layout", NULL },
+ { NULL }
+ };
gtk_init (&argc, &argv);
- suite = test_suite_new ();
- gtk_widget_show_all (suite->window);
+ options = g_option_context_new (NULL);
+ g_option_context_add_main_entries (options, entries, NULL);
+ g_option_context_add_group (options, gtk_get_option_group (TRUE));
+ g_option_context_parse (options, &argc, &argv, &error);
- if (argc > 1)
- gtk_notebook_set_current_page (GTK_NOTEBOOK (suite->notebook),
- atoi (argv[1]));
+ if (error)
+ {
+ g_print ("Usage Error: %s\n", error->message);
+ return 2;
+ }
+
+ if (action && g_str_equal (action, "create-plug"))
+ {
+ create_plug (ellipsize, vertical);
+ }
+ else
+ {
+ suite = test_suite_new (argv[0]);
+ gtk_widget_show_all (suite->window);
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (suite->notebook),
+ initial_page);
+ }
gtk_main ();
- test_suite_free (suite);
+ if (suite)
+ test_suite_free (suite);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]