From e5239736235d6beace1d18c18decaaf6611bb1dd Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 25 Jan 2015 03:50:10 +0100 Subject: adding panel orientation binding --- libmdock/mdock-item-menu.c | 17 ++++++++--------- mate-applet/mdock-mate-panel-applet.c | 24 ++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/libmdock/mdock-item-menu.c b/libmdock/mdock-item-menu.c index 6121cdb..484277b 100644 --- a/libmdock/mdock-item-menu.c +++ b/libmdock/mdock-item-menu.c @@ -77,22 +77,21 @@ static void recents_icon_ready(GObject *source, GAsyncResult *res, gpointer user GFile *file = G_FILE(source); GError *error = NULL; GFileInfo *info = g_file_query_info_finish(file, res, &error); + if (info) { + GIcon *icon = g_file_info_get_icon(info); + if (icon) { + GtkImage *image = GTK_IMAGE(gtk_image_menu_item_get_image(menu_item)); + gtk_image_set_from_gicon(image, icon, GTK_ICON_SIZE_MENU); + } + g_object_unref(info); } else { gchar *uri = g_file_get_uri(file); - g_message("Could not get icon for file '%s': %s", uri, error->message); + g_debug("Could not get icon for file '%s': %s", uri, error->message); g_free(uri); g_error_free(error); - return; } - GIcon *icon = g_file_info_get_icon(info); - if (icon) { - GtkImage *image = GTK_IMAGE(gtk_image_menu_item_get_image(menu_item)); - gtk_image_set_from_gicon(image, icon, GTK_ICON_SIZE_MENU); - } - - g_object_unref(info); } static void recents_result_ready(GObject *source, GAsyncResult *res, gpointer user_data) diff --git a/mate-applet/mdock-mate-panel-applet.c b/mate-applet/mdock-mate-panel-applet.c index 73b7920..1394620 100644 --- a/mate-applet/mdock-mate-panel-applet.c +++ b/mate-applet/mdock-mate-panel-applet.c @@ -51,6 +51,21 @@ static const GtkActionEntry menu_verbs[] = { G_CALLBACK (display_about_dialog) } }; +static gboolean transform_applet_orient_to_orientation(GBinding *binding, const GValue *from_value, GValue *to_value, gpointer user_data) +{ + MatePanelAppletOrient orient = g_value_get_enum(from_value); + switch (orient) { + case MATE_PANEL_APPLET_ORIENT_DOWN: + case MATE_PANEL_APPLET_ORIENT_UP: + g_value_set_enum(to_value, GTK_ORIENTATION_VERTICAL); + break; + case MATE_PANEL_APPLET_ORIENT_LEFT: + case MATE_PANEL_APPLET_ORIENT_RIGHT: + g_value_set_enum(to_value, GTK_ORIENTATION_HORIZONTAL); + break; + } +} + static void mdock_mate_panel_applet_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { MDockMatePanelApplet *self = MDOCK_MATE_PANEL_APPLET(widget); @@ -80,6 +95,11 @@ static void mdock_mate_panel_applet_init(MDockMatePanelApplet *self) self->dock = MDOCK_WIDGET(mdock_widget_new()); gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->dock)); + g_object_bind_property_full(self, "orient", self->dock, "orientation", + G_BINDING_DEFAULT, + transform_applet_orient_to_orientation, + NULL, NULL, NULL); + GtkActionGroup *action_group = gtk_action_group_new("MDock Mate Panel Applet Actions"); gtk_action_group_add_actions(action_group, menu_verbs, G_N_ELEMENTS(menu_verbs), self); @@ -87,8 +107,8 @@ static void mdock_mate_panel_applet_init(MDockMatePanelApplet *self) mate_panel_applet_set_flags(MATE_PANEL_APPLET(self), MATE_PANEL_APPLET_EXPAND_MINOR); mate_panel_applet_setup_menu(MATE_PANEL_APPLET(self), - "" - "", + "" + "", action_group); g_object_unref(action_group); -- cgit v1.2.3