[balsa/popover: 31/63] Use BALSA_USE_POPOVER=0 environment var
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/popover: 31/63] Use BALSA_USE_POPOVER=0 environment var
- Date: Sat, 4 Jul 2020 15:10:56 +0000 (UTC)
commit c5170b1d3c76b429e53aa2a82a76a0d0a9139901
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Jun 13 11:42:06 2020 -0400
Use BALSA_USE_POPOVER=0 environment var
Use a BALSA_USE_POPOVER=0 environment variable to switch from GtkPopover back to GtkMenu.
* libbalsa/libbalsa.c (libbalsa_use_popover):
* libbalsa/libbalsa.h:
* src/balsa-index.c (move_to_change_state), (bndx_popup_menu_create), (bndx_do_popup):
* src/balsa-mblist.c (bmbl_do_popup):
* src/balsa-message.c (balsa_headers_attachments_popup),
(balsa_message_init), (tree_mult_selection_popup), (tree_button_press_cb),
(display_content), (open_with_change_state), (copy_part_change_state),
(part_create_menu):
ChangeLog | 14 ++++++++
libbalsa/libbalsa.c | 18 ++++++++++
libbalsa/libbalsa.h | 2 ++
src/balsa-index.c | 65 ++++++++++++++++++++++--------------
src/balsa-mblist.c | 37 +++++++++++++--------
src/balsa-message.c | 96 ++++++++++++++++++++++++++++++++++++++---------------
6 files changed, 168 insertions(+), 64 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b928c0fc7..a82e97033 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -52,6 +52,20 @@
* libbalsa/libbalsa-gpgme-cb.c (row_activated_cb),
(lb_gpgme_select_key):
+ Use a BALSA_USE_POPOVER=0 environment variable to switch from
+ GtkPopover back to GtkMenu.
+
+ * libbalsa/libbalsa.c (libbalsa_use_popover):
+ * libbalsa/libbalsa.h:
+ * src/balsa-index.c (move_to_change_state),
+ (bndx_popup_menu_create), (bndx_do_popup):
+ * src/balsa-mblist.c (bmbl_do_popup):
+ * src/balsa-message.c (balsa_headers_attachments_popup),
+ (balsa_message_init), (tree_mult_selection_popup),
+ (tree_button_press_cb), (display_content),
+ (open_with_change_state), (copy_part_change_state),
+ (part_create_menu):
+
2020-06-09 Peter Bloomfield <pbloomfield bellsouth net>
Various: restore filtering in a mailbox that is not currently
diff --git a/libbalsa/libbalsa.c b/libbalsa/libbalsa.c
index fe48f1a41..05e216ff2 100644
--- a/libbalsa/libbalsa.c
+++ b/libbalsa/libbalsa.c
@@ -745,3 +745,21 @@ libbalsa_dialog_flags(void)
{
return libbalsa_use_headerbar() ? GTK_DIALOG_USE_HEADER_BAR : (GtkDialogFlags) 0;
}
+
+gboolean
+libbalsa_use_popover(void)
+{
+ static gboolean use_popover = TRUE;
+ static gint check_done = 0;
+
+ if (g_atomic_int_get(&check_done) == 0) {
+ const gchar *popover_env;
+
+ popover_env = g_getenv("BALSA_USE_POPOVER");
+ if ((popover_env != NULL) && (atoi(popover_env) == 0)) {
+ use_popover = FALSE;
+ }
+ g_atomic_int_set(&check_done, 1);
+ }
+ return use_popover;
+}
diff --git a/libbalsa/libbalsa.h b/libbalsa/libbalsa.h
index deac03796..b8f54bbf9 100644
--- a/libbalsa/libbalsa.h
+++ b/libbalsa/libbalsa.h
@@ -187,6 +187,8 @@ enum LibBalsaImageError {
gboolean libbalsa_use_headerbar(void);
GtkDialogFlags libbalsa_dialog_flags(void);
+gboolean libbalsa_use_popover(void);
+
#if HAVE_GTKSOURCEVIEW
GtkWidget *libbalsa_source_view_new(gboolean highlight_phrases);
#endif /* HAVE_GTKSOURCEVIEW */
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 7206181d9..bafcbaa4f 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -142,7 +142,7 @@ struct _BalsaIndex {
/* the popup menu */
GMenu *popup_menu;
- GtkWidget *popup_popover;
+ GtkWidget *popup_widget;
gint move_position;
BalsaMailboxNode* mailbox_node;
@@ -1932,7 +1932,8 @@ move_to_change_state(GSimpleAction *action,
}
}
- gtk_popover_popdown(GTK_POPOVER(bindex->popup_popover));
+ if (libbalsa_use_popover())
+ gtk_popover_popdown(GTK_POPOVER(bindex->popup_widget));
}
/*
@@ -2015,8 +2016,12 @@ bndx_popup_menu_create(BalsaIndex * bindex)
g_object_unref(section);
bindex->popup_menu = menu;
- bindex->popup_popover = gtk_popover_new_from_model(GTK_WIDGET(bindex), G_MENU_MODEL(menu));
- gtk_popover_set_position(GTK_POPOVER(bindex->popup_popover), GTK_POS_BOTTOM);
+ if (libbalsa_use_popover()) {
+ bindex->popup_widget = gtk_popover_new_from_model(GTK_WIDGET(bindex), G_MENU_MODEL(menu));
+ gtk_popover_set_position(GTK_POPOVER(bindex->popup_widget), GTK_POS_BOTTOM);
+ } else {
+ bindex->popup_widget = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+ }
}
/* bndx_do_popup: common code for the popup menu;
@@ -2103,29 +2108,39 @@ bndx_do_popup(BalsaIndex * index, const GdkEvent *event)
g_menu_insert_item(index->popup_menu, index->move_position, item);
g_object_unref(item);
- if (event != NULL &&
- gdk_event_triggers_context_menu(event) &&
- gdk_event_get_coords(event, &x, &y)) {
- /* Pop up to the right of the pointer */
- gtk_tree_view_convert_bin_window_to_widget_coords(GTK_TREE_VIEW(index),
- (gint) x,
- (gint) y,
- &allocation.x,
- &allocation.y);
- allocation.width = 0;
- allocation.height = 0;
+ if (libbalsa_use_popover()) {
+ if (event != NULL &&
+ gdk_event_triggers_context_menu(event) &&
+ gdk_event_get_coords(event, &x, &y)) {
+ /* Pop up to the right of the pointer */
+ gtk_tree_view_convert_bin_window_to_widget_coords(GTK_TREE_VIEW(index),
+ (gint) x,
+ (gint) y,
+ &allocation.x,
+ &allocation.y);
+ allocation.width = 0;
+ allocation.height = 0;
+ } else {
+ /* Pop up to the right of the "From" column */
+ gtk_widget_get_allocation(GTK_WIDGET(index), &allocation);
+ allocation.width = balsa_app.index_num_width +
+ balsa_app.index_status_width +
+ balsa_app.index_attachment_width +
+ balsa_app.index_from_width;
+ }
+ gtk_popover_set_pointing_to(GTK_POPOVER(index->popup_widget),
+ (GdkRectangle *) &allocation);
+
+ gtk_popover_popup(GTK_POPOVER(index->popup_widget));
} else {
- /* Pop up to the right of the "From" column */
- gtk_widget_get_allocation(GTK_WIDGET(index), &allocation);
- allocation.width = balsa_app.index_num_width +
- balsa_app.index_status_width +
- balsa_app.index_attachment_width +
- balsa_app.index_from_width;
+ if (event != NULL) {
+ gtk_menu_popup_at_pointer(GTK_MENU(index->popup_widget), event);
+ } else {
+ gtk_menu_popup_at_widget(GTK_MENU(index->popup_widget), GTK_WIDGET(index),
+ GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+ NULL);
+ }
}
- gtk_popover_set_pointing_to(GTK_POPOVER(index->popup_popover),
- (GdkRectangle *) &allocation);
-
- gtk_popover_popup(GTK_POPOVER(index->popup_popover));
}
/* End of popup stuff */
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index 8d64e1700..3ea6607de 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -740,22 +740,33 @@ bmbl_do_popup(GtkTreeView *tree_view,
menu = balsa_mailbox_node_get_context_menu(mbnode, GTK_WIDGET(tree_view));
+ if (libbalsa_use_popover()) {
+ if (event != NULL &&
+ gdk_event_triggers_context_menu(event) &&
+ gdk_event_get_coords(event, &x, &y)) {
+ GdkRectangle rectangle;
+
+ /* Pop up above the pointer */
+ rectangle.x = (int) x;
+ rectangle.width = 0;
+ rectangle.y = (int) y;
+ rectangle.height = 0;
+ gtk_popover_set_pointing_to(GTK_POPOVER(menu), &rectangle);
+ }
- if (event != NULL &&
- gdk_event_triggers_context_menu(event) &&
- gdk_event_get_coords(event, &x, &y)) {
- GdkRectangle rectangle;
-
- /* Pop up above the pointer */
- rectangle.x = (int) x;
- rectangle.width = 0;
- rectangle.y = (int) y;
- rectangle.height = 0;
- gtk_popover_set_pointing_to(GTK_POPOVER(menu), &rectangle);
+ gtk_popover_popup(GTK_POPOVER(menu));
+ } else {
+ g_object_ref(menu);
+ g_object_ref_sink(menu);
+ if (event)
+ gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent *) event);
+ else
+ gtk_menu_popup_at_widget(GTK_MENU(menu), GTK_WIDGET(tree_view),
+ GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+ NULL);
+ g_object_unref(menu);
}
- gtk_popover_popup(GTK_POPOVER(menu));
-
if (mbnode != NULL)
g_object_unref(mbnode);
}
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 377aa32f6..341b2ee46 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -239,8 +239,16 @@ balsa_message_class_init(BalsaMessageClass * klass)
static void
balsa_headers_attachments_popup(GtkButton * button, BalsaMessage * balsa_message)
{
- if (balsa_message->parts_popup != NULL)
- gtk_popover_popup(GTK_POPOVER(balsa_message->parts_popup));
+ if (balsa_message->parts_popup != NULL) {
+ if (libbalsa_use_popover()) {
+ gtk_popover_popup(GTK_POPOVER(balsa_message->parts_popup));
+ } else {
+ gtk_menu_popup_at_widget(GTK_MENU(balsa_message->parts_popup),
+ GTK_WIDGET(balsa_message),
+ GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+ NULL);
+ }
+ }
}
@@ -993,8 +1001,12 @@ balsa_message_init(BalsaMessage * balsa_message)
"message-menu.save-selected");
g_menu_append(menu, _("Save selected to folder…"),
"message-menu.save-selected-to-folder");
- balsa_message->save_all_popup =
- gtk_popover_new_from_model(balsa_message->treeview, G_MENU_MODEL(menu));
+ if (libbalsa_use_popover()) {
+ balsa_message->save_all_popup =
+ gtk_popover_new_from_model(balsa_message->treeview, G_MENU_MODEL(menu));
+ } else {
+ balsa_message->save_all_popup = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+ }
g_object_unref(menu);
gtk_widget_show_all(GTK_WIDGET(balsa_message));
@@ -1143,7 +1155,10 @@ tree_mult_selection_popup(BalsaMessage *balsa_message,
popup_menu = balsa_message->save_all_popup;
}
- if (popup_menu != NULL) {
+ if (popup_menu == NULL)
+ return;
+
+ if (libbalsa_use_popover()) {
gdouble x, y;
if (event != NULL &&
@@ -1160,6 +1175,15 @@ tree_mult_selection_popup(BalsaMessage *balsa_message,
}
gtk_popover_popup(GTK_POPOVER(popup_menu));
+ } else {
+ if (event != NULL) {
+ gtk_menu_popup_at_pointer(GTK_MENU(balsa_message->save_all_popup), event);
+ } else {
+ gtk_menu_popup_at_widget(GTK_MENU(balsa_message->save_all_popup),
+ GTK_WIDGET(balsa_message),
+ GDK_GRAVITY_CENTER, GDK_GRAVITY_CENTER,
+ NULL);
+ }
}
}
@@ -1224,17 +1248,21 @@ tree_button_press_cb(GtkGestureMultiPress *multi_press_gesture,
gtk_tree_model_get(model, &iter, PART_INFO_COLUMN, &info, -1);
if (info != NULL) {
if (info->popup_menu != NULL) {
- GdkRectangle rectangle;
-
- /* Pop up above the pointer */
- rectangle.x = (int) x;
- rectangle.width = 0;
- rectangle.y = (int) y;
- rectangle.height = 0;
- gtk_popover_set_pointing_to(GTK_POPOVER(info->popup_menu),
- &rectangle);
-
- gtk_popover_popup(GTK_POPOVER(info->popup_menu));
+ if (libbalsa_use_popover()) {
+ GdkRectangle rectangle;
+
+ /* Pop up above the pointer */
+ rectangle.x = (int) x;
+ rectangle.width = 0;
+ rectangle.y = (int) y;
+ rectangle.height = 0;
+ gtk_popover_set_pointing_to(GTK_POPOVER(info->popup_menu),
+ &rectangle);
+
+ gtk_popover_popup(GTK_POPOVER(info->popup_menu));
+ } else {
+ gtk_menu_popup_at_pointer(GTK_MENU(info->popup_menu), event);
+ }
}
g_object_unref(info);
}
@@ -1753,13 +1781,22 @@ display_content(BalsaMessage * balsa_message)
balsa_message->parts_menu = g_menu_new();
- /* Detach any existing popup: */
- if (balsa_message->parts_popup != NULL)
- gtk_popover_set_relative_to(GTK_POPOVER(balsa_message->parts_popup), NULL);
+ if (libbalsa_use_popover()) {
+ /* Detach any existing popup: */
+ if (balsa_message->parts_popup != NULL)
+ gtk_popover_set_relative_to(GTK_POPOVER(balsa_message->parts_popup), NULL);
- balsa_message->parts_popup =
- gtk_popover_new_from_model(balsa_message->attach_button,
- G_MENU_MODEL(balsa_message->parts_menu));
+ balsa_message->parts_popup =
+ gtk_popover_new_from_model(balsa_message->attach_button,
+ G_MENU_MODEL(balsa_message->parts_menu));
+ } else {
+ if (balsa_message->parts_popup)
+ g_object_unref(balsa_message->parts_popup);
+
+ balsa_message->parts_popup =
+ gtk_menu_new_from_model(G_MENU_MODEL(balsa_message->parts_menu));
+ g_object_ref_sink(balsa_message->parts_popup);
+ }
/* Populate the parts-menu */
display_parts(balsa_message, libbalsa_message_get_body_list(balsa_message->message), NULL, NULL);
@@ -1825,7 +1862,8 @@ open_with_change_state(GSimpleAction *action,
balsa_mime_widget_ctx_menu_cb(app, info->body);
g_simple_action_set_state(action, parameter);
- gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
+ if (libbalsa_use_popover())
+ gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
}
static void
@@ -1844,7 +1882,8 @@ copy_part_change_state(GSimpleAction *action,
}
g_simple_action_set_state(action, parameter);
- gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
+ if (libbalsa_use_popover())
+ gtk_popover_popdown(GTK_POPOVER(info->popup_menu));
}
static void
@@ -1904,8 +1943,13 @@ part_create_menu(BalsaMessage *balsa_message, BalsaPartInfo *info)
g_free(content_type);
g_free(prefix);
- info->popup_menu =
- gtk_popover_new_from_model(balsa_message->treeview, G_MENU_MODEL(menu));
+ if (libbalsa_use_popover()) {
+ info->popup_menu =
+ gtk_popover_new_from_model(balsa_message->treeview, G_MENU_MODEL(menu));
+ } else {
+ info->popup_menu = gtk_menu_new_from_model(G_MENU_MODEL(menu));
+ }
+
g_object_unref(menu);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]