Commit 99f93841 authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

Improved the gcompris editor. Now columns are of fixed size which

	makes the UI cleaner.
	Implemented the multiselection support in edit dialog.
	Implemented the remove button in the edit dialog.
parent b67b0a9a
2005-07-18 Bruno coudoin <bruno.coudoin@free.fr>
Improved the gcompris editor. Now columns are of fixed size which
makes the UI cleaner.
Implemented the multiselection support in edit dialog.
Implemented the remove button in the edit dialog.
* po/POTFILES.in:
* src/boards/python/admin/class_edit.py:
* src/boards/python/admin/class_list.py:
* src/boards/python/admin/constants.py:
* src/boards/python/admin/group_edit.py:
* src/boards/python/admin/group_list.py:
* src/boards/python/admin/group_user_list.py:
* src/boards/python/admin/user_list.py:
* src/gcompris/board.c: (init_plugins):
2005-07-18 Yves Combe <yves@ycombe.net>
add missing files.
......
......@@ -208,6 +208,7 @@ src/boards/python/admin/module_groups.py
src/boards/python/admin/module_profiles.py
src/boards/python/admin/user_list.py
src/boards/python/admin/group_edit.py
src/boards/python/admin/group_list.py
src/boards/python/admin/group_user_list.py
src/boards/python/admin/module_users.py
src/boards/python/anim.py
......
......@@ -25,6 +25,8 @@ from gettext import gettext as _
# Database
from pysqlite2 import dbapi2 as sqlite
import constants
# User List Management
(
COLUMN_USERID,
......@@ -80,6 +82,7 @@ class ClassEdit(gtk.Window):
treeview = gtk.TreeView(self.model_left)
treeview.set_rules_hint(True)
treeview.set_search_column(COLUMN_FIRSTNAME)
treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
sw.add(treeview)
......@@ -95,9 +98,12 @@ class ClassEdit(gtk.Window):
vbox2.set_border_width(8)
hbox.pack_start(vbox2, True, True, 0)
button_add = gtk.Button(_("Add user >"))
vbox2.pack_start(button_add, False, False, 0)
button_add = gtk.Button(stock='gtk-add')
button_add.connect("clicked", self.add_user, treeview)
vbox2.pack_start(button_add, False, False, 0)
button_delete = gtk.Button(stock='gtk-delete')
vbox2.pack_start(button_delete, False, False, 0)
# Right List
# ----------
......@@ -114,6 +120,7 @@ class ClassEdit(gtk.Window):
treeview2 = gtk.TreeView(self.model_right)
treeview2.set_rules_hint(True)
treeview2.set_search_column(COLUMN_FIRSTNAME)
treeview2.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
sw2.add(treeview2)
......@@ -140,6 +147,9 @@ class ClassEdit(gtk.Window):
vbox.pack_start(bbox, False, False, 0)
# Missing callbacks
button_delete.connect("clicked", self.remove_user, treeview2)
# Ready GO
self.show_all()
......@@ -192,6 +202,8 @@ class ClassEdit(gtk.Window):
text=COLUMN_FIRSTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_FIRSTNAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_FIRSTNAME)
treeview.append_column(column)
# column for last name
......@@ -201,16 +213,20 @@ class ClassEdit(gtk.Window):
text=COLUMN_LASTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_LASTNAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_LASTNAME)
treeview.append_column(column)
# Add a user from the left list to the right list
#
def add_user(self, button, treeview):
selection = treeview.get_selection()
model, iter = selection.get_selected()
if iter:
model = treeview.get_model()
treestore, paths = treeview.get_selection().get_selected_rows()
paths.reverse()
for path in paths:
iter = treestore.get_iter(path)
path = model.get_path(iter)[0]
user_id = model.get_value(iter, COLUMN_USERID)
user_firstname = model.get_value(iter, COLUMN_FIRSTNAME)
......@@ -224,6 +240,28 @@ class ClassEdit(gtk.Window):
self.cur.execute('update users set class_id=? where user_id=?', (self.class_id, user_id))
self.con.commit()
# Remove a user from the right list to the left list
#
def remove_user(self, button, treeview):
model = treeview.get_model()
treestore, paths = treeview.get_selection().get_selected_rows()
paths.reverse()
for path in paths:
iter = treestore.get_iter(path)
path = model.get_path(iter)[0]
user_id = model.get_value(iter, COLUMN_USERID)
user_firstname = model.get_value(iter, COLUMN_FIRSTNAME)
user_lastname = model.get_value(iter, COLUMN_LASTNAME)
model.remove(iter)
# Add in the the left view
self.add_user_in_model(self.model_left, (user_id, user_firstname, user_lastname))
# Save the change in the base (set an impossible class_id)
self.cur.execute('update users set class_id=? where user_id=?', (-1, user_id))
self.con.commit()
# Done, can quit this dialog
#
......
......@@ -30,6 +30,8 @@ from gettext import gettext as _
# Database
from pysqlite2 import dbapi2 as sqlite
import constants
import class_edit
import user_list
......@@ -176,6 +178,8 @@ class Class_list:
model = treeview.get_model()
# Total column length must be 400
# columns for name
renderer = gtk.CellRendererText()
renderer.connect("edited", self.on_cell_class_edited, model)
......@@ -184,9 +188,11 @@ class Class_list:
text=COLUMN_NAME,
editable=COLUMN_CLASS_EDITABLE)
column.set_sort_column_id(COLUMN_NAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_CLASSNAME)
treeview.append_column(column)
# columns for first name
# columns for teacher
renderer = gtk.CellRendererText()
renderer.connect("edited", self.on_cell_class_edited, model)
renderer.set_data("column", COLUMN_TEACHER)
......@@ -194,6 +200,8 @@ class Class_list:
text=COLUMN_TEACHER,
editable=COLUMN_CLASS_EDITABLE)
column.set_sort_column_id(COLUMN_TEACHER)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_TEACHER)
treeview.append_column(column)
......
# gcompris - constants.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Some common constants for the administration
COLUMN_WIDTH_LOGIN = 80
COLUMN_WIDTH_FIRSTNAME = 100
COLUMN_WIDTH_LASTNAME = 180
COLUMN_WIDTH_BIRTHDATE = 40
COLUMN_WIDTH_CLASSNAME = 100
COLUMN_WIDTH_TEACHER = 300
COLUMN_WIDTH_GROUPNAME = 100
COLUMN_WIDTH_GROUPDESCRIPTION = 300
......@@ -22,6 +22,8 @@ import gtk
import gobject
from gettext import gettext as _
import constants
# Database
from pysqlite2 import dbapi2 as sqlite
......@@ -35,13 +37,14 @@ from pysqlite2 import dbapi2 as sqlite
class GroupEdit(gtk.Window):
counter = 1
def __init__(self, db_connect, db_cursor,
class_id, class_name,
group_id, group_name):
# Create the toplevel window
gtk.Window.__init__(self)
print constants.COLUMN_WIDTH_LOGIN
self.cur = db_cursor
self.con = db_connect
......@@ -84,7 +87,8 @@ class GroupEdit(gtk.Window):
treeview = gtk.TreeView(self.model_left)
treeview.set_rules_hint(True)
treeview.set_search_column(COLUMN_FIRSTNAME)
treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
sw.add(treeview)
# add columns to the tree view
......@@ -99,9 +103,15 @@ class GroupEdit(gtk.Window):
vbox2.set_border_width(8)
hbox.pack_start(vbox2, True, True, 0)
button_add = gtk.Button(_("Add user >"))
vbox2.pack_start(button_add, False, False, 0)
button_add.connect("clicked", self.add_user, treeview)
button = gtk.Button(stock='gtk-add')
button.connect("clicked", self.add_user, treeview)
vbox2.pack_start(button, False, False, 0)
button.show()
button_delete = gtk.Button(stock='gtk-delete')
vbox2.pack_start(button_delete, False, False, 0)
button_delete.show()
# Right List
# ----------
......@@ -118,6 +128,7 @@ class GroupEdit(gtk.Window):
treeview2 = gtk.TreeView(self.model_right)
treeview2.set_rules_hint(True)
treeview2.set_search_column(COLUMN_FIRSTNAME)
treeview2.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
sw2.add(treeview2)
......@@ -143,7 +154,10 @@ class GroupEdit(gtk.Window):
button.connect("clicked", self.close)
vbox.pack_start(bbox, False, False, 0)
# Missing callbacks
button_delete.connect("clicked", self.remove_user, treeview2)
# Ready GO
self.show_all()
......@@ -200,7 +214,7 @@ class GroupEdit(gtk.Window):
def __add_columns(self, treeview):
model = treeview.get_model()
# columns for first name
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_FIRSTNAME)
......@@ -208,6 +222,8 @@ class GroupEdit(gtk.Window):
text=COLUMN_FIRSTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_FIRSTNAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_FIRSTNAME)
treeview.append_column(column)
# column for last name
......@@ -217,16 +233,25 @@ class GroupEdit(gtk.Window):
text=COLUMN_LASTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_LASTNAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_LASTNAME)
treeview.append_column(column)
# Add a user from the left list to the right list
#
def add_user(self, button, treeview):
selection = treeview.get_selection()
model, iter = selection.get_selected()
if iter:
model = treeview.get_model()
treestore, paths = treeview.get_selection().get_selected_rows()
paths.reverse()
for path in paths:
iter = treestore.get_iter(path)
path = model.get_path(iter)[0]
user_id = model.get_value(iter, COLUMN_USERID)
user_firstname = model.get_value(iter, COLUMN_FIRSTNAME)
......@@ -237,10 +262,41 @@ class GroupEdit(gtk.Window):
self.add_user_in_model(self.model_right, (user_id, user_firstname, user_lastname))
# Save the change in the base
self.cur.execute('insert or replace into list_users_in_groups (group_id, user_id) values (?, ?)', (self.group_id, user_id))
self.cur.execute('insert or replace into list_users_in_groups (group_id, user_id) values (?, ?)',
(self.group_id, user_id))
self.con.commit()
# Add a user from the left list to the right list
#
def remove_user(self, button, treeview):
model = treeview.get_model()
treestore, paths = treeview.get_selection().get_selected_rows()
paths.reverse()
for path in paths:
iter = treestore.get_iter(path)
path = model.get_path(iter)[0]
user_id = model.get_value(iter, COLUMN_USERID)
user_firstname = model.get_value(iter, COLUMN_FIRSTNAME)
user_lastname = model.get_value(iter, COLUMN_LASTNAME)
model.remove(iter)
# Add in the the left view
self.add_user_in_model(self.model_left, (user_id, user_firstname, user_lastname))
# Save the change in the base
self.cur.execute('delete from list_users_in_groups where group_id=? and user_id=?',
(self.group_id, user_id))
self.con.commit()
# Done, can quit this dialog
#
def close(self, button):
......
......@@ -33,6 +33,8 @@ from pysqlite2 import dbapi2 as sqlite
import group_user_list
import group_edit
import constants
# Group Management
(
COLUMN_GROUPID,
......@@ -224,6 +226,8 @@ class Group_list:
text=COLUMN_NAME,
editable=COLUMN_GROUP_EDITABLE)
column.set_sort_column_id(COLUMN_NAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_GROUPNAME)
treeview.append_column(column)
# columns for description
......@@ -234,6 +238,8 @@ class Group_list:
text=COLUMN_DESCRIPTION,
editable=COLUMN_GROUP_EDITABLE)
column.set_sort_column_id(COLUMN_DESCRIPTION)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_GROUPDESCRIPTION)
treeview.append_column(column)
......
......@@ -27,6 +27,8 @@ import gtk.gdk
import gobject
from gettext import gettext as _
import constants
# Database
from pysqlite2 import dbapi2 as sqlite
......@@ -141,6 +143,8 @@ class Group_user_list:
model = treeview.get_model()
# Total column lengh must be 400
# columns for login
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_LOGIN)
......@@ -148,6 +152,8 @@ class Group_user_list:
text=COLUMN_LOGIN,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_LOGIN)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_LOGIN)
treeview.append_column(column)
# columns for first name
......@@ -157,6 +163,8 @@ class Group_user_list:
text=COLUMN_FIRSTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_FIRSTNAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_FIRSTNAME)
treeview.append_column(column)
# column for last name
......@@ -166,6 +174,8 @@ class Group_user_list:
text=COLUMN_LASTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_LASTNAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_LASTNAME)
treeview.append_column(column)
# column for birth date
......@@ -175,6 +185,8 @@ class Group_user_list:
text=COLUMN_BIRTHDATE,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_BIRTHDATE)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_BIRTHDATE)
treeview.append_column(column)
......
......@@ -29,6 +29,8 @@ from gettext import gettext as _
# Database
from pysqlite2 import dbapi2 as sqlite
import constants
# User Management
(
COLUMN_USERID,
......@@ -158,6 +160,8 @@ class User_list:
def __add_columns(self, treeview):
# Total column lengh must be 400
model = treeview.get_model()
......@@ -169,6 +173,8 @@ class User_list:
text=COLUMN_LOGIN,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_LOGIN)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_LOGIN)
treeview.append_column(column)
# columns for first name
......@@ -179,6 +185,8 @@ class User_list:
text=COLUMN_FIRSTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_FIRSTNAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_FIRSTNAME)
treeview.append_column(column)
# column for last name
......@@ -189,6 +197,8 @@ class User_list:
text=COLUMN_LASTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_LASTNAME)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_LASTNAME)
treeview.append_column(column)
# column for birth date
......@@ -199,6 +209,8 @@ class User_list:
text=COLUMN_BIRTHDATE,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_BIRTHDATE)
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
column.set_fixed_width(constants.COLUMN_WIDTH_BIRTHDATE)
treeview.append_column(column)
......
......@@ -99,7 +99,6 @@ void init_plugins(void)
static_boards_demo[i++] = get_erase_bplugin_info();
static_boards_demo[i++] = get_gletters_bplugin_info();
static_boards_demo[i++] = get_hanoi_bplugin_info();
static_boards_demo[i++] = get_menu_bplugin_info();
static_boards_demo[i++] = get_reading_bplugin_info();
static_boards_demo[i++] = get_submarine_bplugin_info();
static_boards_demo[i++] = get_superbrain_bplugin_info();
......
Supports Markdown
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