gget r4 - in trunk: data gget



Author: johans
Date: Fri Jun 13 13:15:23 2008
New Revision: 4
URL: http://svn.gnome.org/viewvc/gget?rev=4&view=rev

Log:
Worked on GUI and gconf abstraction.

Added:
   trunk/gget/AddDownloadDialog.py
   trunk/gget/Configuration.py
   trunk/gget/PreferencesDialog.py
Modified:
   trunk/data/gget.glade
   trunk/data/gget.schemas.in
   trunk/gget/GUI.py
   trunk/gget/Main.py
   trunk/gget/MainWindow.py
   trunk/gget/Makefile.am
   trunk/gget/StatusIcon.py

Modified: trunk/data/gget.glade
==============================================================================
--- trunk/data/gget.glade	(original)
+++ trunk/data/gget.glade	Fri Jun 13 13:15:23 2008
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Tue Jun 10 16:16:34 2008 -->
+<!--Generated with glade3 3.4.5 on Fri Jun 13 15:11:41 2008 -->
 <glade-interface>
   <widget class="GtkWindow" id="main_window">
     <property name="width_request">800</property>
     <property name="height_request">600</property>
     <property name="title" translatable="yes">GGet</property>
+    <property name="window_position">GTK_WIN_POS_CENTER</property>
     <child>
       <widget class="GtkVBox" id="vbox">
         <property name="visible">True</property>
@@ -26,6 +27,7 @@
                         <property name="label" translatable="yes">gtk-add</property>
                         <property name="use_underline">True</property>
                         <property name="use_stock">True</property>
+                        <accelerator key="a" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                       </widget>
                     </child>
                     <child>
@@ -54,6 +56,27 @@
                   <widget class="GtkMenu" id="menu2">
                     <property name="visible">True</property>
                     <child>
+                      <widget class="GtkMenuItem" id="menuitem3">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Select all</property>
+                        <property name="use_underline">True</property>
+                        <accelerator key="a" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkMenuItem" id="menuitem5">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Unselect all</property>
+                        <property name="use_underline">True</property>
+                        <accelerator key="a" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK" signal="activate"/>
+                      </widget>
+                    </child>
+                    <child>
+                      <widget class="GtkSeparatorMenuItem" id="separatormenuitem2">
+                        <property name="visible">True</property>
+                      </widget>
+                    </child>
+                    <child>
                       <widget class="GtkImageMenuItem" id="preferences_menu_item">
                         <property name="visible">True</property>
                         <property name="label" translatable="yes">gtk-preferences</property>
@@ -151,4 +174,498 @@
       </widget>
     </child>
   </widget>
