aboutsummarylogtreecommitdiffstats
path: root/popovers__places-sidebar.patch
blob: 7a956e1f46fa2fe230ec4d436f64284883451389 (plain)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
diff -U 5 -r -Z -B ./org/gtk/gtkplacessidebar.c ./mod/gtk/gtkplacessidebar.c
--- ./org/gtk/gtkplacessidebar.c	2017-07-19 04:55:39.000000000 +0200
+++ ./mod/gtk/gtkplacessidebar.c	2017-07-30 18:32:50.010014344 +0200
@@ -57,10 +57,11 @@
 #include "gtkseparator.h"
 #include "gtkentry.h"
 #include "gtkgesturelongpress.h"
 #include "gtkbox.h"
 #include "gtkmodelbutton.h"
+#include "deprecated/gtkimagemenuitem.h"
 
 /**
  * SECTION:gtkplacessidebar
  * @Short_description: Sidebar that displays frequently-used places in the file system
  * @Title: GtkPlacesSidebar
@@ -2142,36 +2143,36 @@
   gtk_widget_set_visible (data->rescan_item, show_rescan);
   gtk_widget_set_visible (data->start_item, show_start);
   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:
         case G_DRIVE_START_STOP_TYPE_UNKNOWN:
           /* uses defaults set above */
@@ -3335,10 +3336,17 @@
 static GtkWidget *
 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,
                             "margin-top", 6,
                             "margin-bottom", 6,
@@ -3353,10 +3361,18 @@
             const gchar *label,
             const gchar *action)
 {
   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,
                        "text", label,
                        NULL);
@@ -3370,10 +3386,21 @@
                  const gchar        *label,
                  GtkPlacesOpenFlags  flags)
 {
   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",
                        "action-target", g_variant_new_int32 (flags),
                        "text", label,
@@ -3406,10 +3433,17 @@
   setup_popover_shadowing (sidebar->popover);
   box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
   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);
 
   if (sidebar->open_flags & GTK_PLACES_OPEN_NEW_TAB)
     add_open_button (box, _("Open in New _Tab"), GTK_PLACES_OPEN_NEW_TAB);
@@ -3429,10 +3463,19 @@
   data.unmount_item = add_button (box, _("_Unmount"), "row.unmount");
   data.eject_item = add_button (box, _("_Eject"), "row.eject");
   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);
 
   if (sidebar->populate_all)
@@ -3472,10 +3515,17 @@
 
   if (sidebar->popover)
     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));
 
   sidebar->context_row = row;
   gtk_popover_popup (GTK_POPOVER (sidebar->popover));