diff options
author | Bastien Nocera <hadess@hadess.net> | 2014-01-23 20:30:16 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2014-01-23 21:05:13 +0100 |
commit | bb57ba0a2f93f77362d06d9fef9b83cfcae92f5b (patch) | |
tree | 578d9cfce676f4d9a91f5e3e7b5850650da00bc0 /src | |
parent | 30edc54a43f460b3d3393a55e073cf6a1cfff112 (diff) | |
download | totem-bb57ba0a2f93f77362d06d9fef9b83cfcae92f5b.tar.gz |
grilo: Add "delete-button-sensitive" prop to selection toolbar
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/grilo/totem-selection-toolbar.c | 49 | ||||
-rw-r--r-- | src/plugins/grilo/totem-selection-toolbar.h | 6 |
2 files changed, 52 insertions, 3 deletions
diff --git a/src/plugins/grilo/totem-selection-toolbar.c b/src/plugins/grilo/totem-selection-toolbar.c index 467b67752..e96c1f438 100644 --- a/src/plugins/grilo/totem-selection-toolbar.c +++ b/src/plugins/grilo/totem-selection-toolbar.c @@ -49,8 +49,9 @@ struct _TotemSelectionToolbarPrivate { GtkWidget *shuffle; GtkWidget *delete; - /* Visibility */ + /* Delete button */ gboolean show_delete_button; + gboolean delete_sensitive; /* Selection mode */ guint n_selected; @@ -62,7 +63,8 @@ G_DEFINE_TYPE_WITH_CODE (TotemSelectionToolbar, totem_selection_toolbar, GTK_TYP enum { PROP_0, PROP_SHOW_DELETE_BUTTON, - PROP_N_SELECTED + PROP_N_SELECTED, + PROP_DELETE_BUTTON_SENSITIVE }; static void @@ -99,7 +101,6 @@ update_toolbar_state (TotemSelectionToolbar *bar) gtk_widget_set_sensitive (priv->add_to_fav, sensitive); gtk_widget_set_sensitive (priv->play, sensitive); gtk_widget_set_sensitive (priv->shuffle, sensitive); - gtk_widget_set_sensitive (priv->delete, sensitive); } static void @@ -148,6 +149,10 @@ totem_selection_toolbar_set_property (GObject *object, totem_selection_toolbar_set_show_delete_button (bar, g_value_get_boolean (value)); break; + case PROP_DELETE_BUTTON_SENSITIVE: + totem_selection_toolbar_set_delete_button_sensitive (bar, g_value_get_boolean (value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -173,6 +178,10 @@ totem_selection_toolbar_get_property (GObject *object, g_value_set_boolean (value, priv->show_delete_button); break; + case PROP_DELETE_BUTTON_SENSITIVE: + g_value_set_boolean (value, priv->delete_sensitive); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -206,6 +215,14 @@ totem_selection_toolbar_class_init (TotemSelectionToolbarClass *klass) TRUE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, + PROP_DELETE_BUTTON_SENSITIVE, + g_param_spec_boolean ("delete-button-sensitive", + "Delete Button Sensitive", + "Whether the delete button is sensitive", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_signal_new ("add-to-favourites-clicked", G_OBJECT_CLASS_TYPE (klass), 0, @@ -254,6 +271,9 @@ totem_selection_toolbar_init (TotemSelectionToolbar *bar) gtk_widget_hide (bar->priv->add_to_fav); + /* So that the default FALSE actually gets applied */ + bar->priv->delete_sensitive = TRUE; + g_signal_connect (bar->priv->add_to_fav, "clicked", G_CALLBACK (add_to_fav_clicked_cb), bar); g_signal_connect (bar->priv->delete, "clicked", @@ -324,3 +344,26 @@ totem_selection_toolbar_get_show_delete_button (TotemSelectionToolbar *bar) return bar->priv->show_delete_button; } + +void +totem_selection_toolbar_set_delete_button_sensitive (TotemSelectionToolbar *bar, + gboolean sensitive) +{ + g_return_if_fail (TOTEM_IS_SELECTION_TOOLBAR (bar)); + + if (bar->priv->delete_sensitive == sensitive) + return; + + bar->priv->delete_sensitive = sensitive; + gtk_widget_set_sensitive (bar->priv->delete, sensitive); + + g_object_notify (G_OBJECT (bar), "delete-button-sensitive"); +} + +gboolean +totem_selection_toolbar_get_delete_button_sensitive (TotemSelectionToolbar *bar) +{ + g_return_val_if_fail (TOTEM_IS_SELECTION_TOOLBAR (bar), 0); + + return bar->priv->delete_sensitive; +} diff --git a/src/plugins/grilo/totem-selection-toolbar.h b/src/plugins/grilo/totem-selection-toolbar.h index b638ff179..d78b88eef 100644 --- a/src/plugins/grilo/totem-selection-toolbar.h +++ b/src/plugins/grilo/totem-selection-toolbar.h @@ -58,13 +58,19 @@ struct _TotemSelectionToolbarClass GType totem_selection_toolbar_get_type (void) G_GNUC_CONST; GtkWidget* totem_selection_toolbar_new (void); + void totem_selection_toolbar_set_n_selected (TotemSelectionToolbar *bar, guint n_selected); guint totem_selection_toolbar_get_n_selected (TotemSelectionToolbar *bar); + void totem_selection_toolbar_set_show_delete_button (TotemSelectionToolbar *bar, gboolean show_delete_button); gboolean totem_selection_toolbar_get_show_delete_button (TotemSelectionToolbar *bar); +void totem_selection_toolbar_set_delete_button_sensitive (TotemSelectionToolbar *bar, + gboolean sensitive); +gboolean totem_selection_toolbar_get_delete_button_sensitive (TotemSelectionToolbar *bar); + G_END_DECLS #endif /* __TOTEM_SELECTION_TOOLBAR_H__ */ |