+  <widget class="GtkDialog" id="add_dialog">
+    <property name="border_width">6</property>
+    <property name="title" translatable="yes">Add</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="default_width">500</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="spacing">12</property>
+        <child>
+          <widget class="GtkHBox" id="hbox1">
+            <property name="visible">True</property>
+            <property name="border_width">6</property>
+            <property name="spacing">12</property>
+            <child>
+              <widget class="GtkImage" id="image1">
+                <property name="visible">True</property>
+                <property name="yalign">0</property>
+                <property name="stock">gtk-add</property>
+                <property name="icon_size">6</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkVBox" id="vbox1">
+                <property name="visible">True</property>
+                <property name="spacing">12</property>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">&lt;big&gt;&lt;b&gt;Add new Download&lt;/b&gt;&lt;/big&gt;</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label2">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="yalign">0</property>
+                    <property name="label" translatable="yes">Please enter the URL to the file you would like to download and select a folder to save it in.</property>
+                    <property name="wrap">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkTable" id="table1">
+                    <property name="visible">True</property>
+                    <property name="n_rows">2</property>
+                    <property name="n_columns">2</property>
+                    <property name="column_spacing">12</property>
+                    <property name="row_spacing">6</property>
+                    <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>
+                      </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>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label4">
+                        <property name="visible">True</property>
+                        <property name="xalign">1</property>
+                        <property name="label" translatable="yes">_Download folder:</property>
+                        <property name="use_underline">True</property>
+                        <property name="mnemonic_widget">download_filechooserbutton</property>
+                      </widget>
+                      <packing>
+                        <property name="top_attach">1</property>
+                        <property name="bottom_attach">2</property>
+                        <property name="x_options">GTK_FILL</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkFileChooserButton" id="download_filechooserbutton">
+                        <property name="visible">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>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="add_cancel_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="add_add_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-add</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="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+  <widget class="GtkDialog" id="preferences_dialog">
+    <property name="border_width">6</property>
+    <property name="title" translatable="yes">Preferences for GGet</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="preferences_dialog_vbox">
+        <property name="visible">True</property>
+        <property name="spacing">6</property>
+        <child>
+          <widget class="GtkNotebook" id="prefences_notebook">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="border_width">6</property>
+            <child>
+              <widget class="GtkVBox" id="general_vbox">
+                <property name="visible">True</property>
+                <property name="border_width">6</property>
+                <child>
+                  <widget class="GtkAlignment" id="alignment4">
+                    <property name="visible">True</property>
+                    <property name="top_padding">6</property>
+                    <property name="bottom_padding">6</property>
+                    <child>
+                      <widget class="GtkFrame" id="show_frame">
+                        <property name="visible">True</property>
+                        <property name="label_xalign">0</property>
+                        <property name="shadow_type">GTK_SHADOW_NONE</property>
+                        <child>
+                          <widget class="GtkAlignment" id="alignment5">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <widget class="GtkVBox" id="show_vbox">
+                                <property name="visible">True</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <widget class="GtkCheckButton" id="status_icon_checkbutton">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="label" translatable="yes">Status icon in notification area</property>
+                                    <property name="response_id">0</property>
+                                    <property name="draw_indicator">True</property>
+                                  </widget>
+                                </child>
+                                <child>
+                                  <widget class="GtkCheckButton" id="main_window_checkbutton">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="label" translatable="yes">Main window on startup</property>
+                                    <property name="response_id">0</property>
+                                    <property name="draw_indicator">True</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                            </child>
+                          </widget>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="show_label">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">&lt;b&gt;Show&lt;/b&gt;</property>
+                            <property name="use_markup">True</property>
+                          </widget>
+                          <packing>
+                            <property name="type">label_item</property>
+                          </packing>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkAlignment" id="alignment6">
+                    <property name="visible">True</property>
+                    <property name="top_padding">6</property>
+                    <property name="bottom_padding">12</property>
+                    <child>
+                      <widget class="GtkFrame" id="startup_frame">
+                        <property name="visible">True</property>
+                        <property name="label_xalign">0</property>
+                        <property name="shadow_type">GTK_SHADOW_NONE</property>
+                        <child>
+                          <widget class="GtkAlignment" id="alignment7">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <widget class="GtkVBox" id="startup_vbox">
+                                <property name="visible">True</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <widget class="GtkCheckButton" id="autostart_checkbutton">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="label" translatable="yes">Start GGet at login</property>
+                                    <property name="response_id">0</property>
+                                    <property name="draw_indicator">True</property>
+                                  </widget>
+                                </child>
+                                <child>
+                                  <widget class="GtkCheckButton" id="autoresume_checkbutton">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="label" translatable="yes">Resume paused downloads</property>
+                                    <property name="response_id">0</property>
+                                    <property name="draw_indicator">True</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                            </child>
+                          </widget>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="startup_label">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">&lt;b&gt;Startup&lt;/b&gt;</property>
+                            <property name="use_markup">True</property>
+                          </widget>
+                          <packing>
+                            <property name="type">label_item</property>
+                          </packing>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="general_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">General</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkVBox" id="folders_vbox">
+                <property name="visible">True</property>
+                <property name="border_width">6</property>
+                <child>
+                  <widget class="GtkAlignment" id="folders_alignment">
+                    <property name="visible">True</property>
+                    <property name="top_padding">6</property>
+                    <child>
+                      <widget class="GtkFrame" id="default_download_folders_frame">
+                        <property name="visible">True</property>
+                        <property name="label_xalign">0</property>
+                        <property name="shadow_type">GTK_SHADOW_NONE</property>
+                        <child>
+                          <widget class="GtkAlignment" id="default_download_folders_alignment">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="bottom_padding">12</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <widget class="GtkVBox" id="default_download_folders_vbox">
+                                <property name="visible">True</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <widget class="GtkRadioButton" id="ask_folder_radiobutton">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="label" translatable="yes">Ask for download location</property>
+                                    <property name="response_id">0</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <widget class="GtkVBox" id="specify_folder_vbox">
+                                    <property name="visible">True</property>
+                                    <property name="spacing">3</property>
+                                    <child>
+                                      <widget class="GtkRadioButton" id="specify_folder_radiobutton">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="label" translatable="yes">Place new downloads in default folder:</property>
+                                        <property name="response_id">0</property>
+                                        <property name="draw_indicator">True</property>
+                                        <property name="group">ask_folder_radiobutton</property>
+                                      </widget>
+                                    </child>
+                                    <child>
+                                      <widget class="GtkAlignment" id="default_folder_alignment">
+                                        <property name="visible">True</property>
+                                        <property name="left_padding">20</property>
+                                        <child>
+                                          <widget class="GtkFileChooserButton" id="default_folder_filechooserbutton">
+                                            <property name="visible">True</property>
+                                            <property name="sensitive">False</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>
+                                      </widget>
+                                      <packing>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </widget>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </widget>
+                            </child>
+                          </widget>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="default_download_folders_label">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">&lt;b&gt;Default Download Folders&lt;/b&gt;</property>
+                            <property name="use_markup">True</property>
+                          </widget>
+                          <packing>
+                            <property name="type">label_item</property>
+                          </packing>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="folders_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Folders</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkVBox" id="network_vbox">
+                <property name="visible">True</property>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="network_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Network</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="position">2</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area2">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_EDGE</property>
+            <child>
+              <widget class="GtkButton" id="help_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-help</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="close_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-close</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="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>

Modified: trunk/data/gget.schemas.in
==============================================================================
--- trunk/data/gget.schemas.in	(original)
+++ trunk/data/gget.schemas.in	Fri Jun 13 13:15:23 2008
@@ -1,14 +1,69 @@
 <gconfschemafile>
     <schemalist>
         <schema>
-            <key>/schemas/apps/gget/download_path</key>
-            <applyto>/apps/gget/download_path</applyto>
+            <key>/schemas/apps/gget/general/show_status_icon</key>
+            <applyto>/apps/gget/general/show_status_icon</applyto>
+            <owner>gget</owner>
+            <type>bool</type>
+            <default>true</default>
+            <locale name="C">
+                <short>Show status icon</short>
+                <long>Whether GGet should display a status icon in the notification area.</long>
+            </locale>
+        </schema>
+        <schema>
+            <key>/schemas/apps/gget/general/show_main_window</key>
+            <applyto>/apps/gget/general/show_main_window</applyto>
+            <owner>gget</owner>
+            <type>bool</type>
+            <default>true</default>
+            <locale name="C">
+                <short>Show main window</short>
+                <long>Whether GGet should display the main window on startup.</long>
+            </locale>
+        </schema>
+        <schema>
+            <key>/schemas/apps/gget/general/autostart</key>
+            <applyto>/apps/gget/general/autostart</applyto>
+            <owner>gget</owner>
+            <type>bool</type>
+            <default>false</default>
+            <locale name="C">
+                <short>Autostart at login</short>
+                <long>Whether GGet should start automatically at login.</long>
+            </locale>
+        </schema>
+        <schema>
+            <key>/schemas/apps/gget/general/autoresume</key>
+            <applyto>/apps/gget/general/autoresume</applyto>
+            <owner>gget</owner>
+            <type>bool</type>
+            <default>false</default>
+            <locale name="C">
+                <short>Autoresume downloads on startup</short>
+                <long>Whether GGet should automatically resume paused downloads on startup.</long>
+            </locale>
+        </schema>
+        <schema>
+            <key>/schemas/apps/gget/folders/ask_for_location</key>
+            <applyto>/apps/gget/folders/ask_for_location</applyto>
+            <owner>gget</owner>
+            <type>bool</type>
+            <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>
+            </locale>
+        </schema>
+        <schema>
+            <key>/schemas/apps/gget/folders/default_folder</key>
+            <applyto>/apps/gget/folders/default_folder</applyto>
             <owner>gget</owner>
             <type>string</type>
