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
eta
gajim
Commits
45cb666d
Commit
45cb666d
authored
18 years ago
by
Liorithiel
Browse files
Options
Downloads
Patches
Plain Diff
Basic edition of multiple-records forms (removing/moving items).
parent
f91d9192
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dataforms_widget.py
+72
-2
72 additions, 2 deletions
src/dataforms_widget.py
with
72 additions
and
2 deletions
src/dataforms_widget.py
+
72
−
2
View file @
45cb666d
...
...
@@ -42,10 +42,12 @@ class DataFormWidget(gtk.Alignment, object):
self
.
_data_form
=
None
self
.
xml
=
gtkgui_helpers
.
get_glade
(
'
data_form_window.glade
'
,
'
data_form_vbox
'
)
self
.
xml
.
signal_autoconnect
(
self
)
for
name
in
(
'
instructions_label
'
,
'
instructions_hseparator
'
,
'
single_form_viewport
'
,
'
data_form_types_notebook
'
,
'
single_form_scrolledwindow
'
,
'
multiple_form_hbox
'
,
'
records_treeview
'
,
'
up_button
'
,
'
down_button
'
,
'
clear_button
'
):
'
records_treeview
'
,
'
add_button
'
,
'
remove_button
'
,
'
edit_button
'
,
'
up_button
'
,
'
down_button
'
,
'
clear_button
'
):
self
.
__dict__
[
name
]
=
self
.
xml
.
get_widget
(
name
)
self
.
add
(
self
.
xml
.
get_widget
(
'
data_form_vbox
'
))
...
...
@@ -53,6 +55,10 @@ class DataFormWidget(gtk.Alignment, object):
if
dataformnode
is
not
None
:
self
.
set_data_form
(
dataformnode
)
selection
=
self
.
records_treeview
.
get_selection
()
selection
.
connect
(
'
changed
'
,
self
.
on_records_selection_changed
)
selection
.
set_mode
(
gtk
.
SELECTION_MULTIPLE
)
def
set_data_form
(
self
,
dataform
):
"""
Set the data form (xmpp.DataForm) displayed in widget.
"""
assert
isinstance
(
dataform
,
dataforms
.
DataForm
)
...
...
@@ -187,7 +193,71 @@ class DataFormWidget(gtk.Alignment, object):
def
refresh_multiple_buttons
(
self
):
'''
Checks for treeview state and makes control buttons sensitive.
'''
selection
=
self
.
records_treeview
.
get_selection
()
model
=
self
.
records_treeview
.
get_model
()
count
=
selection
.
count_selected_rows
()
if
count
==
0
:
self
.
remove_button
.
set_sensitive
(
False
)
self
.
edit_button
.
set_sensitive
(
False
)
self
.
up_button
.
set_sensitive
(
False
)
self
.
down_button
.
set_sensitive
(
False
)
elif
count
==
1
:
self
.
remove_button
.
set_sensitive
(
True
)
self
.
edit_button
.
set_sensitive
(
True
)
_
,
(
path
,)
=
selection
.
get_selected_rows
()
iter
=
model
.
get_iter
(
path
)
if
model
.
iter_next
(
iter
)
is
None
:
self
.
up_button
.
set_sensitive
(
True
)
self
.
down_button
.
set_sensitive
(
False
)
elif
path
==
(
0
,):
self
.
up_button
.
set_sensitive
(
False
)
self
.
down_button
.
set_sensitive
(
True
)
else
:
self
.
up_button
.
set_sensitive
(
True
)
self
.
down_button
.
set_sensitive
(
True
)
else
:
self
.
remove_button
.
set_sensitive
(
True
)
self
.
edit_button
.
set_sensitive
(
True
)
self
.
up_button
.
set_sensitive
(
False
)
self
.
down_button
.
set_sensitive
(
False
)
if
len
(
model
)
==
0
:
self
.
clear_button
.
set_sensitive
(
False
)
else
:
self
.
clear_button
.
set_sensitive
(
True
)
def
on_clear_button_clicked
(
self
,
widget
):
self
.
records_treeview
.
get_model
().
clear
()
def
on_remove_button_clicked
(
self
,
widget
):
selection
=
self
.
records_treeview
.
get_selection
()
model
,
rowrefs
=
selection
.
get_selected_rows
()
# rowref is a list of paths
for
i
in
xrange
(
len
(
rowrefs
)):
rowrefs
[
i
]
=
gtk
.
TreeRowReference
(
model
,
rowrefs
[
i
])
# rowref is a list of row references; need to convert because we will modify the model,
# paths would change
for
rowref
in
rowrefs
:
del
model
[
rowref
.
get_path
()]
def
on_up_button_clicked
(
self
,
widget
):
selection
=
self
.
records_treeview
.
get_selection
()
model
,
(
path
,)
=
selection
.
get_selected_rows
()
iter
=
model
.
get_iter
(
path
)
previter
=
model
.
get_iter
((
path
[
0
]
-
1
,))
# constructing path for previous iter
model
.
swap
(
iter
,
previter
)
self
.
refresh_multiple_buttons
()
def
on_down_button_clicked
(
self
,
widget
):
selection
=
self
.
records_treeview
.
get_selection
()
model
,
(
path
,)
=
selection
.
get_selected_rows
()
iter
=
model
.
get_iter
(
path
)
nextiter
=
model
.
iter_next
(
iter
)
model
.
swap
(
iter
,
nextiter
)
self
.
refresh_multiple_buttons
()
def
on_records_selection_changed
(
self
,
widget
):
self
.
refresh_multiple_buttons
()
class
SingleForm
(
gtk
.
Table
,
object
):
"""
Widget that represent DATAFORM_SINGLE mode form. Because this is used
...
...
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