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}
......
......@@ -7,6 +7,57 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<template class="OVCCGtkConnectionDialog" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button-cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button-connect">
<property name="label">gtk-connect</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<property name="can_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -15,6 +66,7 @@
<property name="spacing">12</property>
<child>
<object class="OVCCGtkMessageInfo" type-func="ovccgtk_message_info_get_type" id="messageinfo">
<property name="visible">True</property>
<property name="message-type">GTK_MESSAGE_INFO</property>
</object>
<packing>
......@@ -53,11 +105,12 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="host-entry">
<object class="GtkEntry" id="host">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
<signal name="notify::text" handler="host_notify_handler" />
</object>
<packing>
<property name="expand">True</property>
......@@ -79,11 +132,12 @@
</packing>
</child>
<child>
<object class="GtkSpinButton" id="port-entry">
<object class="GtkSpinButton" id="port">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustment1</property>
<signal name="notify::value" handler="port_notify_handler" />
</object>
<packing>
<property name="expand">False</property>
......@@ -145,10 +199,11 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="username-entry">
<object class="GtkEntry" id="username">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<signal name="notify::text" handler="username_notify_handler" />
</object>
<packing>
<property name="left_attach">1</property>
......@@ -172,7 +227,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="password-entry">
<object class="GtkEntry" id="password">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
......@@ -207,6 +262,19 @@
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">button-cancel</action-widget>
<action-widget response="-5">button-connect</action-widget>
</action-widgets>
</template>
<object class="GtkSizeGroup" id="sizegroup1">
<widgets>
<widget name="label2"/>
......
......@@ -34,7 +34,7 @@
struct _OVCCGtkConnectionDialogPrivate
{
GtkWidget *message;
GtkWidget *messageinfo;
GtkWidget *spinner;
GtkWidget *host;
......@@ -69,7 +69,7 @@ static void ovccgtk_connection_dialog_response (GtkDialog *dialog,
static gboolean ovccgtk_connection_dialog_real_validate (OVCCGtkConnectionDialog *self);
G_DEFINE_TYPE (OVCCGtkConnectionDialog,
G_DEFINE_TYPE_WITH_PRIVATE (OVCCGtkConnectionDialog,
ovccgtk_connection_dialog,
GTK_TYPE_DIALOG)
......@@ -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