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])
#GTK_DOC_CHECK(1.11)
# Checks for libraries.
GLIB_REQUIRE=2.32
GLIB_REQUIRE=2.38
GMODULE_REQUIRE=2.0
GTK_REQUIRE=3.0
GTK_REQUIRE=3.10
OVCC_REQUIRE=0.0
PKG_CHECK_MODULES([OVCCGTK], [glib-2.0 >= ${GLIB_REQUIRE}
......
......@@ -34,7 +34,7 @@
struct _OVCCGtkConnectionDialogPrivate
{
GtkWidget *message;
GtkWidget *messageinfo;
GtkWidget *spinner;
GtkWidget *host;
......@@ -69,9 +69,9 @@ static void ovccgtk_connection_dialog_response (GtkDialog *dialog,
static gboolean ovccgtk_connection_dialog_real_validate (OVCCGtkConnectionDialog *self);
G_DEFINE_TYPE (OVCCGtkConnectionDialog,
ovccgtk_connection_dialog,
GTK_TYPE_DIALOG)
G_DEFINE_TYPE_WITH_PRIVATE (OVCCGtkConnectionDialog,
ovccgtk_connection_dialog,
GTK_TYPE_DIALOG)
enum
......@@ -184,65 +184,40 @@ ovccgtk_connection_dialog_class_init (OVCCGtkConnectionDialogClass *klass)
G_TYPE_BOOLEAN,
0);
g_type_class_add_private (klass, sizeof (OVCCGtkConnectionDialogPrivate));
}
static GtkBuilder *
builder_new_from_resource (const gchar *resource)
{
GtkBuilder *builder;
GError *err = NULL;
builder = gtk_builder_new ();
if (! gtk_builder_add_from_resource (builder, resource, &err)) {
/* aborts */
g_error ("Failed to load UI resource: %s", err->message);
g_error_free (err);
}
return builder;
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,
OVCCGtkConnectionDialog,
messageinfo);
gtk_widget_class_bind_template_child_private (widget_class,
OVCCGtkConnectionDialog,
host);
gtk_widget_class_bind_template_child_private (widget_class,
OVCCGtkConnectionDialog,
port);
gtk_widget_class_bind_template_child_private (widget_class,
OVCCGtkConnectionDialog,
username);
gtk_widget_class_bind_template_child_private (widget_class,
OVCCGtkConnectionDialog,
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
ovccgtk_connection_dialog_init (OVCCGtkConnectionDialog *self)
{
GtkWidget *content_area;
GtkBuilder *builder;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, OVCCGTK_TYPE_CONNECTION_DIALOG,
OVCCGtkConnectionDialogPrivate);
self->priv = ovccgtk_connection_dialog_get_instance_private (self);
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_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
......@@ -564,7 +539,7 @@ ovccgtk_connection_dialog_set_message (OVCCGtkConnectionDialog *self,
g_return_if_fail (OVCCGTK_IS_CONNECTION_DIALOG (self));
g_return_if_fail (primary != NULL);
g_object_set (self->priv->message,
g_object_set (self->priv->messageinfo,
"message-type", message_type,
"text", primary,
"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