Commit ae065329 authored by Colomban Wendling's avatar Colomban Wendling

OVCCGtk: start using GTK 3.10 widget templates

parent 9ab55947
...@@ -28,9 +28,9 @@ AC_CHECK_PROGS([GLIB_MKENUMS], [glib-mkenums], [NONE]) ...@@ -28,9 +28,9 @@ AC_CHECK_PROGS([GLIB_MKENUMS], [glib-mkenums], [NONE])
#GTK_DOC_CHECK(1.11) #GTK_DOC_CHECK(1.11)
# Checks for libraries. # Checks for libraries.
GLIB_REQUIRE=2.32 GLIB_REQUIRE=2.38
GMODULE_REQUIRE=2.0 GMODULE_REQUIRE=2.0
GTK_REQUIRE=3.0 GTK_REQUIRE=3.10
OVCC_REQUIRE=0.0 OVCC_REQUIRE=0.0
PKG_CHECK_MODULES([OVCCGTK], [glib-2.0 >= ${GLIB_REQUIRE} PKG_CHECK_MODULES([OVCCGTK], [glib-2.0 >= ${GLIB_REQUIRE}
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
struct _OVCCGtkConnectionDialogPrivate struct _OVCCGtkConnectionDialogPrivate
{ {
GtkWidget *message; GtkWidget *messageinfo;
GtkWidget *spinner; GtkWidget *spinner;
GtkWidget *host; GtkWidget *host;
...@@ -69,9 +69,9 @@ static void ovccgtk_connection_dialog_response (GtkDialog *dialog, ...@@ -69,9 +69,9 @@ static void ovccgtk_connection_dialog_response (GtkDialog *dialog,
static gboolean ovccgtk_connection_dialog_real_validate (OVCCGtkConnectionDialog *self); static gboolean ovccgtk_connection_dialog_real_validate (OVCCGtkConnectionDialog *self);
G_DEFINE_TYPE (OVCCGtkConnectionDialog, G_DEFINE_TYPE_WITH_PRIVATE (OVCCGtkConnectionDialog,
ovccgtk_connection_dialog, ovccgtk_connection_dialog,
GTK_TYPE_DIALOG) GTK_TYPE_DIALOG)
enum enum
...@@ -184,65 +184,40 @@ ovccgtk_connection_dialog_class_init (OVCCGtkConnectionDialogClass *klass) ...@@ -184,65 +184,40 @@ ovccgtk_connection_dialog_class_init (OVCCGtkConnectionDialogClass *klass)
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
0); 0);
g_type_class_add_private (klass, sizeof (OVCCGtkConnectionDialogPrivate)); gtk_widget_class_set_template_from_resource (widget_class,
} "/org/ovccgtk/widgets/ovccgtk-connection-dialog.ui");
gtk_widget_class_bind_template_child_private (widget_class,
static GtkBuilder * OVCCGtkConnectionDialog,
builder_new_from_resource (const gchar *resource) messageinfo);
{ gtk_widget_class_bind_template_child_private (widget_class,
GtkBuilder *builder; OVCCGtkConnectionDialog,
GError *err = NULL; host);
gtk_widget_class_bind_template_child_private (widget_class,
builder = gtk_builder_new (); OVCCGtkConnectionDialog,
if (! gtk_builder_add_from_resource (builder, resource, &err)) { port);
/* aborts */ gtk_widget_class_bind_template_child_private (widget_class,
g_error ("Failed to load UI resource: %s", err->message); OVCCGtkConnectionDialog,
g_error_free (err); username);
} gtk_widget_class_bind_template_child_private (widget_class,
OVCCGtkConnectionDialog,
return builder; password);
gtk_widget_class_bind_template_callback (widget_class,
host_notify_handler);
gtk_widget_class_bind_template_callback (widget_class,
port_notify_handler);
gtk_widget_class_bind_template_callback (widget_class,
username_notify_handler);
} }
static void static void
ovccgtk_connection_dialog_init (OVCCGtkConnectionDialog *self) ovccgtk_connection_dialog_init (OVCCGtkConnectionDialog *self)
{ {
GtkWidget *content_area; self->priv = ovccgtk_connection_dialog_get_instance_private (self);
GtkBuilder *builder;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, OVCCGTK_TYPE_CONNECTION_DIALOG,
OVCCGtkConnectionDialogPrivate);
builder = builder_new_from_resource ("/org/ovccgtk/widgets/ovccgtk-connection-dialog.ui"); gtk_widget_init_template (GTK_WIDGET (self));
gtk_dialog_add_buttons (GTK_DIALOG (self),
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_CONNECT, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
gtk_container_set_border_width (GTK_CONTAINER (self), 6);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (self));
self->priv->message = (GtkWidget *) gtk_builder_get_object (builder, "messageinfo");
self->priv->host = (GtkWidget *) gtk_builder_get_object (builder, "host-entry");
self->priv->port = (GtkWidget *) gtk_builder_get_object (builder, "port-entry");
self->priv->username = (GtkWidget *) gtk_builder_get_object (builder, "username-entry");
self->priv->password = (GtkWidget *) gtk_builder_get_object (builder, "password-entry");
gtk_box_pack_start (GTK_BOX (content_area),
(GtkWidget *) gtk_builder_get_object (builder, "box1"),
TRUE, TRUE, 0);
g_signal_connect (self->priv->host, "notify::text",
G_CALLBACK (host_notify_handler), self);
g_signal_connect (self->priv->port, "notify::value",
G_CALLBACK (port_notify_handler), self);
g_signal_connect (self->priv->username, "notify::text",
G_CALLBACK (username_notify_handler), self);
gtk_widget_show_all (content_area);
g_object_unref (builder);
} }
static void static void
...@@ -564,7 +539,7 @@ ovccgtk_connection_dialog_set_message (OVCCGtkConnectionDialog *self, ...@@ -564,7 +539,7 @@ ovccgtk_connection_dialog_set_message (OVCCGtkConnectionDialog *self,
g_return_if_fail (OVCCGTK_IS_CONNECTION_DIALOG (self)); g_return_if_fail (OVCCGTK_IS_CONNECTION_DIALOG (self));
g_return_if_fail (primary != NULL); g_return_if_fail (primary != NULL);
g_object_set (self->priv->message, g_object_set (self->priv->messageinfo,
"message-type", message_type, "message-type", message_type,
"text", primary, "text", primary,
"secondary-text", secondary, "secondary-text", secondary,
......
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