-            <default>~</default>
+            <default></default>
             <locale name="C">
-                <short>Default Download Path</short>
-                <long>Default location where downloaded files will be saved.</long>
+                <short>Default download folder</short>
+                <long>Default location where GGet will save downloaded files.</long>
             </locale>
         </schema>
     </schemalist>

Added: trunk/gget/AddDownloadDialog.py
==============================================================================
--- (empty file)
+++ trunk/gget/AddDownloadDialog.py	Fri Jun 13 13:15:23 2008
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2008 Johan Svedberg <johan svedberg com>
+
+# This file is part of gget.
+
+# gget is free software; you can 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.
+
+# gget 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 gget; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+from gettext import gettext as _
+
+import gtk
+
+import GUI
+from gget import NAME
+
+class AddDownloadDialog:
+    def __init__(self):
+        self.__get_widgets()
+        self.__connect_widgets()
+
+    def __get_widgets(self):
+        xml = gtk.glade.XML(GUI.glade_file, domain=NAME.lower())
+
+        self.dialog = xml.get_widget("add_dialog")
+
+        self.url_entry = xml.get_widget("url_entry")
+
+        self.add_button = xml.get_widget("add_add_button")
+        self.cancel_button = xml.get_widget("add_cancel_button")
+
+    def __connect_widgets(self):
+        self.url_entry.connect("changed", self.__url_entry_changed)
+        self.url_entry.connect("activate", self.__url_entry_activate)
+
+        self.add_button.connect("clicked", self.__add_button_clicked)
+        self.cancel_button.connect("clicked", self.__cancel_button_clicked)
+
+    def __url_entry_changed(self, entry):
+        url = entry.get_text()
+        if len(url) > 0 and url.startswith("http://";):
+            self.add_button.set_sensitive(True)
+        else:
+            self.add_button.set_sensitive(False)
+
+    def __url_entry_activate(self, entry):
+        self.add_button.clicked()
+
+    def __add_button_clicked(self, button):
+        self.dialog.hide()
+
+    def __cancel_button_clicked(self, button):
+        self.dialog.hide()
+
+# vim: set sw=4 et sts=4 tw=79 fo+=l:

Added: trunk/gget/Configuration.py
==============================================================================
--- (empty file)
+++ trunk/gget/Configuration.py	Fri Jun 13 13:15:23 2008
@@ -0,0 +1,168 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2008 Johan Svedberg <johan svedberg com>
+
+# This file is part of gget.
+
+# gget is free software; you can 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.
+
+# gget 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 gget; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+import os.path
+import sys
+from gettext import gettext as _
+
+import gconf
+
+from GUI import ErrorDialog
+
+DIR_GGET = "/apps/gget"
+
+KEY_SHOW_STATUS_ICON = "/general/show_status_icon"
+KEY_SHOW_MAIN_WINDOW = "/general/show_main_window"
+KEY_AUTOSTART        = "/general/autostart"
+KEY_AUTORESUME       = "/general/autoresume"
+KEY_ASK_FOR_LOCATION = "/folders/ask_for_location"
+KEY_DEFAULT_FOLDER   = "/folders/default_folder"
+
+FUNCTION_SUFFIXES = {KEY_SHOW_STATUS_ICON: 'bool',
+                     KEY_SHOW_MAIN_WINDOW: 'bool',
+                     KEY_AUTOSTART:        'bool',
+                     KEY_AUTORESUME:       'bool',
+                     KEY_ASK_FOR_LOCATION: 'bool',
+                     KEY_DEFAULT_FOLDER:   'string'}
+
+class Configuration(object):
+    """Singleton representing the configuration"""
+
+    instance = None
+
+    def __new__(type, *args):
+        if Configuration.instance is None:
+            Configuration.instance = object.__new__(type)
+            Configuration.instance.__init(*args)
+        return Configuration.instance
+
+    def __init(self, *args):
+        # self.base_dir = os.path.expanduser("~/.gnome2/gget")
+        # if not os.path.exists(self.base_dir):
+            # os.makedirs(self.base_dir)
+
+        self.client = gconf.client_get_default()
+        if self.client.dir_exists(DIR_GGET):
+            self.client.add_dir(DIR_GGET, gconf.CLIENT_PRELOAD_RECURSIVE)
+            self.debug = args[0] or os.getenv("GGET_DEBUG")
+            self.__init_option_cache()
+        else:
+            ed = ErrorDialog(_("Could not find configuration directory in GConf"), _("Please make sure that gget.schemas was correctly installed."))
+            ed.run()
+            sys.exit(1)
+
+    def __init_option_cache(self):
+        self.option_cache = {}
+        for key in FUNCTION_SUFFIXES.keys():
+            self.option_cache[key] = getattr(self, 'get_' +
+                                             os.path.basename(key))(False)
+
+    def add_notify(self, key, callback):
+        self.client.notify_add(DIR_GGET + key, callback)
+
+    def __get_option(self, option, type=None):
+        if self.debug:
+            print '[GConf get]: %s%s' % (DIR_GGET, option)
+        if type:
+            return getattr(self.client, 'get_' +
+                           FUNCTION_SUFFIXES[option])(DIR_GGET + option, type)
+        else:
+            return getattr(self.client, 'get_' +
+                           FUNCTION_SUFFIXES[option])(DIR_GGET + option)
+
+    def __set_option(self, option, value, type=None):
+        if self.debug:
+            print '[GConf set]: %s%s=%s' % (DIR_GGET, option, str(value))
+        if type:
+            getattr(self.client, 'set_' +
+                    FUNCTION_SUFFIXES[option])(DIR_GGET + option, type, value)
+            self.option_cache[option] = value
+        else:
+            getattr(self.client, 'set_' +
+                    FUNCTION_SUFFIXES[option])(DIR_GGET + option, value)
+            self.option_cache[option] = value
+
+    def get_show_status_icon(self, use_cache=True):
+        if use_cache:
+            return self.option_cache[KEY_SHOW_STATUS_ICON]
+        else:
+            return self.__get_option(KEY_SHOW_STATUS_ICON)
+
+    def set_show_status_icon(self, show_status_icon):
+        self.__set_option(KEY_SHOW_STATUS_ICON, show_status_icon)
+
+    show_status_icon = property(get_show_status_icon, set_show_status_icon)
+
+    def get_show_main_window(self, use_cache=True):
+        if use_cache:
+            return self.option_cache[KEY_SHOW_MAIN_WINDOW]
+        else:
+            return self.__get_option(KEY_SHOW_MAIN_WINDOW)
+
+    def set_show_main_window(self, show_main_window):
+        self.__set_option(KEY_SHOW_MAIN_WINDOW, show_main_window)
+
+    show_main_window = property(get_show_main_window, set_show_main_window)
+
+    def get_autostart(self, use_cache=True):
+        if use_cache:
+            return self.option_cache[KEY_AUTOSTART]
+        else:
+            return self.__get_option(KEY_AUTOSTART)
+
+    def set_autostart(self, autostart):
+        self.__set_option(KEY_AUTOSTART, autostart)
+
+    autostart = property(get_autostart, set_autostart)
+
+    def get_autoresume(self, use_cache=True):
+        if use_cache:
+            return self.option_cache[KEY_AUTORESUME]
+        else:
+            return self.__get_option(KEY_AUTORESUME)
+
+    def set_autoresume(self, autoresume):
+        self.__set_option(KEY_AUTORESUME, autoresume)
+
+    autoresume = property(get_autoresume, set_autoresume)
+
+    def get_ask_for_location(self, use_cache=True):
+        if use_cache:
+            return self.option_cache[KEY_ASK_FOR_LOCATION]
+        else:
+            return self.__get_option(KEY_ASK_FOR_LOCATION)
+
+    def set_ask_for_location(self, ask_for_location):
+        self.__set_option(KEY_ASK_FOR_LOCATION, ask_for_location)
+
+    ask_for_location = property(get_ask_for_location, set_ask_for_location)
+
+    def get_default_folder(self, use_cache=True):
+        if use_cache:
+            return self.option_cache[KEY_DEFAULT_FOLDER]
+        else:
+            return self.__get_option(KEY_DEFAULT_FOLDER)
+
+    def set_default_folder(self, default_folder):
+        self.__set_option(KEY_DEFAULT_FOLDER, default_folder)
+
+    default_folder = property(get_default_folder, set_default_folder)
+
+# vim: set sw=4 et sts=4 tw=79 fo+=l:

Modified: trunk/gget/GUI.py
==============================================================================
--- trunk/gget/GUI.py	(original)
+++ trunk/gget/GUI.py	Fri Jun 13 13:15:23 2008
@@ -58,9 +58,18 @@
                 pixbuf = icon_theme.load_icon(icon, width,
                                               gtk.ICON_LOOKUP_USE_BUILTIN)
             except Exception, msg2:
-                print 'Error:load_icon:Icon Load Error:%s (or %s)' % (msg1, msg2
-)
+                print 'Error:load_icon:Icon Load Error:%s (or %s)' % (msg1,
+                                                                      msg2)
 
     return pixbuf
 
+class ErrorDialog(gtk.MessageDialog):
+    def __init__(self, primary_msg, secondary_msg):
+        gtk.MessageDialog.__init__(self, parent=None,
+                flags=gtk.DIALOG_MODAL|gtk . DIALOG_DESTROY_WITH_PARENT,
+                type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK,
+                message_format=primary_msg)
+        self.format_secondary_text(secondary_msg)
+        self.set_title(_("Error"))
+
 # vim: set sw=4 et sts=4 tw=79 fo+=l:

Modified: trunk/gget/Main.py
==============================================================================
--- trunk/gget/Main.py	(original)
+++ trunk/gget/Main.py	Fri Jun 13 13:15:23 2008
@@ -32,6 +32,7 @@
 import GUI
 from MainWindow import MainWindow
 from StatusIcon import StatusIcon
+from Configuration import Configuration
 from gget import NAME, VERSION, LOCALE_DIR
 
 def main():
@@ -58,10 +59,14 @@
     # gtk.gdk.threads_init()
     gtk.window_set_default_icon_list(*GUI.get_icon_list([16, 22, 24, 32]))
 
-    main_window = MainWindow()
-    main_window.window.show()
+    config = Configuration(debug)
 
-    status_icon = StatusIcon(main_window)
+    main_window = MainWindow(config)
+    if config.show_main_window:
+        main_window.window.show()
+
+    if config.show_status_icon:
+        status_icon = StatusIcon(main_window)
 
     gtk.main()
 

Modified: trunk/gget/MainWindow.py
==============================================================================
--- trunk/gget/MainWindow.py	(original)
+++ trunk/gget/MainWindow.py	Fri Jun 13 13:15:23 2008
@@ -22,10 +22,14 @@
 
 import GUI
 from AboutDialog import AboutDialog
+from AddDownloadDialog import AddDownloadDialog
+from PreferencesDialog import PreferencesDialog
 from gget import NAME
 
 class MainWindow:
-    def __init__(self):
+    def __init__(self, config):
+        self.config = config
+
         self.__get_widgets()
         self.__connect_widgets()
 
@@ -53,7 +57,7 @@
         self.window.connect("destroy", self.quit)
 
         # File menu
-        self.add_menu_item.connect("activate", self.add_transfer)
+        self.add_menu_item.connect("activate", self.add_download)
         self.quit_menu_item.connect("activate", self.quit)
 
         # Edit menu
@@ -65,13 +69,15 @@
                 self.__about_menu_item_activate)
 
         # Toolbar
-        self.add_tool_button.connect("clicked", self.add_transfer)
+        self.add_tool_button.connect("clicked", self.add_download)
 
-    def add_transfer(self, widget):
-        pass
+    def add_download(self, widget):
+        add = AddDownloadDialog()
+        add.dialog.show()
 
     def __preferences_menu_item_activate(self, menu_item):
