[gnome-software/ADD_SHORTCUT: 4/5] Add support for removing a shortcut from the app details page
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/ADD_SHORTCUT: 4/5] Add support for removing a shortcut from the app details page
- Date: Wed, 20 Apr 2016 13:52:00 +0000 (UTC)
commit e90241cb5e730581981d9f20f4dace20fcde3138
Author: Joaquim Rocha <jrocha endlessm com>
Date: Wed Apr 13 16:27:23 2016 +0200
Add support for removing a shortcut from the app details page
src/gs-shell-details.c | 32 ++++++++++++++++++++++++++++++--
src/gs-shell-details.ui | 1 -
2 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 8bcad03..a2f92eb 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -159,16 +159,44 @@ static void
gs_shell_details_update_shortcut_button (GsShellDetails *self)
{
gboolean enable_shortcut_button;
+ gboolean has_add_shortcut_function;
+ gboolean has_remove_shortcut_function;
gboolean app_has_shortcut;
+ char *add_shortcut_label;
+ char *remove_shortcut_label;
+
+ has_add_shortcut_function = gs_plugin_loader_get_plugin_supported (self->plugin_loader,
"gs_plugin_add_shortcut");
+ has_remove_shortcut_function = gs_plugin_loader_get_plugin_supported (self->plugin_loader,
"gs_plugin_remove_shortcut");
+ enable_shortcut_button = has_add_shortcut_function || has_remove_shortcut_function;
- enable_shortcut_button = gs_plugin_loader_get_plugin_supported (self->plugin_loader,
"gs_plugin_add_shortcut");
gtk_widget_set_visible (self->button_details_shortcut, enable_shortcut_button);
if (!enable_shortcut_button)
return;
+ gtk_widget_set_sensitive (self->button_details_shortcut, TRUE);
+
+ /* TRANSLATORS: button text when a shortcut to the app can be added */
+ add_shortcut_label = _("_Add Shortcut");
+ /* TRANSLATORS: button text when a shortcut to the app can be removed */
+ remove_shortcut_label = _("Re_move Shortcut");
+
+ gtk_button_set_label (self->button_details_shortcut, add_shortcut_label);
+
+ /* If there's only one of the functions (add or remove), then we set always the label of the existing
+ * one and set the widget insensitive if the function's does not make sense to be used (adding an
already
+ * added icon) */
app_has_shortcut = gs_app_has_quirk (self->app, AS_APP_QUIRK_HAS_SHORTCUT);
- gtk_widget_set_sensitive (self->button_details_shortcut, !app_has_shortcut);
+ if (app_has_shortcut) {
+ if (has_remove_shortcut_function) {
+ gtk_button_set_label (self->button_details_shortcut, remove_shortcut_label);
+ } else {
+ gtk_widget_set_sensitive (self->button_details_shortcut, FALSE);
+ }
+ } else if (!has_add_shortcut_function) {
+ gtk_button_set_label (self->button_details_shortcut, remove_shortcut_label);
+ gtk_widget_set_sensitive (self->button_details_shortcut, FALSE);
+ }
}
/**
diff --git a/src/gs-shell-details.ui b/src/gs-shell-details.ui
index aefffba..99d5900 100644
--- a/src/gs-shell-details.ui
+++ b/src/gs-shell-details.ui
@@ -219,7 +219,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
- <property name="label" translatable="yes" comments="Translators: A label
for a button to add a shortcut to the selected application.">Add _Shorcut</property>
</object>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]