Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Open Virtual Carcassonne Clone
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jonathan Michalon
Open Virtual Carcassonne Clone
Commits
70ea590c
Commit
70ea590c
authored
Jan 08, 2014
by
Colomban Wendling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OVCCGtk: use GtkBuilder to create the connection dialog
parent
be47f4c9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
258 additions
and
80 deletions
+258
-80
clients/ovcc-gtk/data/Makefile.am
clients/ovcc-gtk/data/Makefile.am
+2
-1
clients/ovcc-gtk/data/ovccgtk-connection-dialog.ui
clients/ovcc-gtk/data/ovccgtk-connection-dialog.ui
+217
-0
clients/ovcc-gtk/src/ovccgtk-connection-dialog.c
clients/ovcc-gtk/src/ovccgtk-connection-dialog.c
+38
-79
clients/ovcc-gtk/src/ovccgtk-resources.gresource.xml
clients/ovcc-gtk/src/ovccgtk-resources.gresource.xml
+1
-0
No files found.
clients/ovcc-gtk/data/Makefile.am
View file @
70ea590c
...
...
@@ -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
...
...
clients/ovcc-gtk/data/ovccgtk-connection-dialog.ui
0 → 100644
View file @
70ea590c
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object
class=
"GtkAdjustment"
id=
"adjustment1"
>
<property
name=
"upper"
>
65535
</property>
<property
name=
"value"
>
57005
</property>
<property
name=
"step_increment"
>
1
</property>
<property
name=
"page_increment"
>
10
</property>
</object>
<object
class=
"GtkBox"
id=
"box1"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"border_width"
>
6
</property>
<property
name=
"orientation"
>
vertical
</property>
<property
name=
"spacing"
>
12
</property>
<child>
<object
class=
"OVCCGtkMessageInfo"
type-func=
"ovccgtk_message_info_get_type"
id=
"messageinfo"
>
<property
name=
"message-type"
>
GTK_MESSAGE_INFO
</property>
</object>
<packing>
<property
name=
"expand"
>
True
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
0
</property>
</packing>
</child>
<child>
<object
class=
"GtkFrame"
id=
"frame1"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"label_xalign"
>
0
</property>
<property
name=
"shadow_type"
>
none
</property>
<child>
<object
class=
"GtkAlignment"
id=
"alignment1"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"left_padding"
>
12
</property>
<child>
<object
class=
"GtkBox"
id=
"box2"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"spacing"
>
6
</property>
<child>
<object
class=
"GtkLabel"
id=
"label2"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"xalign"
>
0
</property>
<property
name=
"label"
translatable=
"yes"
>
Host:
</property>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
0
</property>
</packing>
</child>
<child>
<object
class=
"GtkEntry"
id=
"host-entry"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"hexpand"
>
True
</property>
<property
name=
"activates_default"
>
True
</property>
</object>
<packing>
<property
name=
"expand"
>
True
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
1
</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
id=
"label3"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"xalign"
>
0
</property>
<property
name=
"label"
translatable=
"yes"
>
Port:
</property>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
2
</property>
</packing>
</child>
<child>
<object
class=
"GtkSpinButton"
id=
"port-entry"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"activates_default"
>
True
</property>
<property
name=
"adjustment"
>
adjustment1
</property>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
3
</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child
type=
"label"
>
<object
class=
"GtkLabel"
id=
"label1"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"label"
translatable=
"yes"
>
Server
</property>
<property
name=
"use_markup"
>
True
</property>
<attributes>
<attribute
name=
"weight"
value=
"bold"
/>
</attributes>
</object>
</child>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
1
</property>
</packing>
</child>
<child>
<object
class=
"GtkFrame"
id=
"frame2"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"label_xalign"
>
0
</property>
<property
name=
"shadow_type"
>
none
</property>
<child>
<object
class=
"GtkAlignment"
id=
"alignment2"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"left_padding"
>
12
</property>
<child>
<object
class=
"GtkGrid"
id=
"grid1"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"row_spacing"
>
6
</property>
<property
name=
"column_spacing"
>
6
</property>
<child>
<object
class=
"GtkLabel"
id=
"label5"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"xalign"
>
0
</property>
<property
name=
"label"
translatable=
"yes"
>
Name:
</property>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
0
</property>
<property
name=
"width"
>
1
</property>
<property
name=
"height"
>
1
</property>
</packing>
</child>
<child>
<object
class=
"GtkEntry"
id=
"username-entry"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"hexpand"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"top_attach"
>
0
</property>
<property
name=
"width"
>
1
</property>
<property
name=
"height"
>
1
</property>
</packing>
</child>
<child>
<object
class=
"GtkLabel"
id=
"label6"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"xalign"
>
0
</property>
<property
name=
"label"
translatable=
"yes"
>
Password:
</property>
</object>
<packing>
<property
name=
"left_attach"
>
0
</property>
<property
name=
"top_attach"
>
1
</property>
<property
name=
"width"
>
1
</property>
<property
name=
"height"
>
1
</property>
</packing>
</child>
<child>
<object
class=
"GtkEntry"
id=
"password-entry"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
True
</property>
<property
name=
"hexpand"
>
True
</property>
</object>
<packing>
<property
name=
"left_attach"
>
1
</property>
<property
name=
"top_attach"
>
1
</property>
<property
name=
"width"
>
1
</property>
<property
name=
"height"
>
1
</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child
type=
"label"
>
<object
class=
"GtkLabel"
id=
"label4"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can_focus"
>
False
</property>
<property
name=
"label"
translatable=
"yes"
>
User
</property>
<property
name=
"use_markup"
>
True
</property>
<attributes>
<attribute
name=
"weight"
value=
"bold"
/>
</attributes>
</object>
</child>
</object>
<packing>
<property
name=
"expand"
>
False
</property>
<property
name=
"fill"
>
True
</property>
<property
name=
"position"
>
2
</property>
</packing>
</child>
</object>
<object
class=
"GtkSizeGroup"
id=
"sizegroup1"
>
<widgets>
<widget
name=
"label2"
/>
<widget
name=
"label5"
/>
<widget
name=
"label6"
/>
</widgets>
</object>
</interface>
clients/ovcc-gtk/src/ovccgtk-connection-dialog.c
View file @
70ea590c
...
...
@@ -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"
);
}
}
...
...
clients/ovcc-gtk/src/ovccgtk-resources.gresource.xml
View file @
70ea590c
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource
prefix=
"/org/ovccgtk/widgets"
>
<file
preprocess=
"xml-stripblanks"
>
ovccgtk-connection-dialog.ui
</file>
<file
preprocess=
"xml-stripblanks"
>
ovccgtk-application.ui
</file>
</gresource>
</gresources>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment