Commit 29408d96 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels
Browse files

desktop: add right click menus

parent a9f95dbe
Pipeline #130318 failed with stage
in 2 minutes and 36 seconds
......@@ -18,6 +18,8 @@
#include "config.h"
#include "gf-icon-view.h"
#include <glib/gi18n.h>
#include "gf-desktop-enum-types.h"
#include "gf-icon.h"
#include "gf-monitor-view.h"
......@@ -371,6 +373,69 @@ desktop_changed_cb (GFileMonitor *monitor,
}
}
static void
open_terminal_cb (GtkMenuItem *item,
GfIconView *self)
{
GError *error;
error = NULL;
if (!gf_launch_desktop_file ("org.gnome.Terminal.desktop", &error))
{
g_warning ("%s", error->message);
g_error_free (error);
}
}
static void
change_background_cb (GtkMenuItem *item,
GfIconView *self)
{
GError *error;
error = NULL;
if (!gf_launch_desktop_file ("gnome-background-panel.desktop", &error))
{
g_warning ("%s", error->message);
g_error_free (error);
}
}
static GtkWidget *
create_popup_menu (GfIconView *self)
{
GtkWidget *popup_menu;
GtkStyleContext *context;
GtkWidget *item;
popup_menu = gtk_menu_new ();
context = gtk_widget_get_style_context (popup_menu);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_CONTEXT_MENU);
item = gtk_menu_item_new_with_label (_("Open Terminal"));
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
gtk_widget_show (item);
g_signal_connect (item, "activate",
G_CALLBACK (open_terminal_cb),
self);
item = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
gtk_widget_show (item);
item = gtk_menu_item_new_with_label (_("Change Background"));
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
gtk_widget_show (item);
g_signal_connect (item, "activate",
G_CALLBACK (change_background_cb),
self);
return popup_menu;
}
static void
multi_press_pressed_cb (GtkGestureMultiPress *gesture,
gint n_press,
......@@ -389,13 +454,19 @@ multi_press_pressed_cb (GtkGestureMultiPress *gesture,
if (event == NULL)
return;
unselect_icons (self);
if (button == GDK_BUTTON_PRIMARY)
{
unselect_icons (self);
}
else if (button == GDK_BUTTON_SECONDARY)
{
GtkWidget *popup_menu;
popup_menu = create_popup_menu (self);
g_object_ref_sink (popup_menu);
gtk_menu_popup_at_pointer (GTK_MENU (popup_menu), event);
g_object_unref (popup_menu);
}
}
......
......@@ -18,6 +18,8 @@
#include "config.h"
#include "gf-icon.h"
#include <glib/gi18n.h>
#include "gf-desktop-enums.h"
#include "gf-desktop-enum-types.h"
#include "gf-utils.h"
......@@ -98,6 +100,36 @@ icon_open (GfIcon *self)
g_free (uri);
}
static void
open_cb (GtkMenuItem *item,
GfIcon *self)
{
icon_open (self);
}
static GtkWidget *
create_popup_menu (GfIcon *self)
{
GtkWidget *popup_menu;
GtkStyleContext *context;
GtkWidget *item;
popup_menu = gtk_menu_new ();
context = gtk_widget_get_style_context (popup_menu);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_CONTEXT_MENU);
item = gtk_menu_item_new_with_label (_("Open"));
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);
gtk_widget_show (item);
g_signal_connect (item, "activate",
G_CALLBACK (open_cb),
self);
return popup_menu;
}
static void
multi_press_pressed_cb (GtkGestureMultiPress *gesture,
gint n_press,
......@@ -155,6 +187,20 @@ multi_press_pressed_cb (GtkGestureMultiPress *gesture,
}
else if (button == GDK_BUTTON_SECONDARY)
{
GtkWidget *popup_menu;
if (!self->selected && !control_pressed)
flags |= GF_ICON_SELECTED_CLEAR;
flags |= GF_ICON_SELECTED_ADD;
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
gf_icon_set_selected (self, TRUE, flags);
popup_menu = create_popup_menu (self);
g_object_ref_sink (popup_menu);
gtk_menu_popup_at_pointer (GTK_MENU (popup_menu), event);
g_object_unref (popup_menu);
}
else if (button == GDK_BUTTON_MIDDLE)
{
......
......@@ -21,6 +21,8 @@ gnome-flashback/libaudio-device-selection/gf-audio-device-selection-dialog.c
gnome-flashback/libautomount-manager/gsd-automount-manager.c
gnome-flashback/libautomount-manager/gsd-autorun.c
gnome-flashback/libbluetooth-applet/gf-bluetooth-applet.c
gnome-flashback/libdesktop/gf-icon.c
gnome-flashback/libdesktop/gf-icon-view.c
gnome-flashback/libend-session-dialog/gf-inhibit-dialog.c
gnome-flashback/libend-session-dialog/gf-inhibit-dialog.ui
gnome-flashback/libinput-sources/gf-input-sources.c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment