Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes | Private Member Functions
admin.profile_list.Profile_list Class Reference

List of all members.

Public Member Functions

def __init__
def reload_profile
def add_profile_in_model
def on_add_profile_clicked
def on_remove_profile_clicked
def on_cell_profile_edited
def on_edit_profile_clicked
def on_default_profile_clicked
def set_default_in_description
def profile_changed_cb

Public Attributes

 cur
 con
 current_profile_id
 profile_model
 button_edit
 button_remove
 button_default
 profile_group
 default_profile_id
 default_profile_id_iter
 default_profile_id_description
 profile_data

Private Member Functions

def __create_model_profile
def __add_columns_profile

Detailed Description

GCompris Profile List Table

Definition at line 44 of file profile_list.py.


Constructor & Destructor Documentation

def admin.profile_list.Profile_list.__init__ (   self,
  frame,
  db_connect,
  db_cursor 
)

Definition at line 49 of file profile_list.py.

00049 
00050   def __init__(self, frame, db_connect, db_cursor):
00051 
00052       self.cur = db_cursor
00053       self.con = db_connect
00054 
00055       # The profile_id to work on
00056       self.current_profile_id = 0
00057 
00058       # ---------------
00059       # Profile Management
00060       # ---------------
00061 
00062       # create tree model
00063       self.profile_model = self.__create_model_profile()
00064 
00065       # Main box is vertical
00066       top_box = gtk.VBox(False, 8)
00067       top_box.show()
00068       frame.add(top_box)
00069 
00070       # Second line profiles and button
00071       profile_hbox = gtk.HBox(False, 8)
00072       profile_hbox.show()
00073       top_box.add(profile_hbox)
00074 
00075       profilelist_box = gtk.VBox(False, 8)
00076       profilelist_box.show()
00077       profile_hbox.add(profilelist_box)
00078 
00079       vbox_button = gtk.VBox(False, 8)
00080       vbox_button.show()
00081       profile_hbox.add(vbox_button)
00082 
00083 
00084       # Create the table
00085       sw = gtk.ScrolledWindow()
00086       sw.show()
00087       sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
00088       sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
00089 
00090       # create tree view
00091       treeview_profile = gtk.TreeView(self.profile_model)
00092       treeview_profile.show()
00093       treeview_profile.set_rules_hint(True)
00094       treeview_profile.set_search_column(COLUMN_NAME)
00095 
00096       sw.add(treeview_profile)
00097 
00098       profilelist_box.pack_start(sw, True, True, 0)
00099 
00100 
00101       # add columns to the tree view
00102       self.__add_columns_profile(treeview_profile)
00103 
00104       # Add buttons
00105       button = gtk.Button(stock='gtk-add')
00106       button.connect("clicked", self.on_add_profile_clicked, self.profile_model)
00107       vbox_button.pack_start(button, False, False, 0)
00108       button.show()
00109 
00110       self.button_edit = gtk.Button(stock='gtk-edit')
00111       self.button_edit.connect("clicked", self.on_edit_profile_clicked, treeview_profile)
00112       vbox_button.pack_start(self.button_edit, False, False, 0)
00113       self.button_edit.show()
00114       self.button_edit.set_sensitive(False)
00115 
00116       self.button_remove = gtk.Button(stock='gtk-remove')
00117       self.button_remove.connect("clicked", self.on_remove_profile_clicked, treeview_profile)
00118       vbox_button.pack_start(self.button_remove, False, False, 0)
00119       self.button_remove.show()
00120       self.button_remove.set_sensitive(False)
00121 
00122       self.button_default = gtk.Button(_("Default"))
00123       self.button_default.connect("clicked", self.on_default_profile_clicked, treeview_profile)
00124       vbox_button.pack_start(self.button_default, False, False, 0)
00125       self.button_default.show()
00126       self.button_default.set_sensitive(False)
00127 
00128       # Group list for the profile
00129       group_hbox = gtk.HBox(False, 8)
00130       group_hbox.show()
00131       top_box.add(group_hbox)
00132 
00133       self.profile_group = profile_group_list.Profile_group_list(group_hbox,
00134                                                         self.con, self.cur,
00135                                                         self.current_profile_id)
00136 
00137       # Missing callbacks
00138       selection = treeview_profile.get_selection()
00139       selection.connect('changed', self.profile_changed_cb, self.profile_group)
00140 
00141       # Load lists
00142       self.reload_profile()


Member Function Documentation

def admin.profile_list.Profile_list.__add_columns_profile (   self,
  treeview 
) [private]

Definition at line 181 of file profile_list.py.

