preference window

This commit is contained in:
Yann Leboulanger 2003-12-29 18:37:31 +00:00
parent 3175b76064
commit bc00565d2a
3 changed files with 599 additions and 12 deletions

View File

@ -1,3 +1,8 @@
si un server deconne, se connecter a un autre
popup qd qqn se connecte
option autopopup differencie pr chaque user
* Gui :
calcule de idle time
TO SEE LATER
ignore list

View File

@ -2517,4 +2517,468 @@ David Ferlier (david@yazzy.org)</property>
</child>
</widget>
<widget class="GtkWindow" id="Prefs">
<property name="visible">True</property>
<property name="title" translatable="yes">Préférences</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<signal name="destroy" handler="gtk_widget_destroy" last_modification_time="Sun, 28 Dec 2003 21:30:10 GMT"/>
<child>
<widget class="GtkVBox" id="vbox13">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkNotebook" id="notebook2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">True</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkFixed" id="fixed1">
<property name="visible">True</property>
<child>
<widget class="GtkFrame" id="frame1">
<property name="width_request">200</property>
<property name="height_request">200</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">10</property>
<property name="column_spacing">3</property>
<child>
<widget class="GtkLabel" id="label42">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Outgoing Messages</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label43">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Status Messages</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label41">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Incomming Messages</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="colorOut">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_but_col_clicked" last_modification_time="Sun, 28 Dec 2003 23:54:58 GMT"/>
<child>
<widget class="GtkDrawingArea" id="drawing_out">
<property name="width_request">40</property>
<property name="height_request">20</property>
<property name="visible">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="colorStatus">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_but_col_clicked" last_modification_time="Sun, 28 Dec 2003 23:55:09 GMT"/>
<child>
<widget class="GtkDrawingArea" id="drawing_status">
<property name="width_request">40</property>
<property name="height_request">20</property>
<property name="visible">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="colorIn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_but_col_clicked" last_modification_time="Sun, 28 Dec 2003 23:54:43 GMT"/>
<child>
<widget class="GtkDrawingArea" id="drawing_in">
<property name="width_request">40</property>
<property name="height_request">20</property>
<property name="visible">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label38">
<property name="visible">True</property>
<property name="label" translatable="yes">Color</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="x">0</property>
<property name="y">0</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label35">
<property name="visible">True</property>
<property name="label" translatable="yes">Look</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkFixed" id="fixed2">
<property name="visible">True</property>
<child>
<widget class="GtkFrame" id="frame2">
<property name="width_request">200</property>
<property name="height_request">150</property>
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
<widget class="GtkVBox" id="vbox14">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkCheckButton" id="chk_autopopup">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">AutoPopup new
messages</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="chk_autopopup_not_online">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Allow AutoPopup
when NOT onlie</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="checkbutton5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">checkbutton5</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label44">
<property name="visible">True</property>
<property name="label" translatable="yes">AutoPopup</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="x">0</property>
<property name="y">0</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label36">
<property name="visible">True</property>
<property name="label" translatable="yes">Events</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label40">
<property name="visible">True</property>
<property name="label" translatable="yes">Empty</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label37">
<property name="visible">True</property>
<property name="label" translatable="yes">label37</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox7">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">15</property>
<child>
<widget class="GtkButton" id="button_cancel">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="gtk_widget_destroy" last_modification_time="Mon, 29 Dec 2003 13:48:26 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="button_ok">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_ok_clicked" last_modification_time="Mon, 29 Dec 2003 13:48:07 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -58,6 +58,119 @@ class user:
# self.sub = args[0].sub
else: raise TypeError, 'bad arguments'
class prefs:
def delete_event(self, widget):
self.window.destroy()
def on_color_button_clicked(self, widget):
if widget.name == 'colorIn':
color = self.colorIn
da = self.da_in
elif widget.name == 'colorOut':
color = self.colorOut
da = self.da_out
elif widget.name == 'colorStatus':
color = self.colorStatus
da = self.da_status
colorseldlg = gtk.ColorSelectionDialog('Select Color')
colorsel = colorseldlg.colorsel
colorsel.set_previous_color(color)
colorsel.set_current_color(color)
colorsel.set_has_palette(gtk.TRUE)
response = colorseldlg.run()
if response == gtk.RESPONSE_OK:
color = colorsel.get_current_color()
da.modify_bg(gtk.STATE_NORMAL, color)
if widget.name == 'colorIn':
self.colorIn = color
elif widget.name == 'colorOut':
self.colorOut = color
elif widget.name == 'colorStatus':
self.colorStatus = color
colorseldlg.destroy()
def write_cfg(self):
#Color for incomming messages
colSt = '#'+(hex(self.colorIn.red)+'0')[2:4]\
+(hex(self.colorIn.green)+'0')[2:4]\
+(hex(self.colorIn.blue)+'0')[2:4]
self.r.cfgParser.set('GtkGui', 'inmsgcolor', colSt)
for j in self.r.tab_messages.keys():
self.r.tab_messages[j].tagIn.set_property("foreground", colSt)
#Color for outgoing messages
colSt = '#'+(hex(self.colorOut.red)+'0')[2:4]\
+(hex(self.colorOut.green)+'0')[2:4]\
+(hex(self.colorOut.blue)+'0')[2:4]
self.r.cfgParser.set('GtkGui', 'outmsgcolor', colSt)
for j in self.r.tab_messages.keys():
self.r.tab_messages[j].tagOut.set_property("foreground", colSt)
#Color for status messages
colSt = '#'+(hex(self.colorStatus.red)+'0')[2:4]\
+(hex(self.colorStatus.green)+'0')[2:4]\
+(hex(self.colorStatus.blue)+'0')[2:4]
self.r.cfgParser.set('GtkGui', 'statusmsgcolor', colSt)
for j in self.r.tab_messages.keys():
self.r.tab_messages[j].tagStatus.set_property("foreground", colSt)
#autopopup
pp = self.chk_autopp.get_active()
if pp == True:
self.r.cfgParser.set('GtkGui', 'autopopup', '1')
self.r.autopopup = 1
else:
self.r.cfgParser.set('GtkGui', 'autopopup', '0')
self.r.autopopup = 0
self.r.cfgParser.writeCfgFile()
self.r.cfgParser.parseCfgFile()
def on_ok(self, widget):
self.write_cfg()
self.window.destroy()
def __init__(self, roster):
self.xml = gtk.glade.XML('plugins/gtkgui/gtkgui.glade', 'Prefs')
self.window = self.xml.get_widget("Prefs")
self.r = roster
self.da_in = self.xml.get_widget("drawing_in")
self.da_out = self.xml.get_widget("drawing_out")
self.da_status = self.xml.get_widget("drawing_status")
self.chk_autopp = self.xml.get_widget("chk_autopopup")
#Color for incomming messages
colSt = self.r.cfgParser.GtkGui_inmsgcolor
if not colSt:
colSt = '#ff0000'
cmapIn = self.da_in.get_colormap()
self.colorIn = cmapIn.alloc_color(colSt)
self.da_in.window.set_background(self.colorIn)
#Color for outgoing messages
colSt = self.r.cfgParser.GtkGui_outmsgcolor
if not colSt:
colSt = '#0000ff'
cmapOut = self.da_out.get_colormap()
self.colorOut = cmapOut.alloc_color(colSt)
self.da_out.window.set_background(self.colorOut)
#Color for status messages
colSt = self.r.cfgParser.GtkGui_statusmsgcolor
if not colSt:
colSt = '#00ff00'
cmapStatus = self.da_status.get_colormap()
self.colorStatus = cmapStatus.alloc_color(colSt)
self.da_status.window.set_background(self.colorStatus)
#Autopopup
st = self.r.cfgParser.GtkGui_autopopup
if not st:
st = '0'
pp = string.atoi(st)
self.chk_autopp.set_active(pp)
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
self.xml.signal_connect('on_but_col_clicked', self.on_color_button_clicked)
self.xml.signal_connect('on_ok_clicked', self.on_ok)
class add:
def delete_event(self, widget):
self.Wadd.destroy()
@ -444,21 +557,21 @@ class message:
# self.window.show()
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
self.xml.signal_connect('on_msg_key_press_event', self.on_msg_key_press_event)
self.tag = self.convTxtBuffer.create_tag("incoming")
self.tagIn = self.convTxtBuffer.create_tag("incoming")
color = self.cfgParser.GtkGui_inmsgcolor
if not color:
color = 'red'
self.tag.set_property("foreground", color)
self.tag = self.convTxtBuffer.create_tag("outgoing")
color = '#ff0000' #red
self.tagIn.set_property("foreground", color)
self.tagOut = self.convTxtBuffer.create_tag("outgoing")
color = self.cfgParser.GtkGui_outmsgcolor
if not color:
color = 'blue'
self.tag.set_property("foreground", color)
self.tag = self.convTxtBuffer.create_tag("status")
color = '#0000ff' #blue
self.tagOut.set_property("foreground", color)
self.tagStatus = self.convTxtBuffer.create_tag("status")
color = self.cfgParser.GtkGui_statusmsgcolor
if not color:
color = 'green'
self.tag.set_property("foreground", color)
self.tagStatus.set_property("foreground", color)
class roster:
def get_icon_pixbuf(self, stock):
@ -630,6 +743,9 @@ class roster:
for j in self.l_contact.keys():
self.chg_status(j, 'offline', 'Disconnected')
def on_prefs(self, widget):
window = prefs(self)
def on_add(self, widget):
window_add = add(self)
@ -689,13 +805,14 @@ class roster:
if not Wbrowser:
Wbrowser = browser(self)
def __init__(self, queueOUT):
def __init__(self, queueOUT, plug):
# FIXME : handle no file ...
self.cfgParser = common.optparser.OptionsParser(CONFPATH)
self.cfgParser.parseCfgFile()
self.xml = gtk.glade.XML('plugins/gtkgui/gtkgui.glade', 'Gajim')
self.window = self.xml.get_widget('Gajim')
self.tree = self.xml.get_widget('treeview')
self.plug = plug
#(icon, name, jid, editable, background color, show_icon)
self.treestore = gtk.TreeStore(gtk.gdk.Pixbuf, str, str, gobject.TYPE_BOOLEAN, str, gobject.TYPE_BOOLEAN)
iconstyle = self.cfgParser.GtkGui_iconstyle
@ -768,6 +885,7 @@ class roster:
#signals
self.xml.signal_connect('gtk_main_quit', self.on_quit)
self.xml.signal_connect('on_preferences_activate', self.on_prefs)
self.xml.signal_connect('on_accounts_activate', self.on_accounts)
self.xml.signal_connect('on_browse_agents_activate', self.on_browse)
self.xml.signal_connect('on_add_activate', self.on_add)
@ -819,10 +937,10 @@ class plugin:
autopopup = self.r.cfgParser.GtkGui_autopopup
if autopopup:
autopopup = string.atoi(autopopup)
self.autopopup = string.atoi(autopopup)
else:
self.autopopup = 0
if autopopup == 0 and not self.r.tab_messages.has_key(jid):
if self.autopopup == 0 and not self.r.tab_messages.has_key(jid):
#We save it in a queue
if not self.r.tab_queues.has_key(jid):
self.r.tab_queues[jid] = Queue.Queue(50)
@ -881,7 +999,7 @@ class plugin:
gtk.threads_init()
gtk.threads_enter()
self.queueIN = quIN
self.r = roster(quOUT)
self.r = roster(quOUT, self)
self.time = gtk.timeout_add(200, self.read_queue)
gtk.main()
gtk.threads_leave()