deluge/delugegtk.py

104 lines
2.9 KiB
Python
Raw Normal View History

2006-12-08 19:06:49 +00:00
#!/usr/bin/env python
2006-11-28 22:28:37 +00:00
#
# delugegtk.py
#
# Copyright (C) Zach Tibbitts 2006 <zach@collegegeek.org>
#
# Deluge is free software.
#
# You may 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.
#
# delugegtk.py 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 main.py. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
2006-11-28 22:28:37 +00:00
2006-12-08 19:02:22 +00:00
import dcommon, dgtk
2006-11-28 22:28:37 +00:00
import sys, os, gettext
import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade
class DelugeGTK:
def __init__(self):
self.gladefile = dcommon.get_glade_file("delugegtk.glade")
self.wtree = gtk.glade.XML(self.gladefile)
self.window = self.wtree.get_widget("main_window")
if(self.window):
self.window.connect("destroy", gtk.main_quit)
2006-11-30 11:01:29 +00:00
self.window.set_title(dcommon.PROGRAM_NAME + " " + dcommon.PROGRAM_VERSION)
2006-11-28 22:28:37 +00:00
self.window.set_icon_from_file(dcommon.get_pixmap("deluge32.png"))
2006-12-08 19:02:22 +00:00
## Create the system tray icon
self.tray = dgtk.TrayIcon(self)
## Create the about dialog
self.abt = dgtk.AboutDialog()
## Create the preferences dialog
2006-12-08 20:26:35 +00:00
self.prf = dgtk.PreferencesDialog()
2006-12-08 19:02:22 +00:00
2006-11-28 22:28:37 +00:00
actions = {
## File Menu
"new_torrent": self.new_torrent,
"add_torrent": self.add_torrent,
## Edit Menu
2006-12-08 20:26:35 +00:00
"pref_clicked": self.prf.show_pref,
"plugins_clicked": self.prf.show_plugins,
2006-12-04 23:59:45 +00:00
## Torrent Menu
2006-11-28 22:28:37 +00:00
## Help Menu
2006-12-08 19:02:22 +00:00
"show_about_dialog": self.abt.show,
2006-11-28 22:28:37 +00:00
}
self.wtree.signal_autoconnect(actions)
2006-12-08 19:02:22 +00:00
2006-11-28 22:28:37 +00:00
## Create the torrent listview
self.torrent_view = self.wtree.get_widget("torrent_view")
self.store = gtk.ListStore(str)
self.torrent_view.set_model(self.store)
2006-12-08 19:02:22 +00:00
## Still a lot of work to be done here,
## this column is here as an example of how
## to create and add columns. Perhaps I
## should create some sort of ColumnsManager
## object in dgtk to keep the code cleaner
## and also confine column code to one place.
## I'm worrying about columns way too much
## because that was one of the main places
## Deluge's code (up to 0.4) got way out of
## hand.
2006-12-08 20:26:35 +00:00
self.name_column = dgtk.TextColumn("Name", 0)
self.torrent_view.append_column(self.name_column)
self.progress_column = dgtk.ProgressColumn("Progress", 1)
2006-12-08 20:26:35 +00:00
self.torrent_view.append_column(self.progress_column)
self.check_column = dgtk.ToggleColumn("Enabled", 2)
2006-12-08 20:26:35 +00:00
self.torrent_view.append_column(self.check_column)
2006-11-28 22:28:37 +00:00
def new_torrent(self, obj):
pass
def add_torrent(self, obj):
pass
2006-12-04 23:59:45 +00:00
2006-12-08 20:26:35 +00:00
## For testing purposes, create a copy of the interface
2006-11-28 22:28:37 +00:00
if __name__ == "__main__":
dgtk = DelugeGTK()
gtk.main()