diff --git a/clients/ovcc-gtk/data/Makefile.am b/clients/ovcc-gtk/data/Makefile.am index 1037b9f4b8061e42e7279cf05b48c93b982955ee..e3a816a3b395c0b1c11f7d2b999f16b164031d65 100644 --- a/clients/ovcc-gtk/data/Makefile.am +++ b/clients/ovcc-gtk/data/Makefile.am @@ -2,7 +2,8 @@ iconsdir = $(datadir) nobase_dist_icons_DATA = icons/hicolor/scalable/apps/ovccgtk.svg -dist_noinst_DATA = ovccgtk-application.ui +dist_noinst_DATA = ovccgtk-application.ui \ + ovccgtk-connection-dialog.ui # we add directory $(pkgdatadir)/icons to our lookup path, so make sure it # exists in case we aren't installed in a default prefix where icons are diff --git a/clients/ovcc-gtk/data/ovccgtk-connection-dialog.ui b/clients/ovcc-gtk/data/ovccgtk-connection-dialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..8b2ad0c214b39c42f6babff7f5408ac45fd1b6c7 --- /dev/null +++ b/clients/ovcc-gtk/data/ovccgtk-connection-dialog.ui @@ -0,0 +1,217 @@ + + + + + 65535 + 57005 + 1 + 10 + + + True + False + 6 + vertical + 12 + + + GTK_MESSAGE_INFO + + + True + True + 0 + + + + + True + False + 0 + none + + + True + False + 12 + + + True + False + 6 + + + True + False + 0 + Host: + + + False + True + 0 + + + + + True + True + True + True + + + True + True + 1 + + + + + True + False + 0 + Port: + + + False + True + 2 + + + + + True + True + True + adjustment1 + + + False + True + 3 + + + + + + + + + True + False + Server + True + + + + + + + + False + True + 1 + + + + + True + False + 0 + none + + + True + False + 12 + + + True + False + 6 + 6 + + + True + False + 0 + Name: + + + 0 + 0 + 1 + 1 + + + + + True + True + True + + + 1 + 0 + 1 + 1 + + + + + True + False + 0 + Password: + + + 0 + 1 + 1 + 1 + + + + + True + True + True + + + 1 + 1 + 1 + 1 + + + + + + + + + True + False + User + True + + + + + + + + False + True + 2 + + + + + + + + + + + diff --git a/clients/ovcc-gtk/src/ovccgtk-connection-dialog.c b/clients/ovcc-gtk/src/ovccgtk-connection-dialog.c index aeacf556de8fe9aa49644c3313c27b45d09ae81c..12949019638d8346dba1da1c001559297df32986 100644 --- a/clients/ovcc-gtk/src/ovccgtk-connection-dialog.c +++ b/clients/ovcc-gtk/src/ovccgtk-connection-dialog.c @@ -187,20 +187,33 @@ ovccgtk_connection_dialog_class_init (OVCCGtkConnectionDialogClass *klass) 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; +} + static void ovccgtk_connection_dialog_init (OVCCGtkConnectionDialog *self) { - GtkWidget *content_area; - GtkWidget *vbox; - GtkWidget *frame; - GtkWidget *box; - GtkWidget *box2; - GtkWidget *label; - GtkSizeGroup *group; + GtkWidget *content_area; + 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_dialog_add_buttons (GTK_DIALOG (self), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CONNECT, GTK_RESPONSE_OK, @@ -210,77 +223,15 @@ ovccgtk_connection_dialog_init (OVCCGtkConnectionDialog *self) content_area = gtk_dialog_get_content_area (GTK_DIALOG (self)); - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); - gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0); - - /* message */ - self->priv->message = ovccgtk_message_info_new (GTK_MESSAGE_INFO, - GTK_BUTTONS_NONE, - NULL); - gtk_box_pack_start (GTK_BOX (vbox), self->priv->message, TRUE, TRUE, 0); - - group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - /* server frame */ - frame = ovccgtk_frame_new (_("Server")); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_container_add (GTK_CONTAINER (frame), box); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (box), box2, TRUE, TRUE, 0); - - label = gtk_label_new (_("Host:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_size_group_add_widget (group, label); - gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0); - - self->priv->host = gtk_entry_new (); - gtk_entry_set_activates_default (GTK_ENTRY (self->priv->host), TRUE); - gtk_box_pack_start (GTK_BOX (box2), self->priv->host, TRUE, TRUE, 0); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (box), box2, FALSE, TRUE, 0); - - label = gtk_label_new (_("Port:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0); - - self->priv->port = gtk_spin_button_new_with_range (0, 0xffff, 1); - gtk_entry_set_activates_default (GTK_ENTRY (self->priv->port), TRUE); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->priv->port), 0xdead); - gtk_box_pack_start (GTK_BOX (box2), self->priv->port, FALSE, TRUE, 0); - - /* user frame */ - frame = ovccgtk_frame_new (_("User")); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0); - box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); - gtk_container_add (GTK_CONTAINER (frame), box); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (box), box2, TRUE, TRUE, 0); - - label = gtk_label_new (_("Name:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_size_group_add_widget (group, label); - gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0); - self->priv->username = gtk_entry_new (); - gtk_entry_set_activates_default (GTK_ENTRY (self->priv->username), TRUE); - gtk_box_pack_start (GTK_BOX (box2), self->priv->username, TRUE, TRUE, 0); - - box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); - gtk_box_pack_start (GTK_BOX (box), box2, TRUE, TRUE, 0); - - label = gtk_label_new (_("Password:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_size_group_add_widget (group, label); - gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0); - self->priv->password = gtk_entry_new (); - gtk_entry_set_activates_default (GTK_ENTRY (self->priv->password), TRUE); - gtk_entry_set_visibility (GTK_ENTRY (self->priv->password), FALSE); - gtk_box_pack_start (GTK_BOX (box2), self->priv->password, TRUE, TRUE, 0); + 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); @@ -290,6 +241,8 @@ ovccgtk_connection_dialog_init (OVCCGtkConnectionDialog *self) G_CALLBACK (username_notify_handler), self); gtk_widget_show_all (content_area); + + g_object_unref (builder); } static void @@ -566,11 +519,17 @@ void ovccgtk_connection_dialog_set_port (OVCCGtkConnectionDialog *self, guint16 port) { + guint16 oldval; + g_return_if_fail (OVCCGTK_IS_CONNECTION_DIALOG (self)); g_return_if_fail (port >= 0 && port <= 0xffff); - if (ovccgtk_connection_dialog_get_port (self) != port) { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->priv->port), port); + oldval = ovccgtk_connection_dialog_get_port (self); + /* for some reason when building the UI with GtkBuilder, the value of the + * entry is properly set to the value of its adjustment, but not actually + * displayed. Setting the value here (even to the same) fixes the issue. */ + gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->priv->port), port); + if (oldval != port) { g_object_notify (G_OBJECT (self), "port"); } } diff --git a/clients/ovcc-gtk/src/ovccgtk-resources.gresource.xml b/clients/ovcc-gtk/src/ovccgtk-resources.gresource.xml index cdf162d74c31e586907348ffd98887b0548d82a7..a6cb65a25ce2b4194f2e1d065a7362dc97c57004 100644 --- a/clients/ovcc-gtk/src/ovccgtk-resources.gresource.xml +++ b/clients/ovcc-gtk/src/ovccgtk-resources.gresource.xml @@ -1,6 +1,7 @@ + ovccgtk-connection-dialog.ui ovccgtk-application.ui