informs the user about new version (ticket #34)

This commit is contained in:
Nikos Kouremenos 2005-04-14 20:10:17 +00:00
parent 283dae6d8d
commit 3a46243f4d
4 changed files with 230 additions and 3 deletions

View File

@ -51,7 +51,7 @@ class Chat:
self.nb_unread = {} self.nb_unread = {}
self.last_message_time = {} self.last_message_time = {}
self.print_time_timeout_id = {} self.print_time_timeout_id = {}
self.names = {} # what is printed in the tab : user.name for example self.names = {} # what is printed in the tab (eg. user.name)
self.childs = {} self.childs = {}
self.window = self.xml.get_widget(widget_name) self.window = self.xml.get_widget(widget_name)
self.widget_name = widget_name self.widget_name = widget_name

View File

@ -0,0 +1,62 @@
import gtk
import gtk.glade
import version
from common import i18n
_ = i18n._
APP = i18n.APP
gtk.glade.bindtextdomain(APP, i18n.DIR)
gtk.glade.textdomain(APP)
GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade'
class Check_for_new_version_dialog:
def __init__(self, plugin):
self.plugin = plugin
xml = gtk.glade.XML(GTKGUI_GLADE, 'new_version_available_dialog', APP)
self.window = xml.get_widget('new_version_available_dialog')
self.information_label = xml.get_widget('information_label')
self.changes_textview = xml.get_widget('changes_textview')
xml.signal_autoconnect(self)
self.check_for_new_version()
def on_new_version_available_dialog_delete_event(self, widget, event):
self.window.destroy()
def on_open_download_page_button_clicked(self, widget):
url = 'http://www.gajim.org/downloads.php?lang='
self.plugin.launch_browser_mailer('url', url)
def check_for_new_version(self):
'''parse online Changelog to find out last version
and the changes for that latest version'''
check_for_new_version_available = True
if check_for_new_version_available:
import urllib
import version
url = 'http://trac.gajim.org/file/trunk/Changelog?rev=latest&format=txt'
changelog = urllib.urlopen(url)
# format is Gajim version (date)
first_line = changelog.readline()
finish_version = first_line.find(' ', 6) # start search after 'Gajim'
latest_version = first_line[6:finish_version]
if latest_version > version.version:
start_date = finish_version + 2 # one space and one (
date = first_line[start_date:-2] # remove the last ) and \n
text = 'Gajim ' + latest_version + ' was released in ' + date + '!'
self.information_label.set_text(text)
changes = ''
while True:
line = changelog.readline()
if line.startswith('Gajim'):
break
else:
if line != '\n':
changes += line
buf = self.changes_textview.get_buffer()
buf.set_text(changes)
self.window.show_all()

View File

@ -10049,7 +10049,7 @@ send a chat message to</property>
</widget> </widget>
<widget class="GtkWindow" id="add_remove_emoticons_window"> <widget class="GtkWindow" id="add_remove_emoticons_window">
<property name="border_width">5</property> <property name="border_width">4</property>
<property name="width_request">300</property> <property name="width_request">300</property>
<property name="height_request">350</property> <property name="height_request">350</property>
<property name="title" translatable="yes">Add/Remove Emoticons</property> <property name="title" translatable="yes">Add/Remove Emoticons</property>
@ -10172,4 +10172,167 @@ send a chat message to</property>
</child> </child>
</widget> </widget>
<widget class="GtkDialog" id="new_version_available_dialog">
<property name="border_width">4</property>
<property name="width_request">490</property>
<property name="height_request">250</property>
<property name="title" translatable="yes">New version of Gajim available</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>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="has_separator">False</property>
<signal name="delete_event" handler="on_new_version_available_dialog_delete_event" last_modification_time="Thu, 14 Apr 2005 17:45:18 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox9">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area8">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="open_download_page_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="label" translatable="yes">Open Download Page</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_open_download_page_button_clicked" last_modification_time="Thu, 14 Apr 2005 17:51:56 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="information_label">
<property name="visible">True</property>
<property name="label" translatable="yes"></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>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame28">
<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="GtkAlignment" id="alignment57">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow34">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="changes_textview">
<property name="visible">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">0</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label239">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Changes in latest version&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</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>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface> </glade-interface>

View File

@ -63,6 +63,7 @@ import sys
import Queue import Queue
import sre import sre
import common.sleepy import common.sleepy
import check_for_new_version
try: try:
import winsound # windows-only built-in module for playing wav import winsound # windows-only built-in module for playing wav
@ -991,6 +992,7 @@ class plugin:
if self.config['trayicon']: if self.config['trayicon']:
self.show_systray() self.show_systray()
check_for_new_version.Check_for_new_version_dialog(self)
self.init_regexp() self.init_regexp()
# get instances for windows/dialogs that will show_all()/hide() # get instances for windows/dialogs that will show_all()/hide()