diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c index 88a72335..f5e27148 100644 --- a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c +++ b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <string.h> | 29 | #include <string.h> |
30 | 30 | ||
31 | 31 | ||
32 | |||
33 | /** | 32 | /** |
34 | * Helper function of GNUNET_GTK_FS_metadata_copy_selection_activated | 33 | * Helper function of GNUNET_GTK_FS_metadata_copy_selection_activated |
35 | * which copies the (selected) entries from the tree view to the | 34 | * which copies the (selected) entries from the tree view to the |
@@ -41,14 +40,17 @@ | |||
41 | * @param user_data 'GList**' where we should store the types and values found | 40 | * @param user_data 'GList**' where we should store the types and values found |
42 | */ | 41 | */ |
43 | static void | 42 | static void |
44 | copy_metadata_to_clipboard (GtkTreeModel * model, GtkTreePath * path, | 43 | copy_metadata_to_clipboard (GtkTreeModel *model, |
45 | GtkTreeIter * iter, gpointer user_data) | 44 | GtkTreePath *path, |
45 | GtkTreeIter *iter, | ||
46 | gpointer user_data) | ||
46 | { | 47 | { |
47 | GList **l = user_data; | 48 | GList **l = user_data; |
48 | gchar *type; | 49 | gchar *type; |
49 | gchar *value; | 50 | gchar *value; |
50 | 51 | ||
51 | gtk_tree_model_get (model, iter, | 52 | gtk_tree_model_get (model, |
53 | iter, | ||
52 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING, | 54 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_TYPE_STRING, |
53 | &type, | 55 | &type, |
54 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE, | 56 | GNUNET_GTK_FS_MAIN_WINDOW_META_DATA_MC_META_VALUE, |
@@ -66,8 +68,8 @@ copy_metadata_to_clipboard (GtkTreeModel * model, GtkTreePath * path, | |||
66 | * @param user_data the GtkBuilder of the main window | 68 | * @param user_data the GtkBuilder of the main window |
67 | */ | 69 | */ |
68 | void | 70 | void |
69 | GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, | 71 | GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem *menuitem, |
70 | gpointer user_data) | 72 | gpointer user_data) |
71 | { | 73 | { |
72 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 74 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
73 | GtkTreeView *tree; | 75 | GtkTreeView *tree; |
@@ -83,7 +85,8 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, | |||
83 | tree = main_ctx->md_treeview; | 85 | tree = main_ctx->md_treeview; |
84 | pairs = NULL; | 86 | pairs = NULL; |
85 | gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree), | 87 | gtk_tree_selection_selected_foreach (gtk_tree_view_get_selection (tree), |
86 | ©_metadata_to_clipboard, &pairs); | 88 | ©_metadata_to_clipboard, |
89 | &pairs); | ||
87 | if (NULL == pairs) | 90 | if (NULL == pairs) |
88 | return; /* nothing selected */ | 91 | return; /* nothing selected */ |
89 | total_len = 0; | 92 | total_len = 0; |
@@ -93,12 +96,12 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, | |||
93 | type = pos; | 96 | type = pos; |
94 | value = pos->next; | 97 | value = pos->next; |
95 | GNUNET_assert (NULL != value); | 98 | GNUNET_assert (NULL != value); |
96 | total_len += | 99 | total_len += strlen ((gchar *) type->data) + |
97 | strlen ((gchar *) type->data) + strlen ((gchar *) value->data) + | 100 | strlen ((gchar *) value->data) + 2 /* ": " */ + |
98 | 2 /* ": " */ + ((NULL != value->next) ? 1 : 0) /* "\n" */ ; | 101 | ((NULL != value->next) ? 1 : 0) /* "\n" */; |
99 | } | 102 | } |
100 | GNUNET_assert (total_len > 0); | 103 | GNUNET_assert (total_len > 0); |
101 | total_len++; /* "\0" */ | 104 | total_len++; /* "\0" */ |
102 | s = g_new0 (gchar, total_len); | 105 | s = g_new0 (gchar, total_len); |
103 | if (NULL == s) | 106 | if (NULL == s) |
104 | { | 107 | { |
@@ -135,24 +138,23 @@ GNUNET_GTK_FS_metadata_copy_selection_activated (GtkMenuItem * menuitem, | |||
135 | * @param user_data the gtk builder of the main window | 138 | * @param user_data the gtk builder of the main window |
136 | */ | 139 | */ |
137 | gboolean | 140 | gboolean |
138 | GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget * widget, | 141 | GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb ( |
139 | GdkEvent * event, | 142 | GtkWidget *widget, |
140 | gpointer user_data) | 143 | GdkEvent *event, |
144 | gpointer user_data) | ||
141 | { | 145 | { |
142 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 146 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
143 | GdkEventButton *event_button = (GdkEventButton *) event; | 147 | GdkEventButton *event_button = (GdkEventButton *) event; |
144 | GtkMenu *menu; | 148 | GtkMenu *menu; |
145 | 149 | ||
146 | /* Ignore double-clicks and triple-clicks */ | 150 | /* Ignore double-clicks and triple-clicks */ |
147 | if ( (event_button->button != 3) || | 151 | if ((event_button->button != 3) || (event_button->type != GDK_BUTTON_PRESS)) |
148 | (event_button->type != GDK_BUTTON_PRESS) ) | ||
149 | return FALSE; | 152 | return FALSE; |
150 | menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, | 153 | menu = GTK_MENU ( |
151 | "metadata_popup_menu")); | 154 | gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu")); |
152 | if (NULL == menu) | 155 | if (NULL == menu) |
153 | return FALSE; | 156 | return FALSE; |
154 | gtk_menu_popup_at_pointer (menu, | 157 | gtk_menu_popup_at_pointer (menu, event); |
155 | event); | ||
156 | return FALSE; | 158 | return FALSE; |
157 | } | 159 | } |
158 | 160 | ||
@@ -166,13 +168,14 @@ GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget * widg | |||
166 | * @return TRUE we did it | 168 | * @return TRUE we did it |
167 | */ | 169 | */ |
168 | gboolean | 170 | gboolean |
169 | GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget * widget, | 171 | GNUNET_GTK_main_window_metadata_treeview_popup_menu_cb (GtkWidget *widget, |
170 | gpointer user_data) | 172 | gpointer user_data) |
171 | { | 173 | { |
172 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; | 174 | struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; |
173 | GtkMenu *menu; | 175 | GtkMenu *menu; |
174 | 176 | ||
175 | menu = GTK_MENU (gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu")); | 177 | menu = GTK_MENU ( |
178 | gtk_builder_get_object (main_ctx->builder, "metadata_popup_menu")); | ||
176 | if (NULL == menu) | 179 | if (NULL == menu) |
177 | return FALSE; | 180 | return FALSE; |
178 | gtk_menu_popup_at_widget (menu, | 181 | gtk_menu_popup_at_widget (menu, |