-        pass
+        pd = PreferencesDialog(self.config)
+        pd.dialog.show()
 
     def __about_menu_item_activate(self, menu_item):
         ad = AboutDialog()

Modified: trunk/gget/Makefile.am
==============================================================================
--- trunk/gget/Makefile.am	(original)
+++ trunk/gget/Makefile.am	Fri Jun 13 13:15:23 2008
@@ -1,10 +1,13 @@
 ggetdir = $(pythondir)/gget
 gget_PYTHON =			\
 	AboutDialog.py		\
+	AddDownloadDialog.py	\
+	Configuration.py	\
 	GUI.py			\
 	__init__.py		\
 	Main.py			\
 	MainWindow.py		\
+	PreferencesDialog.py	\
 	StatusIcon.py
 
 DISTCLEANFILES = __init__.py

Added: trunk/gget/PreferencesDialog.py
==============================================================================
--- (empty file)
+++ trunk/gget/PreferencesDialog.py	Fri Jun 13 13:15:23 2008
@@ -0,0 +1,177 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2008 Johan Svedberg <johan svedberg com>
+
+# This file is part of gget.
+
+# gget is free software; you can 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.
+
+# gget 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 gget; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+from gettext import gettext as _
+
+import gtk
+import gconf
+
+import Configuration
+import GUI
+from gget import NAME
+
+class PreferencesDialog:
+    def __init__(self, config):
+        self.config = config
+
+        self.__get_widgets()
+        self.__connect_widgets()
+        self.__add_config_notifications()
+
+        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)
+        self.autoresume_checkbutton.set_active(self.config.autoresume)
+        if self.config.ask_for_location:
+            self.ask_folder_radiobutton.set_active(True)
+        else:
+            self.specify_folder_radiobutton.set_active(True)
+        self.default_folder_filechooserbutton.set_current_folder(self.config.default_folder)
+
+    def __get_widgets(self):
+        xml = gtk.glade.XML(GUI.glade_file, domain=NAME.lower())
+
+        self.dialog = xml.get_widget("preferences_dialog")
+
+        # General tab
+        self.status_icon_checkbutton = xml.get_widget("status_icon_checkbutton")
+        self.main_window_checkbutton = xml.get_widget("main_window_checkbutton")
+
+        self.autostart_checkbutton = xml.get_widget("autostart_checkbutton")
+        self.autoresume_checkbutton = xml.get_widget("autoresume_checkbutton")
+
+        # Folders tab
+        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")
+
+        # Buttons
+        self.close_button = xml.get_widget("close_button")
+
+    def __connect_widgets(self):
+        # General tab
+        self.status_icon_checkbutton.connect("toggled",
+                self.__status_icon_checkbutton_toggled)
+        self.main_window_checkbutton.connect("toggled",
+                self.__main_window_checkbutton_toggled)
+
+        self.autostart_checkbutton.connect("toggled",
+                self.__autostart_checkbutton_toggled)
+        self.autoresume_checkbutton.connect("toggled",
+                self.__autoresume_checkbutton_toggled)
+
+        # Folders tab
+        self.ask_folder_radiobutton.connect("toggled",
+                self.__ask_folder_radiobutton_toggled)
+        self.default_folder_filechooserbutton.connect("current-folder-changed",
+                self.__default_folder_filechooserbutton_current_folder_changed)
+
+        # Buttons
+        self.close_button.connect("clicked", self.__close_button_clicked)
+
+    def __add_config_notifications(self):
+        self.config.add_notify(Configuration.KEY_SHOW_STATUS_ICON,
+                self.__show_status_icon_key_changed)
+        self.config.add_notify(Configuration.KEY_SHOW_MAIN_WINDOW,
+                self.__show_main_window_key_changed)
+        self.config.add_notify(Configuration.KEY_AUTOSTART,
+                self.__autostart_key_changed)
+        self.config.add_notify(Configuration.KEY_AUTORESUME,
+                self.__autoresume_key_changed)
+        self.config.add_notify(Configuration.KEY_ASK_FOR_LOCATION,
+                self.__ask_for_location_key_changed)
+        self.config.add_notify(Configuration.KEY_DEFAULT_FOLDER,
+                self.__default_folder_key_changed)
+
+    def __show_status_icon_key_changed(self, client, cnxn_id, entry, data):
+        if not entry.value:
+            self.status_icon_checkbutton.set_active(True)
+        elif entry.value.type == gconf.VALUE_BOOL:
+            value = entry.value.get_bool()
+            self.status_icon_checkbutton.set_active(value)
+        else:
+            self.status_icon_checkbutton.set_active(True)
+
+    def __show_main_window_key_changed(self, client, cnxn_id, entry, data):
+        if not entry.value:
+            self.main_window_checkbutton.set_active(True)
+        elif entry.value.type == gconf.VALUE_BOOL:
+            value = entry.value.get_bool()
+            self.status_icon_checkbutton.set_active(value)
+        else:
+            self.status_icon_checkbutton.set_active(True)
+
+    def __autostart_key_changed(self, client, cnxn_id, entry, data):
+        if not entry.value:
+            self.autostart_checkbutton.set_active(True)
+        elif entry.value.type == gconf.VALUE_BOOL:
+            value = entry.value.get_bool()
+            self.autostart_checkbutton.set_active(value)
+        else:
+            self.autostart_checkbutton.set_active(True)
+
+    def __autoresume_key_changed(self, client, cnxn_id, entry, data):
+        if not entry.value:
+            self.autoresume_checkbutton.set_active(True)
+        elif entry.value.type == gconf.VALUE_BOOL:
+            value = entry.value.get_bool()
+            self.autoresumet_checkbutton.set_active(value)
+        else:
+            self.autoresume_checkbutton.set_active(True)
+
+    def __ask_for_location_key_changed(self, client, cnxn_id, entry, data):
+        if not entry.value:
+            self.ask_folder_radiobutton.set_active(True)
+        elif entry.value.type == gconf.VALUE_BOOL:
+            value = entry.value.get_bool()
+            self.ask_folder_radiobutton.set_active(value)
+        else:
+            self.ask_folder_radiobutton.set_active(True)
+
+    def __default_folder_key_changed(self, client, cnxn_id, entry, data):
+        if entry.value.type == gconf.VALUE_STRING:
+            folder = entry.value.to_string()
+            self.default_folder_filechooserbutton.set_current_folder(folder)
+
+    def __status_icon_checkbutton_toggled(self, checkbutton):
+        self.config.show_status_icon = checkbutton.get_active()
+
+    def __main_window_checkbutton_toggled(self, checkbutton):
+        self.config.show_main_window = checkbutton.get_active()
+
+    def __autostart_checkbutton_toggled(self, checkbutton):
+        self.config.autostart = checkbutton.get_active()
+
+    def __autoresume_checkbutton_toggled(self, checkbutton):
+        self.config.autoresume = checkbutton.get_active()
+
+    def __ask_folder_radiobutton_toggled(self, radiobutton):
+        active = radiobutton.get_active()
+        self.config.ask_for_location = active
+        self.default_folder_filechooserbutton.set_sensitive(not active)
+
+    def __default_folder_filechooserbutton_current_folder_changed(self,
+            filechooserbutton):
+        self.config.default_folder = filechooserbutton.get_current_folder()
+
+    def __close_button_clicked(self, button):
+        self.dialog.hide()
+
+# vim: set sw=4 et sts=4 tw=79 fo+=l:

Modified: trunk/gget/StatusIcon.py
==============================================================================
--- trunk/gget/StatusIcon.py	(original)
+++ trunk/gget/StatusIcon.py	Fri Jun 13 13:15:23 2008
@@ -53,7 +53,7 @@
                 self.context_menu)
 
         self.quit_imi.connect("activate", self.main_window.quit)
-        self.add_imi.connect("activate", self.main_window.add_transfer)
+        self.add_imi.connect("activate", self.main_window.add_download)
 
     def __icon_clicked(self, icon):
         if self.main_window.window.get_property("visible"):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]