talkatu/talkatu

Remove code for no-longer supported GTK

2021-10-09, Elliott Sales de Andrade
cdb6fdb07bc4
Parents 953536539d73
Children e778e5866097
Remove code for no-longer supported GTK

We require GTK 3.24 now.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/1012/
--- a/demo/talkatudemowindow.c Sat Sep 25 13:34:51 2021 -0500
+++ b/demo/talkatudemowindow.c Sat Oct 09 23:34:45 2021 -0500
@@ -181,22 +181,8 @@
GError *error = NULL;
gboolean success = FALSE;
-#if GTK_CHECK_VERSION(3, 22, 0)
success = gtk_show_uri_on_window(
- GTK_WINDOW(data),
- url,
- GDK_CURRENT_TIME,
- &error
- );
-#else
- success = gtk_show_uri(
- gtk_widget_get_screen(view),
- url,
- GDK_CURRENT_TIME,
- &error
- );
-#endif
-
+ GTK_WINDOW(data), url, GDK_CURRENT_TIME, &error);
if(!success) {
g_message(
"failed to open uri '%s': %s",
@@ -238,11 +224,7 @@
talkatu_demo_window_author_toggled_cb(GtkToolButton *button, gpointer data) {
GtkPopover *popover = GTK_POPOVER(data);
-#if GTK_CHECK_VERSION(3,22,0)
gtk_popover_popup(popover);
-#else
- gtk_widget_show(popover);
-#endif
}
static void
@@ -271,11 +253,7 @@
{
GtkPopover *popover = GTK_POPOVER(data);
-#if GTK_CHECK_VERSION(3,22,0)
gtk_popover_popup(popover);
-#else
- gtk_widget_show(popover);
-#endif
}
static void
--- a/talkatu/talkatumenutoolbutton.c Sat Sep 25 13:34:51 2021 -0500
+++ b/talkatu/talkatumenutoolbutton.c Sat Oct 09 23:34:45 2021 -0500
@@ -61,171 +61,15 @@
* GObject Stuff
*****************************************************************************/
-#if !GTK_CHECK_VERSION(3, 22, 0)
-static void
-talkatu_menu_position_func_helper(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
-{
- GtkWidget *widget;
- GtkRequisition requisition;
- GdkScreen *screen;
- GdkRectangle monitor;
- gint monitor_num;
- gint space_left, space_right, space_above, space_below;
- gboolean rtl;
-
- g_return_if_fail(GTK_IS_MENU(menu));
-
- widget = GTK_WIDGET(menu);
- screen = gtk_widget_get_screen(widget);
- rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
-
- /*
- * We need the requisition to figure out the right place to
- * popup the menu. In fact, we always need to ask here, since
- * if a size_request was queued while we weren't popped up,
- * the requisition won't have been recomputed yet.
- */
- gtk_widget_get_preferred_size(widget, NULL, &requisition);
-
- monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
-
- *push_in = FALSE;
-
- /*
- * The placement of popup menus horizontally works like this (with
- * RTL in parentheses)
- *
- * - If there is enough room to the right (left) of the mouse cursor,
- * position the menu there.
- *
- * - Otherwise, if if there is enough room to the left (right) of the
- * mouse cursor, position the menu there.
- *
- * - Otherwise if the menu is smaller than the monitor, position it
- * on the side of the mouse cursor that has the most space available
- *
- * - Otherwise (if there is simply not enough room for the menu on the
- * monitor), position it as far left (right) as possible.
- *
- * Positioning in the vertical direction is similar: first try below
- * mouse cursor, then above.
- */
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- space_left = *x - monitor.x;
- space_right = monitor.x + monitor.width - *x - 1;
- space_above = *y - monitor.y;
- space_below = monitor.y + monitor.height - *y - 1;
-
- /* position horizontally */
-
- if (requisition.width <= space_left || requisition.width <= space_right) {
- if ((rtl && requisition.width <= space_left) ||
- (!rtl && requisition.width > space_right)) {
- /* position left */
- *x = *x - requisition.width + 1;
- }
-
- /* x is clamped on-screen further down */
-
- } else if (requisition.width <= monitor.width) {
- /* the menu is too big to fit on either side of the mouse
- * cursor, but smaller than the monitor. Position it on
- * the side that has the most space
- */
- if (space_left > space_right) {
- /* left justify */
- *x = monitor.x;
- } else {
- /* right justify */
- *x = monitor.x + monitor.width - requisition.width;
- }
-
- } else {
- /* menu is simply too big for the monitor */
- if (rtl) {
- /* right justify */
- *x = monitor.x + monitor.width - requisition.width;
- } else {
- /* left justify */
- *x = monitor.x;
- }
- }
-
- /* Position vertically. The algorithm is the same as above, but
- * simpler because we don't have to take RTL into account.
- */
-
- if (requisition.height <= space_above || requisition.height <= space_below) {
- if (requisition.height > space_below) {
- *y = *y - requisition.height + 1;
- }
-
- *y = CLAMP(*y, monitor.y,
- monitor.y + monitor.height - requisition.height);
- } else if (requisition.height > space_below && requisition.height > space_above) {
- if (space_below >= space_above) {
- *y = monitor.y + monitor.height - requisition.height;
- } else {
- *y = monitor.y;
- }
- } else {
- *y = monitor.y;
- }
-}
-
-/* This comes from gtkmenutoolbutton.c from gtk+
- * Copyright (C) 2003 Ricardo Fernandez Pascual
- * Copyright (C) 2004 Paolo Borelli
- */
-static void
-talkatu_menu_position_func(GtkMenu *menu,
- gint *x,
- gint *y,
- gboolean *push_in,
- gpointer data)
-{
- GtkWidget *widget = GTK_WIDGET(data);
- GtkAllocation allocation;
- gint savy;
-
- gtk_widget_get_allocation(widget, &allocation);
- gdk_window_get_origin(gtk_widget_get_window(widget), x, y);
-
- *x += allocation.x;
- *y += allocation.y + allocation.height;
- savy = *y;
-
- talkatu_menu_position_func_helper(menu, x, y, push_in, data);
-
- if (savy > *y + 1)
- *y -= allocation.height;
-}
-#endif
-
static void
talkatu_menu_tool_button_clicked(GtkToolButton *button) {
TalkatuMenuToolButton *menu_button = TALKATU_MENU_TOOL_BUTTON(button);
-#if GTK_CHECK_VERSION(3, 22, 0)
- gtk_menu_popup_at_widget(
- GTK_MENU(menu_button->menu),
- GTK_WIDGET(button),
- GDK_GRAVITY_SOUTH_WEST,
- GDK_GRAVITY_NORTH_WEST,
- NULL
- );
-#else
- gtk_menu_popup(
- GTK_MENU(menu_button->menu),
- NULL,
- NULL,
- talkatu_menu_position_func,
- button,
- GDK_LEFTBUTTON,
- gtk_get_current_event_time()
- );
-#endif
+ gtk_menu_popup_at_widget(GTK_MENU(menu_button->menu),
+ GTK_WIDGET(button),
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ NULL);
}
static void