[rhythmbox] ipod: use media player source base class



commit 8254aa18f801035498e61ff7dc40c7aebc1be2a4
Author: Jonathan Matthew <jonathan d14n org>
Date:   Mon Dec 14 08:45:31 2009 +1000

    ipod: use media player source base class

 plugins/ipod/ipod-info.ui     |  657 ++++++++++++++++-------------------------
 plugins/ipod/rb-ipod-plugin.c |    6 +-
 plugins/ipod/rb-ipod-source.c |  249 +++++++++++-----
 plugins/ipod/rb-ipod-source.h |   12 +-
 4 files changed, 440 insertions(+), 484 deletions(-)
---
diff --git a/plugins/ipod/ipod-info.ui b/plugins/ipod/ipod-info.ui
index ddba4c0..aabcf71 100644
--- a/plugins/ipod/ipod-info.ui
+++ b/plugins/ipod/ipod-info.ui
@@ -2,424 +2,273 @@
 <interface>
   <!-- interface-requires gtk+ 2.12 -->
   <!-- interface-naming-policy toplevel-contextual -->
-  <object class="GtkDialog" id="ipod-information">
+  <object class="GtkTable" id="ipod-basic-info">
     <property name="visible">True</property>
-    <property name="title" translatable="yes">iPod Properties</property>
-    <property name="type_hint">dialog</property>
-    <property name="has_separator">False</property>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox1">
+    <property name="border_width">12</property>
+    <property name="n_rows">4</property>
+    <property name="n_columns">2</property>
+    <property name="column_spacing">12</property>
+    <property name="row_spacing">6</property>
+    <child>
+      <object class="GtkEntry" id="ipod-name-entry">
         <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="invisible_char">&#x25CF;</property>
+      </object>
+      <packing>
+        <property name="left_attach">1</property>
+        <property name="right_attach">2</property>
+        <property name="y_options"></property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="label-ipod-name">
+        <property name="visible">True</property>
+        <property name="xalign">0</property>
+        <property name="label" translatable="yes">iPod Name:</property>
+      </object>
+      <packing>
+        <property name="x_options">GTK_FILL</property>
+        <property name="y_options"></property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="label-num-tracks">
+        <property name="visible">True</property>
+        <property name="label" translatable="yes">Tracks:</property>
+      </object>
+      <packing>
+        <property name="top_attach">1</property>
+        <property name="bottom_attach">2</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="label-num-podcasts">
+        <property name="visible">True</property>
+        <property name="label" translatable="yes">Podcasts:</property>
+      </object>
+      <packing>
+        <property name="top_attach">2</property>
+        <property name="bottom_attach">3</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="label-num-playlists">
+        <property name="visible">True</property>
+        <property name="label" translatable="yes">Playlists:</property>
+      </object>
+      <packing>
+        <property name="top_attach">3</property>
+        <property name="bottom_attach">4</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="ipod-num-tracks">
+        <property name="visible">True</property>
+      </object>
+      <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>
+      <object class="GtkLabel" id="ipod-num-podcasts">
+        <property name="visible">True</property>
+      </object>
+      <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>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="ipod-num-playlists">
+        <property name="visible">True</property>
+      </object>
+      <packing>
+        <property name="left_attach">1</property>
+        <property name="right_attach">2</property>
+        <property name="top_attach">3</property>
+        <property name="bottom_attach">4</property>
+      </packing>
+    </child>
+  </object>
+  <object class="GtkFrame" id="ipod-advanced-tab">
+    <property name="visible">True</property>
+    <property name="border_width">12</property>
+    <property name="label_xalign">0</property>
+    <property name="shadow_type">none</property>
+    <child>
+      <object class="GtkTable" id="table2">
+        <property name="visible">True</property>
+        <property name="border_width">12</property>
+        <property name="n_rows">6</property>
+        <property name="n_columns">2</property>
+        <property name="column_spacing">12</property>
+        <property name="row_spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="label-device-node-value">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+          </object>
+          <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="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label-mount-point-value">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label-device-node">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Device Node:</property>
+          </object>
+          <packing>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label-mount-point">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Mount Point:</property>
+          </object>
+          <packing>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label-database-version">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Database Version:</property>
+          </object>
+          <packing>
+            <property name="top_attach">5</property>
+            <property name="bottom_attach">6</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
         <child>
-          <object class="GtkNotebook" id="notebook1">
+          <object class="GtkLabel" id="label-database-version-value">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="border_width">6</property>
-            <child>
-              <object class="GtkVBox" id="vbox1">
-                <property name="visible">True</property>
-                <property name="border_width">12</property>
-                <child>
-                  <object class="GtkFrame" id="frame1">
-                    <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">none</property>
-                    <child>
-                      <object class="GtkTable" id="table-information">
-                        <property name="visible">True</property>
-                        <property name="border_width">12</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>
-                          <object class="GtkEntry" id="entry-ipod-name">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label-ipod-name">
-                            <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">iPod Name:</property>
-                          </object>
-                          <packing>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label-ipod-usage">
-                            <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes" comments="amount of disk space used on the iPod">Volume Usage:</property>
-                          </object>
-                          <packing>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkProgressBar" id="progressbar-ipod-usage">
-                            <property name="visible">True</property>
-                            <property name="pulse_step">0.10000000149</property>
-                          </object>
-                          <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">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                      </object>
-                    </child>
-                    <child type="label">
-                      <object class="GtkLabel" id="label-frame-information">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">&lt;b&gt;Information&lt;/b&gt;</property>
-                        <property name="use_markup">True</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkFrame" id="frame3">
-                    <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">none</property>
-                    <child>
-                      <object class="GtkTable" id="table-content">
-                        <property name="visible">True</property>
-                        <property name="border_width">12</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>
-                          <object class="GtkLabel" id="label-number-playlist-number">
-                            <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <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">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label-number-track-number">
-                            <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="justify">right</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label-number-playlist">
-                            <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Number of Playlists:</property>
-                          </object>
-                          <packing>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkLabel" id="label-number-tracks">
-                            <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Number of Tracks:</property>
-                          </object>
-                          <packing>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                      </object>
-                    </child>
-                    <child type="label">
-                      <object class="GtkLabel" id="label-frame-content">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">&lt;b&gt;Content&lt;/b&gt;</property>
-                        <property name="use_markup">True</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label-notebook-basic">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Basic</property>
-              </object>
-              <packing>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkFrame" id="frame2">
-                <property name="visible">True</property>
-                <property name="border_width">12</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">none</property>
-                <child>
-                  <object class="GtkTable" id="table2">
-                    <property name="visible">True</property>
-                    <property name="border_width">12</property>
-                    <property name="n_rows">6</property>
-                    <property name="n_columns">2</property>
-                    <property name="column_spacing">12</property>
-                    <property name="row_spacing">6</property>
-                    <child>
-                      <object class="GtkLabel" id="label-device-node-value">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <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="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-mount-point-value">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-device-node">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Device Node:</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">1</property>
-                        <property name="bottom_attach">2</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-mount-point">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Mount Point:</property>
-                      </object>
-                      <packing>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-database-version">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Database Version:</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">5</property>
-                        <property name="bottom_attach">6</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-database-version-value">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">5</property>
-                        <property name="bottom_attach">6</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-firmware-version">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Firmware Version:</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-firmware-version-value">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">4</property>
-                        <property name="bottom_attach">5</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-serial-number">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Serial Number:</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
-                        <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-serial-number-value">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">1</property>
-                        <property name="right_attach">2</property>
-                        <property name="top_attach">3</property>
-                        <property name="bottom_attach">4</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-ipod-mode">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Model:</property>
-                      </object>
-                      <packing>
-                        <property name="top_attach">2</property>
-                        <property name="bottom_attach">3</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label-ipod-model-value">
-                        <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <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">GTK_FILL</property>
-                        <property name="y_options"></property>
-                      </packing>
-                    </child>
-                  </object>
-                </child>
-                <child type="label">
-                  <object class="GtkLabel" id="label-frame-system">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;b&gt;System&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                </child>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label-notebook-advanced">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Advanced</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
+            <property name="xalign">0</property>
           </object>
           <packing>
-            <property name="position">1</property>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="top_attach">5</property>
+            <property name="bottom_attach">6</property>
+            <property name="y_options"></property>
           </packing>
         </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area1">
+        <child>
+          <object class="GtkLabel" id="label-firmware-version">
             <property name="visible">True</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="closebutton1">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Firmware Version:</property>
           </object>
           <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
+            <property name="top_attach">4</property>
+            <property name="bottom_attach">5</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
           </packing>
         </child>
+        <child>
+          <object class="GtkLabel" id="label-firmware-version-value">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="top_attach">4</property>
+            <property name="bottom_attach">5</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label-serial-number">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Serial Number:</property>
+          </object>
+          <packing>
+            <property name="top_attach">3</property>
+            <property name="bottom_attach">4</property>
+            <property name="x_options">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label-serial-number-value">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="right_attach">2</property>
+            <property name="top_attach">3</property>
+            <property name="bottom_attach">4</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label-ipod-model">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Model:</property>
+          </object>
+          <packing>
+            <property name="top_attach">2</property>
+            <property name="bottom_attach">3</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label-ipod-model-value">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+          </object>
+          <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">GTK_FILL</property>
+            <property name="y_options"></property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <child type="label">
+      <object class="GtkLabel" id="label-frame-system">
+        <property name="visible">True</property>
+        <property name="label" translatable="yes">&lt;b&gt;System&lt;/b&gt;</property>
+        <property name="use_markup">True</property>
       </object>
     </child>
-    <action-widgets>
-      <action-widget response="-7">closebutton1</action-widget>
-    </action-widgets>
   </object>
 </interface>
diff --git a/plugins/ipod/rb-ipod-plugin.c b/plugins/ipod/rb-ipod-plugin.c
index d15ba7e..3f1528c 100644
--- a/plugins/ipod/rb-ipod-plugin.c
+++ b/plugins/ipod/rb-ipod-plugin.c
@@ -40,6 +40,7 @@
 
 #include "rb-ipod-helpers.h"
 #include "rb-removable-media-manager.h"
+#include "rb-media-player-source.h"
 #include "rb-sourcelist.h"
 #include "rb-source.h"
 #include "rb-ipod-source.h"
@@ -249,7 +250,8 @@ create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, MPIDDevice *devic
 
 	src = RB_SOURCE (rb_ipod_source_new (RB_PLUGIN (plugin),
 					     plugin->shell,
-					     mount));
+					     mount,
+					     device_info));
 
 	plugin->ipod_sources = g_list_prepend (plugin->ipod_sources, src);
 	g_signal_connect_object (G_OBJECT (src),
@@ -263,7 +265,7 @@ static void
 rb_ipod_plugin_cmd_properties (GtkAction *action, RBSource *source)
 {
 	g_return_if_fail (RB_IS_IPOD_SOURCE (source));
-	rb_ipod_source_show_properties (RB_IPOD_SOURCE (source));
+	rb_media_player_source_show_properties (RB_MEDIA_PLAYER_SOURCE (source));
 }
  
 static void
diff --git a/plugins/ipod/rb-ipod-source.c b/plugins/ipod/rb-ipod-source.c
index a59346a..6618f6d 100644
--- a/plugins/ipod/rb-ipod-source.c
+++ b/plugins/ipod/rb-ipod-source.c
@@ -48,11 +48,16 @@
 #include "rb-util.h"
 #include "rhythmdb.h"
 #include "rb-cut-and-paste-code.h"
+#include "rb-media-player-source.h"
+#include "rb-playlist-source.h"
+#include "rb-playlist-manager.h"
+#include "rb-podcast-manager.h"
 
 #define CONF_STATE_PANED_POSITION CONF_PREFIX "/state/ipod/paned_position"
 #define CONF_STATE_SHOW_BROWSER   CONF_PREFIX "/state/ipod/show_browser"
 
 static void rb_ipod_source_constructed (GObject *object);
+static void rb_ipod_source_class_init (RBiPodSourceClass *klass);
 static void rb_ipod_source_dispose (GObject *object);
 
 static char *impl_get_browser_key (RBSource *source);
@@ -85,6 +90,19 @@ static gboolean rb_ipod_song_artwork_add_cb (RhythmDB *db,
                                              const GValue *metadata,
                                              RBiPodSource *isource);
 
+static guint64 impl_get_capacity (RBMediaPlayerSource *source);
+static guint64 impl_get_free_space (RBMediaPlayerSource *source);
+static void impl_show_properties (RBMediaPlayerSource *source, GtkWidget *info_box, GtkWidget *notebook);
+
+static void rb_ipod_source_set_property (GObject *object,
+					 guint prop_id,
+					 const GValue *value,
+					 GParamSpec *pspec);
+static void rb_ipod_source_get_property (GObject *object,
+					 guint prop_id,
+					 GValue *value,
+					 GParamSpec *pspec);
+
 static RhythmDB *get_db_for_source (RBiPodSource *source);
 
 struct _PlayedEntry {
@@ -99,6 +117,8 @@ typedef struct
 	RbIpodDb *ipod_db;
 	GHashTable *entry_map;
 
+	MPIDDevice *device_info;
+
 	gboolean needs_shuffle_db;
 	RBIpodStaticPlaylistSource *podcast_pl;
 
@@ -115,9 +135,16 @@ typedef struct {
 	GdkPixbuf *pixbuf;
 } RBiPodSongArtworkAddData;
 
+enum
+{
+	PROP_0,
+	PROP_DEVICE_INFO,
+	PROP_DEVICE_SERIAL
+};
+
 RB_PLUGIN_DEFINE_TYPE(RBiPodSource,
 		      rb_ipod_source,
-		      RB_TYPE_REMOVABLE_MEDIA_SOURCE)
+		      RB_TYPE_MEDIA_PLAYER_SOURCE)
 
 #define IPOD_SOURCE_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_IPOD_SOURCE, RBiPodSourcePrivate))
 
@@ -126,12 +153,16 @@ rb_ipod_source_class_init (RBiPodSourceClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 	RBSourceClass *source_class = RB_SOURCE_CLASS (klass);
+	RBMediaPlayerSourceClass *mps_class = RB_MEDIA_PLAYER_SOURCE_CLASS (klass);
 	RBRemovableMediaSourceClass *rms_class = RB_REMOVABLE_MEDIA_SOURCE_CLASS (klass);
 	RBBrowserSourceClass *browser_source_class = RB_BROWSER_SOURCE_CLASS (klass);
 
 	object_class->constructed = rb_ipod_source_constructed;
 	object_class->dispose = rb_ipod_source_dispose;
 
+	object_class->set_property = rb_ipod_source_set_property;
+	object_class->get_property = rb_ipod_source_get_property;
+
 	source_class->impl_can_browse = (RBSourceFeatureFunc) rb_true_function;
 	source_class->impl_get_browser_key  = impl_get_browser_key;
 	source_class->impl_show_popup = impl_show_popup;
@@ -140,8 +171,12 @@ rb_ipod_source_class_init (RBiPodSourceClass *klass)
 	source_class->impl_move_to_trash = impl_move_to_trash;
 	source_class->impl_can_rename = (RBSourceFeatureFunc) rb_true_function;
 	source_class->impl_get_ui_actions = impl_get_ui_actions;
-
 	source_class->impl_can_paste = (RBSourceFeatureFunc) rb_true_function;
+
+	mps_class->impl_get_capacity = impl_get_capacity;
+	mps_class->impl_get_free_space = impl_get_free_space;
+	mps_class->impl_show_properties = impl_show_properties;
+
 	rms_class->impl_should_paste = rb_removable_media_source_should_paste_no_duplicate;
 	rms_class->impl_track_added = impl_track_added;
 	rms_class->impl_build_dest_uri = impl_build_dest_uri;
@@ -149,9 +184,60 @@ rb_ipod_source_class_init (RBiPodSourceClass *klass)
 
 	browser_source_class->impl_get_paned_key = impl_get_paned_key;
 
+	g_object_class_install_property (object_class,
+					 PROP_DEVICE_INFO,
+					 g_param_spec_object ("device-info",
+							      "device info",
+							      "device information object",
+							      MPID_TYPE_DEVICE,
+							      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+	g_object_class_override_property (object_class, PROP_DEVICE_SERIAL, "serial");
+
 	g_type_class_add_private (klass, sizeof (RBiPodSourcePrivate));
 }
 
+static void
+rb_ipod_source_set_property (GObject *object,
+			     guint prop_id,
+			     const GValue *value,
+			     GParamSpec *pspec)
+{
+	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (object);
+
+	switch (prop_id) {
+	case PROP_DEVICE_INFO:
+		priv->device_info = g_value_dup_object (value);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
+
+static void
+rb_ipod_source_get_property (GObject *object,
+			     guint prop_id,
+			     GValue *value,
+			     GParamSpec *pspec)
+{
+	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (object);
+
+	switch (prop_id) {
+	case PROP_DEVICE_INFO:
+		g_value_set_object (value, priv->device_info);
+		break;
+	case PROP_DEVICE_SERIAL:
+		{
+			char *serial;
+			g_object_get (priv->device_info, "serial", &serial, NULL);
+			g_value_take_string (value, serial);
+		}
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+		break;
+	}
+}
 
 static void
 rb_ipod_source_set_ipod_name (RBiPodSource *source, const char *name)
@@ -249,10 +335,11 @@ rb_ipod_source_dispose (GObject *object)
 	G_OBJECT_CLASS (rb_ipod_source_parent_class)->dispose (object);
 }
 
-RBRemovableMediaSource *
+RBMediaPlayerSource *
 rb_ipod_source_new (RBPlugin *plugin,
 		    RBShell *shell,
-		    GMount *mount)
+		    GMount *mount,
+		    MPIDDevice *device_info)
 {
 	RBiPodSource *source;
 	RhythmDBEntryType entry_type;
@@ -282,12 +369,13 @@ rb_ipod_source_new (RBPlugin *plugin,
 					       "mount", mount,
 					       "shell", shell,
 					       "source-group", RB_SOURCE_GROUP_DEVICES,
+					       "device-info", device_info,
 					       NULL));
 
 	rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);
         g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
 
-	return RB_REMOVABLE_MEDIA_SOURCE (source);
+	return RB_MEDIA_PLAYER_SOURCE (source);
 }
 
 static void
@@ -1588,17 +1676,6 @@ rb_ipod_source_remove_playlist (RBiPodSource *ipod_source,
 	rb_ipod_db_remove_playlist (priv->ipod_db, rb_ipod_static_playlist_source_get_itdb_playlist (playlist_source));
 }
 
-static void
-rb_ipod_info_response_cb (GtkDialog *dialog,
- 			  int response_id,
- 			  RBiPodSource *source)
-{
-	if (response_id == GTK_RESPONSE_CLOSE) {
- 		
-		gtk_widget_destroy (GTK_WIDGET (dialog));
-	}
-}
-
 static gboolean
 ipod_name_changed_cb (GtkWidget     *widget,
  		      GdkEventFocus *event,
@@ -1610,28 +1687,29 @@ ipod_name_changed_cb (GtkWidget     *widget,
 	return FALSE;
 }
 
-void
-rb_ipod_source_show_properties (RBiPodSource *source)
+
+static void
+impl_show_properties (RBMediaPlayerSource *source, GtkWidget *info_box, GtkWidget *notebook)
 {
+	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
+	GHashTableIter iter;
+	int num_podcasts;
+	gpointer key, value;
 	GtkBuilder *builder;
-	GObject *dialog;
-	GObject *label;
+	GtkWidget *widget;
 	char *text;
 	const gchar *mp;
-	char *used;
-	char *capacity;
 	char *builder_file;
- 	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
 	Itdb_Device *ipod_dev;
 	RBPlugin *plugin;
 
+	/* probably should display an error on the basic page in most of these error cases.. */
+
 	if (priv->ipod_db == NULL) {
 		rb_debug ("can't show ipod properties with no ipod db");
 		return;
 	}
 
-	ipod_dev = rb_ipod_db_get_device (priv->ipod_db);
-
 	g_object_get (source, "plugin", &plugin, NULL);
 	builder_file = rb_plugin_find_file (plugin, "ipod-info.ui");
 	g_object_unref (plugin);
@@ -1649,66 +1727,91 @@ rb_ipod_source_show_properties (RBiPodSource *source)
  		return;
  	}
 	
- 	dialog = gtk_builder_get_object (builder, "ipod-information");
- 	g_signal_connect_object (dialog,
- 				 "response",
- 				 G_CALLBACK (rb_ipod_info_response_cb),
- 				 source, 0);
- 
- 	label = gtk_builder_get_object (builder, "label-number-track-number");
- 	text = g_strdup_printf ("%u", g_list_length (rb_ipod_db_get_tracks(priv->ipod_db) ));
- 	gtk_label_set_text (GTK_LABEL (label), text);
- 	g_free (text);
- 
- 	label = gtk_builder_get_object (builder, "entry-ipod-name");
- 	gtk_entry_set_text (GTK_ENTRY (label), rb_ipod_db_get_ipod_name (priv->ipod_db));
- 	g_signal_connect (label, "focus-out-event",
+	ipod_dev = rb_ipod_db_get_device (priv->ipod_db);
+
+	/* basic tab stuff */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipod-basic-info"));
+	gtk_box_pack_start (GTK_BOX (info_box), widget, TRUE, TRUE, 0);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipod-name-entry"));
+	gtk_entry_set_text (GTK_ENTRY (widget), rb_ipod_db_get_ipod_name (priv->ipod_db));
+	g_signal_connect (widget, "focus-out-event",
  			  (GCallback)ipod_name_changed_cb, source);
- 
- 	label = gtk_builder_get_object (builder, "label-number-playlist-number");
- 	text = g_strdup_printf ("%u", g_list_length (rb_ipod_db_get_playlists (priv->ipod_db)));
- 	gtk_label_set_text (GTK_LABEL (label), text);
- 	g_free (text);
- 
- 	label = gtk_builder_get_object (builder, "label-mount-point-value");
-	mp = rb_ipod_db_get_mount_path (priv->ipod_db);
- 	gtk_label_set_text (GTK_LABEL (label), mp);
-
-	label = gtk_builder_get_object (builder, "progressbar-ipod-usage");
-	used = g_format_size_for_display (rb_ipod_helpers_get_capacity (mp) - rb_ipod_helpers_get_free_space (mp));
-	capacity = g_format_size_for_display (rb_ipod_helpers_get_capacity(mp));
-	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (label), 
-				       (double)(rb_ipod_helpers_get_capacity (mp) - rb_ipod_helpers_get_free_space (mp))/(double)rb_ipod_helpers_get_capacity (mp));
-	/* Translators: this is used to display the amount of storage space
-	 * used and the total storage space on an iPod.
-	 */
-	text = g_strdup_printf (_("%s of %s"), used, capacity);
-	gtk_progress_bar_set_text (GTK_PROGRESS_BAR (label), text);
+
+	num_podcasts = 0;
+	g_hash_table_iter_init (&iter, priv->entry_map);
+	while (g_hash_table_iter_next (&iter, &key, &value)) {
+		Itdb_Track *track = value;
+		if (track->mediatype == MEDIATYPE_PODCAST) {
+			num_podcasts++;
+		}
+	}
+
+	/* TODO these need to be updated as entries are added and removed. */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipod-num-tracks"));
+	text = g_strdup_printf ("%d", g_hash_table_size (priv->entry_map) - num_podcasts);
+	gtk_label_set_text (GTK_LABEL (widget), text);
+	g_free (text);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipod-num-podcasts"));
+	text = g_strdup_printf ("%d", num_podcasts);
+	gtk_label_set_text (GTK_LABEL (widget), text);
 	g_free (text);
-	g_free (capacity);
-	g_free (used);
 
-	label = gtk_builder_get_object (builder, "label-device-node-value");
+	/* TODO probably needs to ignore the master playlist? */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipod-num-playlists"));
+	text = g_strdup_printf ("%d", g_list_length (rb_ipod_db_get_playlists (priv->ipod_db)));
+	gtk_label_set_text (GTK_LABEL (widget), text);
+	g_free (text);
+
+	/* 'advanced' tab stuff */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "ipod-advanced-tab"));
+	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, gtk_label_new (_("Advanced")));
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-mount-point-value"));
+	mp = rb_ipod_db_get_mount_path (priv->ipod_db);
+	gtk_label_set_text (GTK_LABEL (widget), mp);
+
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-device-node-value"));
 	text = rb_ipod_helpers_get_device (RB_SOURCE(source));
-	gtk_label_set_text (GTK_LABEL (label), text);
+	gtk_label_set_text (GTK_LABEL (widget), text);
 	g_free (text);
 
- 	label = gtk_builder_get_object (builder, "label-ipod-model-value");
- 	gtk_label_set_text (GTK_LABEL (label), itdb_device_get_sysinfo (ipod_dev, "ModelNumStr"));
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-ipod-model-value"));
+	gtk_label_set_text (GTK_LABEL (widget), itdb_device_get_sysinfo (ipod_dev, "ModelNumStr"));
 
- 	label = gtk_builder_get_object (builder, "label-database-version-value");
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-database-version-value"));
 	text = g_strdup_printf ("%u", rb_ipod_db_get_database_version (priv->ipod_db));
- 	gtk_label_set_text (GTK_LABEL (label), text);
+	gtk_label_set_text (GTK_LABEL (widget), text);
 	g_free (text);
 
- 	label = gtk_builder_get_object (builder, "label-serial-number-value");
-	gtk_label_set_text (GTK_LABEL (label), itdb_device_get_sysinfo (ipod_dev, "pszSerialNumber"));
-
- 	label = gtk_builder_get_object (builder, "label-firmware-version-value");
-	gtk_label_set_text (GTK_LABEL (label), itdb_device_get_sysinfo (ipod_dev, "VisibleBuildID"));
+	g_object_get (priv->device_info, "serial", &text, NULL);
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-serial-number-value"));
+	gtk_label_set_text (GTK_LABEL (widget), text);
+	g_free (text);
 
- 	gtk_widget_show (GTK_WIDGET (dialog));
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-firmware-version-value"));
+	gtk_label_set_text (GTK_LABEL (widget), itdb_device_get_sysinfo (ipod_dev, "VisibleBuildID"));
 
 	g_object_unref (builder);
 }
 
+static const gchar *
+get_mount_point	(RBiPodSource *source)
+{
+	RBiPodSourcePrivate *priv = IPOD_SOURCE_GET_PRIVATE (source);
+	return rb_ipod_db_get_mount_path (priv->ipod_db);
+}
+
+static guint64
+impl_get_capacity (RBMediaPlayerSource *source)
+{
+	return rb_ipod_helpers_get_capacity (get_mount_point (RB_IPOD_SOURCE (source)));
+}
+
+static guint64
+impl_get_free_space (RBMediaPlayerSource *source)
+{
+	return rb_ipod_helpers_get_free_space (get_mount_point (RB_IPOD_SOURCE (source)));
+}
+
diff --git a/plugins/ipod/rb-ipod-source.h b/plugins/ipod/rb-ipod-source.h
index 25d7444..f93ac4b 100644
--- a/plugins/ipod/rb-ipod-source.h
+++ b/plugins/ipod/rb-ipod-source.h
@@ -29,9 +29,10 @@
 #define __RB_IPOD_SOURCE_H
 
 #include "rb-shell.h"
-#include "rb-removable-media-source.h"
+#include "rb-media-player-source.h"
 #include "rhythmdb.h"
 #include "rb-plugin.h"
+#include "mediaplayerid.h"
 
 G_BEGIN_DECLS
 
@@ -44,17 +45,18 @@ G_BEGIN_DECLS
 
 typedef struct
 {
-	RBRemovableMediaSource parent;
+	RBMediaPlayerSource parent;
 } RBiPodSource;
 
 typedef struct
 {
-	RBRemovableMediaSourceClass parent;
+	RBMediaPlayerSourceClass parent;
 } RBiPodSourceClass;
 
-RBRemovableMediaSource *rb_ipod_source_new		(RBPlugin *plugin,
+RBMediaPlayerSource    *rb_ipod_source_new		(RBPlugin *plugin,
 							 RBShell *shell,
-                                                         GMount *mount);
+                                                         GMount *mount,
+							 MPIDDevice *device_info);
 GType			rb_ipod_source_get_type		(void);
 GType                   rb_ipod_source_register_type    (GTypeModule *module);
 



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