Commit a7d72e5c authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

group edition start to works. new file for group edition same force

	* src/boards/python/admin/class_edit.py: group edition start to works.
	* admin/group_edit.py: new file for group edition
	* admin/group_user_list.py: same
	* src/gcompris/gcompris.c: (gcompris_init): force fullscreen off in edit mode.
parent d71cb6ad
2005-07-11 Bruno coudoin <bruno.coudoin@free.fr>
* src/boards/python/admin/class_edit.py: group edition start to works.
* admin/group_edit.py: new file for group edition
* admin/group_user_list.py: same
* src/gcompris/gcompris.c: (gcompris_init): force fullscreen off in edit mode.
2005-07-10 Yves Combe,,, <yves@ycombe.net>
board conf by profile, user/class db access.
......
......@@ -143,51 +143,6 @@ class ClassEdit(gtk.Window):
# Ready GO
self.show_all()
def on_interactive_dialog_clicked(self, button):
dialog = gtk.Dialog("Interactive Dialog", self, 0,
(gtk.STOCK_OK, gtk.RESPONSE_OK,
"_Non-stock button", gtk.RESPONSE_CANCEL))
hbox = gtk.HBox(False, 8)
hbox.set_border_width(8)
dialog.vbox.pack_start(hbox, False, False, 0)
stock = gtk.image_new_from_stock(
gtk.STOCK_DIALOG_QUESTION,
gtk.ICON_SIZE_DIALOG)
hbox.pack_start(stock, False, False, 0)
table = gtk.Table(2, 2)
table.set_row_spacings(4)
table.set_col_spacings(4)
hbox.pack_start(table, True, True, 0)
label = gtk.Label("Entry _1")
label.set_use_underline(True)
table.attach(label, 0, 1, 0, 1)
local_entry1 = gtk.Entry()
local_entry1.set_text(self.entry1.get_text())
table.attach(local_entry1, 1, 2, 0, 1)
label.set_mnemonic_widget(local_entry1)
label = gtk.Label("Entry _2")
label.set_use_underline(True)
table.attach(label, 0, 1, 1, 2)
local_entry2 = gtk.Entry()
local_entry2.set_text(self.entry2.get_text())
table.attach(local_entry2, 1, 2, 1, 2)
label.set_mnemonic_widget(local_entry2)
dialog.show_all()
response = dialog.run()
if response == gtk.RESPONSE_OK:
self.entry1.set_text(local_entry1.get_text())
self.entry2.set_text(local_entry2.get_text())
dialog.destroy()
# -------------------
# User Management
......
# gcompris - group_edit.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
#
import gtk
import gobject
from gettext import gettext as _
# Database
from pysqlite2 import dbapi2 as sqlite
# User List Management
(
COLUMN_USERID,
COLUMN_FIRSTNAME,
COLUMN_LASTNAME,
COLUMN_USER_EDITABLE
) = range(4)
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)
self.cur = db_cursor
self.con = db_connect
self.group_id = group_id
self.class_id = class_id
self.set_title(_("Group Edition"))
self.set_border_width(8)
self.set_default_size(320, 350)
frame = gtk.Frame(_("Editing group: ") + group_name
+ _(" for class: ") + class_name)
self.add(frame)
vbox = gtk.VBox(False, 8)
vbox.set_border_width(8)
frame.add(vbox)
# Top message gives instructions
label = gtk.Label(_('Assign all the users bellonging to this group'))
vbox.pack_start(label, False, False, 0)
vbox.pack_start(gtk.HSeparator(), False, False, 0)
# Lower area
hbox = gtk.HBox(False, 8)
vbox.pack_start(hbox, True, True, 0)
# Left list
# ---------
# Create the table
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
# create tree model
self.model_left = self.__create_model(False, group_id)
# create tree view
treeview = gtk.TreeView(self.model_left)
treeview.set_rules_hint(True)
treeview.set_search_column(COLUMN_FIRSTNAME)
sw.add(treeview)
# add columns to the tree view
self.__add_columns(treeview)
hbox.pack_start(sw, True, True, 0)
# Middle Button
# -------------
vbox2 = gtk.VBox(False, 8)
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)
# Right List
# ----------
# Create the table
sw2 = gtk.ScrolledWindow()
sw2.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw2.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
# create tree model
self.model_right = self.__create_model(True, group_id)
# create tree view
treeview2 = gtk.TreeView(self.model_right)
treeview2.set_rules_hint(True)
treeview2.set_search_column(COLUMN_FIRSTNAME)
sw2.add(treeview2)
# add columns to the tree view
self.__add_columns(treeview2)
hbox.pack_start(sw2, True, True, 0)
# Confirmation Buttons
# --------------------
vbox.pack_start(gtk.HSeparator(), False, False, 0)
bbox = gtk.HButtonBox()
bbox.set_border_width(5)
bbox.set_layout(gtk.BUTTONBOX_EDGE)
bbox.set_spacing(40)
button = gtk.Button(stock='gtk-help')
bbox.add(button)
button = gtk.Button(stock='gtk-close')
bbox.add(button)
button.connect("clicked", self.close)
vbox.pack_start(bbox, False, False, 0)
# Ready GO
self.show_all()
# -------------------
# User Management
# -------------------
# Add user in the model
def add_user_in_model(self, model, user):
iter = model.append()
model.set (iter,
COLUMN_USERID, user[COLUMN_USERID],
COLUMN_FIRSTNAME, user[COLUMN_FIRSTNAME],
COLUMN_LASTNAME, user[COLUMN_LASTNAME],
COLUMN_USER_EDITABLE, False
)
# If group_id is provided, only users in this group are inserted
# If with = True, create a list only with the given group_id.
# False, create a list only without the given group_id
def __create_model(self, with, class_id):
# Grab the user data
if(with):
self.cur.execute('select user_id,firstname,lastname from users where class_id=?', (class_id,))
else:
self.cur.execute('select user_id,firstname,lastname from users where class_id!=?', (class_id,))
user_data = self.cur.fetchall()
model = gtk.ListStore(
gobject.TYPE_INT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_BOOLEAN)
for user in user_data:
self.add_user_in_model(model, user)
return model
def __add_columns(self, treeview):
model = treeview.get_model()
# columns for first name
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_FIRSTNAME)
column = gtk.TreeViewColumn(_('First Name'), renderer,
text=COLUMN_FIRSTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_FIRSTNAME)
treeview.append_column(column)
# column for last name
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_LASTNAME)
column = gtk.TreeViewColumn(_('Last Name'), renderer,
text=COLUMN_LASTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_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:
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 right view
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.con.commit()
# Done, can quit this dialog
#
def close(self, button):
self.destroy()
# gcompris - group_user_list.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
#
import gnome
import gnome.canvas
import gcompris
import gcompris.utils
import gcompris.skin
import gtk
import gtk.gdk
import gobject
from gettext import gettext as _
# Database
from pysqlite2 import dbapi2 as sqlite
#import group_edit
# User Management
(
COLUMN_USERID,
COLUMN_LOGIN,
COLUMN_FIRSTNAME,
COLUMN_LASTNAME,
COLUMN_BIRTHDATE,
COLUMN_CLASS,
COLUMN_USER_EDITABLE
) = range(7)
class Group_user_list:
"""GCompris Group User List Table"""
# area is the drawing area for the list
#
# return the list item
#
def __init__(self, container, db_connect, db_cursor, group_id):
self.cur = db_cursor
self.con = db_connect
# The group_id to work on
self.group_id = group_id
# ---------------
# User Group Management
# ---------------
# create tree model
self.model = self.__create_model()
self.reload(self.group_id)
# Create the table
sw = gtk.ScrolledWindow()
sw.show()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
# create tree view
treeview_group = gtk.TreeView(self.model)
treeview_group.show()
treeview_group.set_rules_hint(True)
treeview_group.set_search_column(COLUMN_FIRSTNAME)
sw.add(treeview_group)
# add columns to the tree view
self.__add_columns(treeview_group)
container.pack_start(sw)
# -------------------
# User Management
# -------------------
# Retrieve data from the database for the given group_id
def reload(self, group_id):
print "Reloading group_user_list for group_id=" + str(group_id)
self.group_id = group_id
# Remove all entries in the list
self.model.clear()
self.cur.execute('select user_id from list_users_in_groups where group_id=?', (self.group_id,))
list_user_id = self.cur.fetchall()
# Now retrieve users detail
print list_user_id
for user_id in list_user_id:
print user_id
self.cur.execute('select * from users where user_id=?', user_id)
user = self.cur.fetchall()[0]
print user
self.add_user_in_model(self.model, user)
# Add user in the model
def add_user_in_model(self, model, user):
iter = model.append()
model.set (iter,
COLUMN_USERID, user[COLUMN_USERID],
COLUMN_LOGIN, user[COLUMN_LOGIN],
COLUMN_FIRSTNAME, user[COLUMN_FIRSTNAME],
COLUMN_LASTNAME, user[COLUMN_LASTNAME],
COLUMN_BIRTHDATE, user[COLUMN_BIRTHDATE],
COLUMN_CLASS, user[COLUMN_CLASS],
COLUMN_USER_EDITABLE, True
)
def __create_model(self):
model = gtk.ListStore(
gobject.TYPE_INT,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_STRING,
gobject.TYPE_INT,
gobject.TYPE_BOOLEAN)
return model
def __add_columns(self, treeview):
model = treeview.get_model()
# columns for login
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_LOGIN)
column = gtk.TreeViewColumn(_('Login'), renderer,
text=COLUMN_LOGIN,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_LOGIN)
treeview.append_column(column)
# columns for first name
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_FIRSTNAME)
column = gtk.TreeViewColumn(_('First Name'), renderer,
text=COLUMN_FIRSTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_FIRSTNAME)
treeview.append_column(column)
# column for last name
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_LASTNAME)
column = gtk.TreeViewColumn(_('Last Name'), renderer,
text=COLUMN_LASTNAME,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_LASTNAME)
treeview.append_column(column)
# column for birth date
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_BIRTHDATE)
column = gtk.TreeViewColumn(_('Birth Date'), renderer,
text=COLUMN_BIRTHDATE,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_BIRTHDATE)
treeview.append_column(column)
# column for class
renderer = gtk.CellRendererText()
renderer.set_data("column", COLUMN_CLASS)
column = gtk.TreeViewColumn(_('Class'), renderer,
text=COLUMN_CLASS,
editable=COLUMN_USER_EDITABLE)
column.set_sort_column_id(COLUMN_CLASS)
treeview.append_column(column)
/* gcompris - gcompris.c
*
* Time-stamp: <2005/07/09 23:20:37 yves>
* Time-stamp: <2005/07/10 23:38:14 bruno>
*
* Copyright (C) 2000-2003 Bruno Coudoin
*
......@@ -1048,6 +1048,8 @@ gcompris_init (int argc, char *argv[])
properties->administration = TRUE;
g_warning("Background music disabled");
properties->music = FALSE;
g_warning("Fullscreen is disabled");
properties->fullscreen = FALSE;
}
if (popt_reread_xml){
......
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