Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
l-n-s
gajim
Commits
44d56ac2
Commit
44d56ac2
authored
6 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Tests: Add a DataFormWidget test window
parent
09f0835f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/gtk/dataform.py
+83
-0
83 additions, 0 deletions
test/gtk/dataform.py
test/gtk/util.py
+23
-0
23 additions, 0 deletions
test/gtk/util.py
with
106 additions
and
0 deletions
test/gtk/dataform.py
0 → 100644
+
83
−
0
View file @
44d56ac2
from
gi.repository
import
Gtk
import
nbxmpp
from
gajim.gtk.dataform
import
DataFormWidget
from
gajim.common.modules.dataforms
import
extend_form
from
gajim.common.const
import
CSSPriority
from
test.gtk
import
util
util
.
load_style
(
'
gajim.css
'
,
CSSPriority
.
APPLICATION
)
FORM
=
'''
<x xmlns=
'
jabber:x:data
'
type=
'
form
'
>
<title>Bot Configuration</title>
<instructions>Fill out this form to configure your new bot!</instructions>
<field type=
'
hidden
'
var=
'
FORM_TYPE
'
>
<value>jabber:bot</value>
</field>
<field type=
'
fixed
'
><value>Section 1: Bot Info</value></field>
<field type=
'
text-single
'
label=
'
The name of your bot
'
var=
'
botname
'
>
<required/>
</field>
<field type=
'
text-multi
'
label=
'
Helpful description of your bot
'
var=
'
description
'
>
<required/>
</field>
<field type=
'
boolean
'
label=
'
Public bot?
'
var=
'
public
'
/>
<field type=
'
text-private
'
label=
'
Password for special access
'
var=
'
password
'
>
<required/>
</field>
<field type=
'
fixed
'
><value>Section 2: Features</value></field>
<field type=
'
list-multi
'
label=
'
What features will the bot support?
'
var=
'
features
'
>
<option label=
'
Contests
'
><value>contests</value></option>
<option label=
'
News
'
><value>news</value></option>
<option label=
'
Polls
'
><value>polls</value></option>
<option label=
'
Reminders
'
><value>reminders</value></option>
<option label=
'
Search
'
><value>search</value></option>
<value>news</value>
<value>search</value>
</field>
<field type=
'
fixed
'
><value>Section 3: Subscriber List</value></field>
<field type=
'
list-single
'
label=
'
Maximum number of subscribers
'
var=
'
maxsubs
'
>
<value>20</value>
<option label=
'
10
'
><value>10</value></option>
<option label=
'
20
'
><value>20</value></option>
<option label=
'
30
'
><value>30</value></option>
<option label=
'
50
'
><value>50</value></option>
<option label=
'
100
'
><value>100</value></option>
<option label=
'
None
'
><value>none</value></option>
</field>
<field type=
'
fixed
'
><value>Section 4: Invitations</value></field>
<field type=
'
jid-multi
'
label=
'
People to invite
'
var=
'
invitelist
'
>
<desc>Tell all your friends about your new bot!</desc>
<required/>
</field>
</x>
'''
class
DataFormWindow
(
Gtk
.
Window
):
def
__init__
(
self
):
Gtk
.
Window
.
__init__
(
self
,
title
=
"
Data Form Test
"
)
self
.
set_default_size
(
600
,
600
)
self
.
_widget
=
DataFormWidget
(
extend_form
(
node
=
nbxmpp
.
Node
(
node
=
FORM
)))
self
.
add
(
self
.
_widget
)
self
.
show
()
win
=
DataFormWindow
()
win
.
connect
(
"
destroy
"
,
Gtk
.
main_quit
)
win
.
show_all
()
Gtk
.
main
()
This diff is collapsed.
Click to expand it.
test/gtk/util.py
0 → 100644
+
23
−
0
View file @
44d56ac2
from
pathlib
import
Path
from
gi.repository
import
Gdk
from
gi.repository
import
Gtk
def
get_gajim_dir
():
gajim_path
=
Path
(
__file__
)
/
'
..
'
/
'
..
'
/
'
..
'
/
'
gajim
'
return
gajim_path
.
resolve
()
def
load_style
(
filename
,
priority
):
path
=
get_gajim_dir
()
/
'
data
'
/
'
style
'
/
filename
try
:
with
open
(
str
(
path
),
"
r
"
)
as
file
:
css
=
file
.
read
()
except
Exception
as
exc
:
print
(
exc
)
return
provider
=
Gtk
.
CssProvider
()
provider
.
load_from_data
(
bytes
(
css
.
encode
(
'
utf-8
'
)))
Gtk
.
StyleContext
.
add_provider_for_screen
(
Gdk
.
Screen
.
get_default
(),
provider
,
priority
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment