From: David King Date: Tue, 8 Nov 2011 14:34:10 +0000 (+0100) Subject: ui: Improve preferences dialog, bug 663631 X-Git-Tag: RYGEL_0_13_1~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f68fdfe1fed2af11f4ef01b221afb044cc1065a5;p=profile%2Fivi%2Frygel.git ui: Improve preferences dialog, bug 663631 Add tooltips to the widgets in the preferences dialog. Add +/- ToolButtons for adding and removing shared directories. Update the sensitivity of the remove toolbutton, based on whether a row in the URI model is selected, or if the model is empty. Remove the GtkAlignments and use padding on containers. Set the correct response ID on the close button. Set the entry text column in the GtkBuilder file. --- diff --git a/TODO b/TODO index 992c026..07e15b5 100644 --- a/TODO +++ b/TODO @@ -54,7 +54,6 @@ * UI * Make sure we restart rygel when configuration changes. - * Fix tooltips. * Get interfaces directly from NM. * Show available APs for Wifi interface. diff --git a/data/rygel-preferences.ui b/data/rygel-preferences.ui index 7a2780d..3a2aaac 100644 --- a/data/rygel-preferences.ui +++ b/data/rygel-preferences.ui @@ -1,11 +1,14 @@ - + 65525 1 10 + + both + @@ -18,7 +21,7 @@ False True True - 5 + 6 Rygel Preferences 400 dialog @@ -28,219 +31,156 @@ False vertical 12 - - + + True False - end + 12 + 12 - - gtk-close + + _Share media through DLNA + False True True - True - True - True - True + False + True + Enable sharing of media, such as photos, videos and music, with DLNA + Enable sharing of media, such as photos, videos and music, with DLNA False - True + True + 0 + True - False - False - 0 + 0 + 0 + 2 + 1 - - - - - True - False - 12 - 12 - 12 - 12 - + True False - 12 + 12 - - _Share media through DLNA + True True - False - False - True - 0 - True - - - False - False - 0 - - - - - True - False - 0 - 12 + True + True + in - + True - False - 12 - - - True - True - True - True - in - - - True - True - True - True - uris-liststore - False - 0 - True - - - - - - - - True - True - 0 - - - - - True - False - 5 - start - - - gtk-add - True - True - True - False - True - True - - - False - True - 0 - - - - - gtk-remove - True - True - True - False - True - - - False - True - 1 - - - - - gtk-clear - True - True - True - False - True - True - - - False - True - 2 - - - - - False - True - 1 - + True + True + True + uris-liststore + False + 0 + True + + - True - True - 1 + 0 + 0 + 1 + 1 - + True False - 0 - 12 - + + False True False - 6 - - - True - False - 0 - _Network - True - - - False - True - 0 - - - - - True - False - - Any - - - - True - True - 1 - - + Add a directory to the list of shared directories + False + Add shared directory + list-add-symbolic + + False + True + + + + + False + True + False + Remove a directory from the list of shared directories + False + Remove shared directory + list-add-symbolic + + + False + True + - False - False - 2 + 0 + 1 + 1 + 1 + + 0 + 1 + 2 + 1 + + + + + True + False + 12 + 0 + _Network: + True + iface-entry + + + 0 + 2 + 1 + 1 + + + + + True + False + True + Select the network interface that DLNA media will be shared on, or share media on all interfaces + Select the network interface that DLNA media will be shared on, or share media on all interfaces + True + 0 + 1 + + Any + + + + 1 + 2 + 1 + 1 + @@ -249,12 +189,45 @@ 0 + + + True + False + end + + + gtk-close + False + True + True + True + True + True + True + False + True + + + False + False + 0 + + + + + False + True + end + 0 + + - button3 + button3 + False True @@ -282,6 +255,7 @@ gtk-cancel + False True True True @@ -298,6 +272,7 @@ gtk-open + False True True True @@ -313,6 +288,12 @@ + + False + True + end + 0 + @@ -324,10 +305,6 @@ button5 - - both - - diff --git a/src/ui/rygel-media-pref-section.vala b/src/ui/rygel-media-pref-section.vala index a3d1a9e..e05234b 100644 --- a/src/ui/rygel-media-pref-section.vala +++ b/src/ui/rygel-media-pref-section.vala @@ -31,13 +31,15 @@ public class Rygel.MediaPrefSection : PreferencesSection { const string URIS_DIALOG = URIS_KEY + "-dialog"; const string ADD_BUTTON = "add-button"; const string REMOVE_BUTTON = "remove-button"; - const string CLEAR_BUTTON = "clear-button"; + const string TREE_SELECTION = "treeview-selection"; private ArrayList widgets; // All widgets in this section private TreeView treeview; private ListStore liststore; + private TreeSelection tree_selection; private FileChooserDialog dialog; + private ToolButton remove_button; public MediaPrefSection (Builder builder, WritableUserConfig config) { @@ -49,6 +51,9 @@ public class Rygel.MediaPrefSection : PreferencesSection { assert (this.treeview != null); this.liststore = (ListStore) builder.get_object (URIS_LISTSTORE); assert (this.liststore != null); + this.tree_selection = builder.get_object (TREE_SELECTION) + as TreeSelection; + assert (this.tree_selection != null); this.dialog = (FileChooserDialog) builder.get_object (URIS_DIALOG); assert (this.dialog != null); @@ -74,17 +79,17 @@ public class Rygel.MediaPrefSection : PreferencesSection { this.dialog.set_current_folder (Environment.get_home_dir ()); this.dialog.show_hidden = false; - var button = (Button) builder.get_object (ADD_BUTTON); - button.clicked.connect (this.on_add_button_clicked); - this.widgets.add (button); + var add_button = builder.get_object (ADD_BUTTON) as ToolButton; + add_button.clicked.connect (this.on_add_button_clicked); + this.widgets.add (add_button); - button = (Button) builder.get_object (REMOVE_BUTTON); - button.clicked.connect (this.on_remove_button_clicked); - this.widgets.add (button); + remove_button = builder.get_object (REMOVE_BUTTON) as ToolButton; + remove_button.clicked.connect (this.on_remove_button_clicked); + this.widgets.add (remove_button); - button = (Button) builder.get_object (CLEAR_BUTTON); - button.clicked.connect (this.on_clear_button_clicked); - this.widgets.add (button); + // Update the sensitivity of the remove button + this.on_tree_selection_changed (); + this.tree_selection.changed.connect (this.on_tree_selection_changed); } public override void save () { @@ -108,9 +113,14 @@ public class Rygel.MediaPrefSection : PreferencesSection { foreach (var widget in this.widgets) { widget.sensitive = sensitivity; } + + // Force an update of the remove button. + if (sensitivity) { + this.on_tree_selection_changed (); + } } - private void on_add_button_clicked (Button button) { + private void on_add_button_clicked (ToolButton button) { if (this.dialog.run () == ResponseType.OK) { TreeIter iter; @@ -131,7 +141,7 @@ public class Rygel.MediaPrefSection : PreferencesSection { this.dialog.hide (); } - private void on_remove_button_clicked (Button button) { + private void on_remove_button_clicked (ToolButton button) { var selection = this.treeview.get_selection (); var rows = selection.get_selected_rows (null); @@ -152,10 +162,6 @@ public class Rygel.MediaPrefSection : PreferencesSection { } } - private void on_clear_button_clicked (Button button) { - this.liststore.clear (); - } - private string get_real_uri (string uri) { switch (uri) { case "@MUSIC@": @@ -182,4 +188,13 @@ public class Rygel.MediaPrefSection : PreferencesSection { return uri; } } + + private void on_tree_selection_changed () { + // Remove button cannot be sensitive if no row is selected + if (tree_selection.get_selected (null, null)) { + remove_button.set_sensitive (true); + } else { + remove_button.set_sensitive (false); + } + } } diff --git a/src/ui/rygel-network-pref-section.vala b/src/ui/rygel-network-pref-section.vala index 4997f14..0e6c8bc 100644 --- a/src/ui/rygel-network-pref-section.vala +++ b/src/ui/rygel-network-pref-section.vala @@ -25,7 +25,6 @@ using GUPnP; public class Rygel.NetworkPrefSection : PreferencesSection { const string IFACE_ENTRY = "iface-entry"; - const string ANY_NETWORK = "Any"; private ComboBoxText iface_entry; @@ -40,10 +39,9 @@ public class Rygel.NetworkPrefSection : PreferencesSection { this.context_manager = new ContextManager (null, 0); - // Apparently glade/GtkBuilder is unable to do this for us - this.iface_entry.set_entry_text_column (0); try { this.iface_entry.append_text (config.get_interface ()); + // TODO: Set the current interface to be active. this.iface_entry.set_active (0); } catch (GLib.Error err) { // No problem if we fail to read the config, the default values @@ -59,7 +57,8 @@ public class Rygel.NetworkPrefSection : PreferencesSection { public override void save () { var iface = this.iface_entry.get_active_text (); - if (iface == ANY_NETWORK) { + // The zeroth item is "Any" network. -1 represents no active item. + if (this.iface_entry.active <= 0 ) { iface = ""; }