00181 
00182   def __add_columns_profile(self, treeview):
00183 
00184     model = treeview.get_model()
00185 
00186     # columns for name
00187     renderer = gtk.CellRendererText()
00188     renderer.set_data("column", COLUMN_NAME)
00189     column = gtk.TreeViewColumn(_('Profile'), renderer,
00190                                 text=COLUMN_NAME)
00191     column.set_sort_column_id(COLUMN_NAME)
00192     column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
00193     column.set_fixed_width(constants.COLUMN_WIDTH_PROFILENAME)
00194     treeview.append_column(column)
00195 
00196     # columns for description
00197     renderer = gtk.CellRendererText()
00198     renderer.set_data("column", COLUMN_DESCRIPTION)
00199     column = gtk.TreeViewColumn(_('Description'), renderer,
00200                                 text=COLUMN_DESCRIPTION)
00201     column.set_sort_column_id(COLUMN_DESCRIPTION)
00202     column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
00203     column.set_fixed_width(constants.COLUMN_WIDTH_PROFILEDESCRIPTION)
00204     treeview.append_column(column)
00205 

Definition at line 171 of file profile_list.py.

00171 
00172   def __create_model_profile(self):
00173     model = gtk.ListStore(
00174       gobject.TYPE_INT,
00175       gobject.TYPE_STRING,
00176       gobject.TYPE_STRING,
00177       gobject.TYPE_BOOLEAN)
00178 
00179     return model
00180 

def admin.profile_list.Profile_list.add_profile_in_model (   self,
  model,
  aprofile 
)

Definition at line 207 of file profile_list.py.

00207 
00208   def add_profile_in_model(self, model, aprofile):
00209     iter = model.append()
00210     model.set (iter,
00211                COLUMN_PROFILEID,          aprofile[COLUMN_PROFILEID],
00212                COLUMN_NAME,               aprofile[COLUMN_NAME],
00213                COLUMN_DESCRIPTION,        aprofile[COLUMN_DESCRIPTION]
00214                )
00215 
00216     if self.default_profile_id ==  aprofile[COLUMN_PROFILEID]:
00217       self.set_default_in_description(iter)

Here is the call graph for this function:

def admin.profile_list.Profile_list.on_add_profile_clicked (   self,
  button,
  model 
)

Definition at line 219 of file profile_list.py.

00219 
00220   def on_add_profile_clicked(self, button, model):
00221 
00222     profile_id = constants.get_next_profile_id(self.con, self.cur)
00223 
00224     profile_edit.ProfileEdit(self.con, self.cur,
00225                              profile_id, None, None,
00226                              self)
00227 

def admin.profile_list.Profile_list.on_cell_profile_edited (   self,
  cell,
  path_string,
  new_text,
  model 
)

Definition at line 251 of file profile_list.py.

00251 
00252   def on_cell_profile_edited(self, cell, path_string, new_text, model):
00253 
00254     iter = model.get_iter_from_string(path_string)
00255     path = model.get_path(iter)[0]
00256     column = cell.get_data("column")
00257 
00258     profile_id = model.get_value(iter, COLUMN_PROFILEID)
00259 
00260     if column == COLUMN_NAME:
00261       model.set(iter, column, new_text)
00262 
00263     elif column == COLUMN_DESCRIPTION:
00264       model.set(iter, column, new_text)
00265 
00266     profile_data = (profile_id,
00267                     model.get_value(iter, COLUMN_NAME),
00268                     model.get_value(iter, COLUMN_DESCRIPTION))
00269     # Save the changes in the base
00270     self.cur.execute('insert or replace into profiles (profile_id, name, description) values (?, ?, ?)',
00271                      profile_data)
00272     self.con.commit()
00273 

def admin.profile_list.Profile_list.on_default_profile_clicked (   self,
  button,
  treeview 
)

Definition at line 291 of file profile_list.py.

00291 
00292   def on_default_profile_clicked(self, button, treeview):
00293     selection = treeview.get_selection()
00294     model, iter = selection.get_selected()
00295 
00296     if iter:
00297       path = model.get_path(iter)[0]
00298       profile_id   = model.get_value(iter, COLUMN_PROFILEID)
00299 
00300       self.default_profile_id = profile_id
00301       self.button_default.set_sensitive(False)
00302 
00303       # Save the changes in the base
00304       self.cur.execute('UPDATE informations SET profile_id=?',
00305                        (profile_id,))
00306       self.con.commit()
00307 
00308       self.set_default_in_description(iter)

Here is the call graph for this function:

def admin.profile_list.Profile_list.on_edit_profile_clicked (   self,
  button,
  treeview 
)

Definition at line 274 of file profile_list.py.

