gget r18 - in trunk: data gget
- From: johans svn gnome org
- To: svn-commits-list gnome org
- Subject: gget r18 - in trunk: data gget
- Date: Thu, 26 Jun 2008 23:26:24 +0000 (UTC)
Author: johans
Date: Thu Jun 26 23:26:24 2008
New Revision: 18
URL: http://svn.gnome.org/viewvc/gget?rev=18&view=rev
Log:
Added UI for download folders based on file extensions. Not enabled yet though.
Modified:
trunk/data/gget.glade
trunk/data/gget.schemas.in
trunk/gget/Configuration.py
trunk/gget/PreferencesDialog.py
Modified: trunk/data/gget.glade
==============================================================================
--- trunk/data/gget.glade (original)
+++ trunk/data/gget.glade Thu Jun 26 23:26:24 2008
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Mon Jun 23 23:52:28 2008 -->
+<!--Generated with glade3 3.4.5 on Fri Jun 27 01:23:25 2008 -->
<glade-interface>
<widget class="GtkWindow" id="main_window">
<property name="width_request">800</property>
@@ -159,10 +159,18 @@
</packing>
</child>
<child>
- <widget class="GtkTreeView" id="downloads_treeview">
+ <widget class="GtkScrolledWindow" id="downloads_scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="headers_clickable">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <child>
+ <widget class="GtkTreeView" id="downloads_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_clickable">True</property>
+ </widget>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -244,16 +252,25 @@
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<child>
- <widget class="GtkFileChooserButton" id="download_filechooserbutton">
+ <widget class="GtkLabel" id="label3">
<property name="visible">True</property>
- <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
- <property name="title" translatable="yes">Select download folder</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_URL:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">url_entry</property>
+ </widget>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="url_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
</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>
</packing>
</child>
<child>
@@ -271,25 +288,16 @@
</packing>
</child>
<child>
- <widget class="GtkEntry" id="url_entry">
+ <widget class="GtkFileChooserButton" id="download_filechooserbutton">
<property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
+ <property name="title" translatable="yes">Select download folder</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_URL:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">url_entry</property>
- </widget>
- <packing>
- <property name="x_options">GTK_FILL</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
</packing>
</child>
</widget>
@@ -484,6 +492,7 @@
</child>
</widget>
<packing>
+ <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -557,8 +566,8 @@
<widget class="GtkFileChooserButton" id="default_folder_filechooserbutton">
<property name="visible">True</property>
<property name="sensitive">False</property>
- <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="local_only">False</property>
+ <property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="title" translatable="yes">Select download folder</property>
</widget>
</child>
@@ -573,6 +582,118 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkVBox" id="extensions_vbox1">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkCheckButton" id="extensions_checkbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Except for specific file types:</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkAlignment" id="extensions_alignment">
+ <property name="visible">True</property>
+ <property name="left_padding">20</property>
+ <child>
+ <widget class="GtkVBox" id="extensions_vbox2">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkScrolledWindow" id="extensions_scrolledwindow">
+ <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_ETCHED_IN</property>
+ <child>
+ <widget class="GtkTreeView" id="extensions_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_clickable">True</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkButton" id="add_extension_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-add</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="remove_extension_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="label" translatable="yes">gtk-remove</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="stock">gtk-dialog-info</property>
+ <property name="icon_size">6</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Use a regular expression for the extension
+For example: *.tar.gz</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
Modified: trunk/data/gget.schemas.in
==============================================================================
--- trunk/data/gget.schemas.in (original)
+++ trunk/data/gget.schemas.in Thu Jun 26 23:26:24 2008
@@ -1,3 +1,4 @@
+<?xml version="1.0"?>
<gconfschemafile>
<schemalist>
<schema>
@@ -8,7 +9,9 @@
<default>true</default>
<locale name="C">
<short>Show statusbar</short>
- <long>Whether GGet should display a statusbar in the main window.</long>
+ <long>
+ Whether GGet should display a statusbar in the main window.
+ </long>
</locale>
</schema>
<schema>
@@ -19,7 +22,9 @@
<default>true</default>
<locale name="C">
<short>Show toolbar</short>
- <long>Whether GGet should display a toolbar in the main window.</long>
+ <long>
+ Whether GGet should display a toolbar in the main window.
+ </long>
</locale>
</schema>
<schema>
@@ -30,7 +35,10 @@
<default>true</default>
<locale name="C">
<short>Show status icon</short>
- <long>Whether GGet should display a status icon in the notification area.</long>
+ <long>
+ Whether GGet should display a status icon in the
+ notification area.
+ </long>
</locale>
</schema>
<schema>
@@ -41,7 +49,9 @@
<default>true</default>
<locale name="C">
<short>Show main window</short>
- <long>Whether GGet should display the main window on startup.</long>
+ <long>
+ Whether GGet should display the main window on startup.
+ </long>
</locale>
</schema>
<schema>
@@ -63,7 +73,10 @@
<default>false</default>
<locale name="C">
<short>Autoresume downloads on startup</short>
- <long>Whether GGet should automatically resume paused downloads on startup.</long>
+ <long>
+ Whether GGet should automatically resume paused downloads
+ on startup.
+ </long>
</locale>
</schema>
<schema>
@@ -118,7 +131,10 @@
<default>true</default>
<locale name="C">
<short>Ask for download location</short>
- <long>Whether GGet should always ask for the location where to save downloaded files.</long>
+ <long>
+ Whether GGet should always ask for the location where to
+ save downloaded files.
+ </long>
</locale>
</schema>
<schema>
@@ -129,7 +145,54 @@
<default></default>
<locale name="C">
<short>Default download folder</short>
- <long>Default location where GGet will save downloaded files.</long>
+ <long>
+ Default location where GGet will save downloaded
+ files.
+ </long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/gget/folders/check_extensions</key>
+ <applyto>/apps/gget/folders/check_extensions</applyto>
+ <owner>gget</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Use exceptions for extensions</short>
+ <long>
+ Whether to check file extensions to determine download
+ folder.
+ </long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/gget/folders/extensions</key>
+ <applyto>/apps/gget/folders/extensions</applyto>
+ <owner>gget</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <default>[]</default>
+ <locale name="C">
+ <short>File type extensions</short>
+ <long>
+ File type extensions which has download associated default
+ download folders in the extension_folders key.
+ </long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/gget/folders/extension_folders</key>
+ <applyto>/apps/gget/folders/extension_folders</applyto>
+ <owner>gget</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <default>[]</default>
+ <locale name="C">
+ <short>Folders for file type extensions</short>
+ <long>
+ Default download folders for the file type extensions in
+ the extensions key.
+ </long>
</locale>
</schema>
</schemalist>
Modified: trunk/gget/Configuration.py
==============================================================================
--- trunk/gget/Configuration.py (original)
+++ trunk/gget/Configuration.py Thu Jun 26 23:26:24 2008
@@ -37,6 +37,9 @@
KEY_AUTORESUME = "/general/autoresume"
KEY_ASK_FOR_LOCATION = "/folders/ask_for_location"
KEY_DEFAULT_FOLDER = "/folders/default_folder"
+KEY_CHECK_EXTENSIONS = "/folders/check_extensions"
+KEY_EXTENSIONS = "/folders/extensions"
+KEY_EXTENSION_FOLDERS = "/folders/extension_folders"
KEY_WINDOW_WIDTH = "/general/window_width"
KEY_WINDOW_HEIGHT = "/general/window_height"
KEY_WINDOW_POSITION_X = "/general/window_position_x"
@@ -52,6 +55,9 @@
KEY_AUTORESUME: 'bool',
KEY_ASK_FOR_LOCATION: 'bool',
KEY_DEFAULT_FOLDER: 'string',
+ KEY_CHECK_EXTENSIONS: 'bool',
+ KEY_EXTENSIONS: 'list',
+ KEY_EXTENSION_FOLDERS: 'list',
KEY_WINDOW_WIDTH: 'int',
KEY_WINDOW_HEIGHT: 'int',
KEY_WINDOW_POSITION_X: 'int',
@@ -212,6 +218,44 @@
default_folder = property(get_default_folder, set_default_folder)
+ # Check extensions
+ def get_check_extensions(self, use_cache=True):
+ if use_cache:
+ return self.option_cache[KEY_CHECK_EXTENSIONS]
+ else:
+ return self.__get_option(KEY_CHECK_EXTENSIONS)
+
+ def set_check_extensions(self, check_extensions):
+ self.__set_option(KEY_CHECK_EXTENSIONS, check_extensions)
+
+ check_extensions = property(get_check_extensions, set_check_extensions)
+
+ # Extensions
+ def get_extensions(self, use_cache=True):
+ if use_cache:
+ return self.option_cache[KEY_EXTENSIONS]
+ else:
+ return self.__get_option(KEY_EXTENSIONS, type=gconf.VALUE_STRING)
+
+ def set_extensions(self, extensions):
+ self.__set_option(KEY_EXTENSIONS, extensions, type=gconf.VALUE_STRING)
+
+ extensions = property(get_extensions, set_extensions)
+
+ # Extension folders
+ def get_extension_folders(self, use_cache=True):
+ if use_cache:
+ return self.option_cache[KEY_EXTENSION_FOLDERS]
+ else:
+ return self.__get_option(KEY_EXTENSION_FOLDERS,
+ type=gconf.VALUE_STRING)
+
+ def set_extension_folders(self, extension_folders):
+ self.__set_option(KEY_EXTENSION_FOLDERS, extension_folders,
+ type=gconf.VALUE_STRING)
+
+ extension_folders = property(get_extension_folders, set_extension_folders)
+
# Window width
def get_window_width(self, use_cache=True):
if use_cache:
Modified: trunk/gget/PreferencesDialog.py
==============================================================================
--- trunk/gget/PreferencesDialog.py (original)
+++ trunk/gget/PreferencesDialog.py Thu Jun 26 23:26:24 2008
@@ -39,9 +39,11 @@
self.config = config
self.__get_widgets()
+ self.__make_extensions_treeview()
self.__connect_widgets()
self.__add_config_notifications()
+ # Set widget states from configuration
self.status_icon_checkbutton.set_active(self.config.show_status_icon)
self.main_window_checkbutton.set_active(self.config.show_main_window)
self.autostart_checkbutton.set_active(self.config.autostart)
@@ -54,6 +56,13 @@
else:
self.specify_folder_radiobutton.set_active(True)
self.default_folder_filechooserbutton.set_current_folder(self.config.default_folder)
+ self.extensions_checkbutton.set_active(self.config.check_extensions)
+ if not self.config.check_extensions:
+ self.extensions_alignment.set_sensitive(False)
+
+ for extension, folder in zip(self.config.extensions,
+ self.config.extension_folders):
+ self.extensions_model.append((extension, folder))
def __get_widgets(self):
xml = gtk.glade.XML(GUI.glade_file, domain=NAME.lower())
@@ -71,10 +80,65 @@
self.ask_folder_radiobutton = xml.get_widget("ask_folder_radiobutton")
self.specify_folder_radiobutton = xml.get_widget("specify_folder_radiobutton")
self.default_folder_filechooserbutton = xml.get_widget("default_folder_filechooserbutton")
+ self.extensions_checkbutton = xml.get_widget("extensions_checkbutton")
+ self.extensions_alignment = xml.get_widget("extensions_alignment")
+ self.extensions_treeview = xml.get_widget("extensions_treeview")
+ self.add_extension_button = xml.get_widget("add_extension_button")
+ self.remove_extension_button = xml.get_widget("remove_extension_button")
# Buttons
self.close_button = xml.get_widget("close_button")
+ def __make_extensions_treeview(self):
+ self.extensions_model = gtk.ListStore(str, str)
+ self.extensions_treeview.set_model(self.extensions_model)
+
+ # Extension
+ self.extension_cell_renderer = gtk.CellRendererText()
+ self.extension_cell_renderer.props.xpad = 3
+ self.extension_cell_renderer.props.ypad = 3
+ self.extension_cell_renderer.props.editable = True
+ self.extension_cell_renderer.connect("edited",
+ self.__extension_cell_renderer_edited)
+ self.extension_treeview_column = gtk.TreeViewColumn(_("Extension"),
+ self.extension_cell_renderer)
+ self.extension_treeview_column.set_cell_data_func(
+ self.extension_cell_renderer, self.__extension_cell_data_func)
+ self.extensions_treeview.append_column(self.extension_treeview_column)
+
+ # Folder
+ folder_cell_renderer = gtk.CellRendererText()
+ folder_cell_renderer.props.xpad = 3
+ folder_cell_renderer.props.ypad = 3
+ folder_cell_renderer.props.editable = True
+ folder_cell_renderer.connect("edited",
+ self.__folder_cell_renderer_edited)
+ folder_treeview_column = gtk.TreeViewColumn(_("Folder"),
+ folder_cell_renderer)
+ folder_treeview_column.set_cell_data_func(folder_cell_renderer,
+ self.__folder_cell_data_func)
+ self.extensions_treeview.append_column(folder_treeview_column)
+
+ def __extension_cell_data_func(self, column, cell, model, iter):
+ cell.props.text = model.get_value(iter, 0)
+
+ def __folder_cell_data_func(self, column, cell, model, iter):
+ cell.props.text = model.get_value(iter, 1)
+
+ def __extension_cell_renderer_edited(self, cell, path, new_text):
+ extensions = self.config.extensions
+ if self.extensions_model[path][0] in extensions:
+ extensions[extensions.index(self.extensions_model[path][0])] = new_text
+ self.config.extensions = extensions
+ self.extensions_model[path][0] = new_text
+
+ def __folder_cell_renderer_edited(self, cell, path, new_text):
+ extension_folders = self.config.extension_folders
+ if self.extensions_model[path][1] in extension_folders:
+ extension_folders[extension_folders.index(self.extensions_model[path][1])] = new_text
+ self.config.extension_folders = extension_folders
+ self.extensions_model[path][1] = new_text
+
def __connect_widgets(self):
# General tab
self.status_icon_checkbutton.connect("toggled",
@@ -92,6 +156,16 @@
self.__ask_folder_radiobutton_toggled)
self.default_folder_filechooserbutton.connect("current-folder-changed",
self.__default_folder_filechooserbutton_current_folder_changed)
+ self.extensions_checkbutton.connect("toggled",
+ self.__extensions_checkbutton_toggled)
+ self.add_extension_button.connect("clicked",
+ self.__add_extension_button_clicked)
+ self.remove_extension_button.connect("clicked",
+ self.__remove_extension_button_clicked)
+
+ selection = self.extensions_treeview.get_selection()
+ selection.connect("changed",
+ self.__extensions_treeview_selection_changed)
# Buttons
self.close_button.connect("clicked", self.__close_button_clicked)
@@ -109,6 +183,8 @@
self.__ask_for_location_key_changed)
self.config.add_notify(Configuration.KEY_DEFAULT_FOLDER,
self.__default_folder_key_changed)
+ self.config.add_notify(Configuration.KEY_CHECK_EXTENSIONS,
+ self.__check_extensions_key_changed)
def __show_status_icon_key_changed(self, client, cnxn_id, entry, data):
if not entry.value:
@@ -132,8 +208,7 @@
if not entry.value:
self.main_window_checkbutton.set_active(True)
elif entry.value.type == gconf.VALUE_BOOL:
- value = entry.value.get_bool()
- self.main_window_checkbutton.set_active(value)
+ self.main_window_checkbutton.set_active(entry.value.get_bool())
else:
self.main_window_checkbutton.set_active(True)
@@ -194,6 +269,18 @@
folder = entry.value.to_string()
self.default_folder_filechooserbutton.set_current_folder(folder)
+ def __check_extensions_key_changed(self, client, cnxn_id, entry, data):
+ if not entry.value:
+ self.extensions_checkbutton.set_active(True)
+ self.extensions_alignment.set_sensitive(True)
+ elif entry.value.type == gconf.VALUE_BOOL:
+ value = entry.value.get_bool()
+ self.extensions_checkbutton.set_active(value)
+ self.extensions_alignment.set_sensitive(value)
+ else:
+ self.extensions_checkbutton.set_active(True)
+ self.extensions_alignment.set_sensitive(True)
+
def __status_icon_checkbutton_toggled(self, checkbutton):
self.config.show_status_icon = checkbutton.get_active()
@@ -218,6 +305,48 @@
if self.config.default_folder != folder:
self.config.default_folder = folder
+ def __extensions_checkbutton_toggled(self, checkbutton):
+ self.config.check_extensions = checkbutton.get_active()
+
+ def __extensions_treeview_selection_changed(self, selection):
+ """When selection changes set sensitivity appropriately."""
+ (extensions_model, extensions_iter) = selection.get_selected()
+ if extensions_iter:
+ self.remove_extension_button.set_sensitive(True)
+ else:
+ self.remove_extension_button.set_sensitive(False)
+
+ def __add_extension_button_clicked(self, button):
+ extensions = self.config.extensions
+ extensions.append("*.*")
+ self.config.extensions = extensions
+
+ extension_folders = self.config.extension_folders
+ extension_folders.append(self.config.default_folder)
+ self.config.extension_folders = extension_folders
+
+ iter = self.extensions_model.append(("*.*", self.config.default_folder))
+ path = self.extensions_model.get_path(iter)
+ self.extensions_treeview.set_cursor_on_cell(path,
+ self.extension_treeview_column, self.extension_cell_renderer,
+ True)
+
+ def __remove_extension_button_clicked(self, button):
+ selection = self.extensions_treeview.get_selection()
+ (extensions_model, extensions_iter) = selection.get_selected()
+ if extensions_iter:
+ extension = extensions_model.get_value(extensions_iter, 0)
+ extension_folder = extensions_model.get_value(extensions_iter, 1)
+ extensions_model.remove(extensions_iter)
+ extensions = self.config.extensions
+ if extension in extensions:
+ extensions.remove(extension)
+ self.config.extensions = extensions
+ extension_folders = self.config.extension_folders
+ if extension_folder in extension_folders:
+ extension_folders.remove(extension_folder)
+ self.config.extension_folders = extension_folders
+
def __close_button_clicked(self, button):
self.dialog.hide()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]