1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
Index: b/gtk/gtkplacessidebar.c
===================================================================
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -64,6 +64,7 @@
#include "gtkgesturelongpress.h"
#include "gtkbox.h"
#include "gtkmodelbutton.h"
+#include "deprecated/gtkimagemenuitem.h"
/**
* SECTION:gtkplacessidebar
@@ -2341,32 +2342,32 @@ check_popover_sensitivity (GtkSidebarRow
gtk_widget_set_visible (data->stop_item, show_stop);
/* Adjust start/stop items to reflect the type of the drive */
- g_object_set (data->start_item, "text", _("_Start"), NULL);
- g_object_set (data->stop_item, "text", _("_Stop"), NULL);
+ g_object_set (data->start_item, "label", _("_Start"), "use_underline", TRUE, NULL);
+ g_object_set (data->stop_item, "label", _("_Stop"), "use_underline", TRUE, NULL);
if ((show_start || show_stop) && drive != NULL)
{
switch (g_drive_get_start_stop_type (drive))
{
case G_DRIVE_START_STOP_TYPE_SHUTDOWN:
/* start() for type G_DRIVE_START_STOP_TYPE_SHUTDOWN is normally not used */
- g_object_set (data->start_item, "text", _("_Power On"), NULL);
- g_object_set (data->stop_item, "text", _("_Safely Remove Drive"), NULL);
+ g_object_set (data->start_item, "label", _("_Power On"), "use_underline", TRUE, NULL);
+ g_object_set (data->stop_item, "label", _("_Safely Remove Drive"), "use_underline", TRUE, NULL);
break;
case G_DRIVE_START_STOP_TYPE_NETWORK:
- g_object_set (data->start_item, "text", _("_Connect Drive"), NULL);
- g_object_set (data->stop_item, "text", _("_Disconnect Drive"), NULL);
+ g_object_set (data->start_item, "label", _("_Connect Drive"), "use_underline", TRUE, NULL);
+ g_object_set (data->stop_item, "label", _("_Disconnect Drive"), "use_underline", TRUE, NULL);
break;
case G_DRIVE_START_STOP_TYPE_MULTIDISK:
- g_object_set (data->start_item, "text", _("_Start Multi-disk Device"), NULL);
- g_object_set (data->stop_item, "text", _("_Stop Multi-disk Device"), NULL);
+ g_object_set (data->start_item, "label", _("_Start Multi-disk Device"), "use_underline", TRUE, NULL);
+ g_object_set (data->stop_item, "label", _("_Stop Multi-disk Device"), "use_underline", TRUE, NULL);
break;
case G_DRIVE_START_STOP_TYPE_PASSWORD:
/* stop() for type G_DRIVE_START_STOP_TYPE_PASSWORD is normally not used */
- g_object_set (data->start_item, "text", _("_Unlock Device"), NULL);
- g_object_set (data->stop_item, "text", _("_Lock Device"), NULL);
+ g_object_set (data->start_item, "label", _("_Unlock Device"), "use_underline", TRUE, NULL);
+ g_object_set (data->stop_item, "label", _("_Lock Device"), "use_underline", TRUE, NULL);
break;
default:
@@ -3559,6 +3560,13 @@ append_separator (GtkWidget *box)
{
GtkWidget *separator;
+ if (GTK_IS_MENU (box))
+ {
+ separator = gtk_separator_menu_item_new();
+ gtk_widget_set_visible(GTK_WIDGET(separator), TRUE);
+ gtk_menu_shell_append(GTK_MENU_SHELL(box), separator);
+ return separator;
+ }
separator = g_object_new (GTK_TYPE_SEPARATOR,
"orientation", GTK_ORIENTATION_HORIZONTAL,
"visible", TRUE,
@@ -3577,6 +3585,14 @@ add_button (GtkWidget *box,
{
GtkWidget *item;
+ if (GTK_IS_MENU (box))
+ {
+ item = gtk_image_menu_item_new_with_mnemonic(label);
+ g_object_set(G_OBJECT(item), "action-name", action, NULL);
+ gtk_widget_set_visible(GTK_WIDGET(item), TRUE);
+ gtk_menu_shell_append(GTK_MENU_SHELL(box), item);
+ return item;
+ }
item = g_object_new (GTK_TYPE_MODEL_BUTTON,
"visible", TRUE,
"action-name", action,
@@ -3594,6 +3610,17 @@ add_open_button (GtkWidget *box
{
GtkWidget *item;
+ if (GTK_IS_MENU (box))
+ {
+ item = gtk_image_menu_item_new_with_mnemonic (label);
+ g_object_set(G_OBJECT (item),
+ "action-name", flags == GTK_PLACES_OPEN_NORMAL ? "row.open" : "row.open-other",
+ "action-target", g_variant_new_int32 (flags),
+ NULL);
+ gtk_widget_set_visible (GTK_WIDGET (item), TRUE);
+ gtk_menu_shell_append (GTK_MENU_SHELL (box), item);
+ return item;
+ }
item = g_object_new (GTK_TYPE_MODEL_BUTTON,
"visible", TRUE,
"action-name", flags == GTK_PLACES_OPEN_NORMAL ? "row.open" : "row.open-other",
@@ -3699,6 +3726,13 @@ create_row_popover (GtkPlacesSidebar *si
g_object_set (box, "margin", 10, NULL);
gtk_widget_show (box);
gtk_container_add (GTK_CONTAINER (sidebar->popover), box);
+ if (!sidebar->populate_all)
+ {
+ sidebar->popover = gtk_menu_new ();
+ g_signal_connect (sidebar->popover, "destroy", G_CALLBACK (on_row_popover_destroy), sidebar);
+ gtk_menu_attach_to_widget (GTK_MENU (sidebar->popover), GTK_WIDGET (sidebar), NULL);
+ box = sidebar->popover;
+ }
add_open_button (box, _("_Open"), GTK_PLACES_OPEN_NORMAL);
@@ -3722,6 +3756,15 @@ create_row_popover (GtkPlacesSidebar *si
data.rescan_item = add_button (box, _("_Detect Media"), "row.rescan");
data.start_item = add_button (box, _("_Start"), "row.start");
data.stop_item = add_button (box, _("_Stop"), "row.stop");
+ if (!sidebar->populate_all)
+ {
+ g_object_set (
+ g_list_first (gtk_container_get_children (GTK_CONTAINER (box)))->data,
+ "image", gtk_image_new_from_icon_name ("gtk-open", GTK_ICON_SIZE_MENU), NULL
+ );
+ g_object_set (data.remove_item, "image", gtk_image_new_from_icon_name("gtk-remove",GTK_ICON_SIZE_MENU), NULL);
+ g_object_set (data.add_shortcut_item, "image", gtk_image_new_from_icon_name("gtk-add", GTK_ICON_SIZE_MENU), NULL);
+ }
/* Update everything! */
check_popover_sensitivity (row, &data);
@@ -3765,6 +3808,13 @@ show_row_popover (GtkSidebarRow *row)
gtk_widget_destroy (sidebar->popover);
create_row_popover (sidebar, row);
+ if (GTK_IS_MENU (sidebar->popover))
+ {
+ sidebar->context_row = row;
+ gtk_menu_popup_at_pointer (GTK_MENU (sidebar->popover), NULL);
+ g_object_unref (sidebar);
+ return;
+ }
gtk_popover_set_relative_to (GTK_POPOVER (sidebar->popover), GTK_WIDGET (row));
|