00274 
00275   def on_edit_profile_clicked(self, button, treeview):
00276 
00277     selection = treeview.get_selection()
00278     model, iter = selection.get_selected()
00279 
00280     if iter:
00281       path = model.get_path(iter)[0]
00282       profile_id          = model.get_value(iter, COLUMN_PROFILEID)
00283       profile_name        = model.get_value(iter, COLUMN_NAME)
00284       profile_description = model.get_value(iter, COLUMN_DESCRIPTION)
00285       profile_edit.ProfileEdit(self.con, self.cur,
00286                                profile_id, profile_name, profile_description,
00287                                self)
00288 
00289 

def admin.profile_list.Profile_list.on_remove_profile_clicked (   self,
  button,
  treeview 
)

Definition at line 228 of file profile_list.py.

00228 
00229   def on_remove_profile_clicked(self, button, treeview):
00230 
00231     selection = treeview.get_selection()
00232     model, iter = selection.get_selected()
00233 
00234     if iter:
00235       path = model.get_path(iter)[0]
00236       profile_id = model.get_value(iter, COLUMN_PROFILEID)
00237 
00238       model.remove(iter)
00239       # Remove it from the base
00240       self.cur.execute('DELETE FROM profiles WHERE profile_id=?', (profile_id,))
00241 
00242       # Remove it from list_groups_in_profiles
00243       self.cur.execute('DELETE FROM list_groups_in_profiles ' +
00244                        'WHERE profile_id=?',
00245                        (profile_id,))
00246 
00247       self.con.commit()
00248 
00249       self.profile_group.reload(-1)
00250 

def admin.profile_list.Profile_list.profile_changed_cb (   self,
  selection,
  profile_group 
)

Definition at line 332 of file profile_list.py.

00332 
00333   def profile_changed_cb(self, selection, profile_group):
00334     model, iter = selection.get_selected()
00335 
00336     if iter:
00337       self.current_profile_id = model.get_value(iter, COLUMN_PROFILEID)
00338 
00339       profile_group.reload(self.current_profile_id)
00340 
00341       self.button_edit.set_sensitive(True)
00342       self.button_remove.set_sensitive(True)
00343 
00344       # Set the default button on if needed
00345       if(self.default_profile_id == self.current_profile_id):
00346         self.button_default.set_sensitive(False)
00347       else:
00348         self.button_default.set_sensitive(True)
00349 
00350       if(self.current_profile_id == 1):
00351          self.button_remove.set_sensitive(False)
00352       else:
00353          self.button_remove.set_sensitive(True)
00354 

Definition at line 148 of file profile_list.py.

00148 
00149   def reload_profile(self):
00150 
00151     # Remove all entries in the list
00152     self.profile_model.clear()
00153 
00154     # Get the default profile
00155     self.cur.execute('select * from informations')
00156     self.default_profile_id = self.cur.fetchall()[0][2]
00157     self.default_profile_id_iter = None
00158     self.default_profile_id_description = None
00159 
00160     # Grab the profile data
00161     self.cur.execute('SELECT profile_id, name, description FROM profiles ORDER BY name')
00162     self.profile_data = self.cur.fetchall()
00163 
00164     for aprofile in self.profile_data:
00165       self.add_profile_in_model(self.profile_model, aprofile)
00166 
00167     self.profile_group.reload(self.current_profile_id)
00168 
00169 

Definition at line 310 of file profile_list.py.

00310 
00311   def set_default_in_description(self, iter):
00312       # set default in description
00313       description  = self.profile_model.get_value(iter, COLUMN_DESCRIPTION)
00314 
00315       self.profile_model.set (iter,
00316                               COLUMN_DESCRIPTION,        description + " " + _("[Default]"),
00317                               )
00318 
00319       # There was a previous default TAG, erase it
00320       if self.default_profile_id_iter:
00321         self.profile_model.set (self.default_profile_id_iter,
00322                                 COLUMN_DESCRIPTION, self.default_profile_id_description,
00323                                 )
00324 
00325       # Save the default profile iter to erase it's "default" tag if needed
00326       self.default_profile_id_iter        = iter
00327       self.default_profile_id_description = description
00328 

Here is the caller graph for this function:


Member Data Documentation

Definition at line 121 of file profile_list.py.

Definition at line 109 of file profile_list.py.

Definition at line 115 of file profile_list.py.

Definition at line 52 of file profile_list.py.

Definition at line 51 of file profile_list.py.

Definition at line 55 of file profile_list.py.

Definition at line 155 of file profile_list.py.

Definition at line 157 of file profile_list.py.

Definition at line 156 of file profile_list.py.

Definition at line 161 of file profile_list.py.

Definition at line 132 of file profile_list.py.

Definition at line 62 of file profile_list.py.


The documentation for this class was generated from the following file: