summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-01-23 02:25:10 +0100
committerJavier <dev.git@javispedro.com>2015-01-23 02:25:10 +0100
commitf5a8f45bdc5ce167967215acc240b949716df103 (patch)
tree4a1ee43544b2282c3f724fda684073075f601204
parentb711fa350a4aec9d9584e6b3623290201f7273a2 (diff)
downloadmdock-f5a8f45bdc5ce167967215acc240b949716df103.tar.gz
mdock-f5a8f45bdc5ce167967215acc240b949716df103.zip
pin/unpin menu item
-rw-r--r--libmdock/mdock-item.c19
-rw-r--r--libmdock/mdock-item.h1
2 files changed, 17 insertions, 3 deletions
diff --git a/libmdock/mdock-item.c b/libmdock/mdock-item.c
index 9f87a6a..2399e19 100644
--- a/libmdock/mdock-item.c
+++ b/libmdock/mdock-item.c
@@ -17,6 +17,7 @@
* along with MDock. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <glib/gi18n.h>
#include "mdock-enums.h"
#include "mdock-item.h"
#include "mdock-item-menu.h"
@@ -108,8 +109,12 @@ static void mdock_item_update_menu(MDockItem *self)
{
gtk_widget_set_visible(GTK_WIDGET(self->priv->menu_close_all), self->priv->windows != NULL);
gtk_widget_set_visible(GTK_WIDGET(self->priv->menu_pin), self->priv->appinfo != NULL);
+ if (self->priv->appinfo) {
+ gtk_menu_item_set_label(GTK_MENU_ITEM(self->priv->menu_pin),
+ self->priv->pinned ? _("Un_pin") : _("_Pin"));
+ }
gtk_widget_set_visible(GTK_WIDGET(self->priv->menu_launch), self->priv->appinfo != NULL);
- if (!gtk_image_menu_item_get_image(self->priv->menu_launch) && self->priv->icon) {
+ if (!gtk_image_menu_item_get_image(self->priv->menu_launch) && self->priv->appinfo && self->priv->icon) {
gint width, height;
if (gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height)) {
GdkPixbuf *pixbuf = mdock_item_load_icon(self, MIN(width, height));
@@ -241,6 +246,7 @@ static void mdock_item_set_property(GObject *object,
switch (property_id) {
case PROP_PINNED:
self->priv->pinned = g_value_get_boolean(value);
+ mdock_item_update_menu(self);
break;
case PROP_DESKTOP_APP_INFO:
self->priv->appinfo = g_value_dup_object(value);
@@ -320,11 +326,13 @@ static void mdock_item_init(MDockItem *self)
g_signal_connect_swapped(self->priv->menu_close_all, "activate",
G_CALLBACK(mdock_item_close_all_windows), self);
- self->priv->menu_pin = g_object_ref_sink(gtk_image_menu_item_new_with_mnemonic("_Pin"));
+ self->priv->menu_pin = g_object_ref_sink(gtk_image_menu_item_new_with_mnemonic(_("_Pin")));
gtk_menu_shell_append(GTK_MENU_SHELL(self->priv->right_menu),
GTK_WIDGET(self->priv->menu_pin));
+ g_signal_connect_swapped(self->priv->menu_pin, "activate",
+ G_CALLBACK(mdock_item_toggle_pinned), self);
- self->priv->menu_launch = g_object_ref_sink(gtk_image_menu_item_new_with_mnemonic("_New instance"));
+ self->priv->menu_launch = g_object_ref_sink(gtk_image_menu_item_new_with_mnemonic(_("_New instance")));
gtk_menu_shell_append(GTK_MENU_SHELL(self->priv->right_menu),
GTK_WIDGET(self->priv->menu_launch));
g_signal_connect_swapped(self->priv->menu_launch, "activate",
@@ -386,6 +394,11 @@ void mdock_item_set_pinned(MDockItem *self, gboolean pinned)
g_object_set(self, "pinned", pinned, NULL);
}
+void mdock_item_toggle_pinned(MDockItem *self)
+{
+ mdock_item_set_pinned(self, !self->priv->pinned);
+}
+
GDesktopAppInfo *mdock_item_get_desktop_app_info(MDockItem *self)
{
return g_object_ref(self->priv->appinfo);
diff --git a/libmdock/mdock-item.h b/libmdock/mdock-item.h
index f9fe657..328187e 100644
--- a/libmdock/mdock-item.h
+++ b/libmdock/mdock-item.h
@@ -54,6 +54,7 @@ MDockItem *mdock_item_new();
gboolean mdock_item_get_pinned(MDockItem *self);
void mdock_item_set_pinned(MDockItem *self, gboolean pinned);
+void mdock_item_toggle_pinned(MDockItem *self);
GDesktopAppInfo *mdock_item_get_desktop_app_info(MDockItem *self);
void mdock_item_set_desktop_app_info(MDockItem *self, GDesktopAppInfo *app_info);