X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-utils.c;h=90217262f3dbc2a16041d07346affbfd4fa5ee21;hb=64153d3fe6c59d09f13131db5f376df550f966ac;hp=b35b77bba21828794a79cd53d9dd0addeb531ce8;hpb=70f641411b2fbab930b481ac844984819b48805d;p=evince.git diff --git a/shell/ev-utils.c b/shell/ev-utils.c index b35b77bb..90217262 100644 --- a/shell/ev-utils.c +++ b/shell/ev-utils.c @@ -22,6 +22,8 @@ #include "ev-utils.h" #include "ev-file-helpers.h" + +#include #include #define PRINT_CONFIG_FILENAME "ev-print-config.xml" @@ -251,6 +253,8 @@ using_postscript_printer (GnomePrintConfig *config) return TRUE; else if (!strcmp ((const gchar *)transport, "LPD")) return TRUE; + else if (!strcmp ((const gchar *)transport, "PAPI")) + return TRUE; } return FALSE; @@ -300,3 +304,68 @@ save_print_config_to_file (GnomePrintConfig *config) } #endif /* WITH_GNOME_PRINT */ +static void +ev_gui_sanitise_popup_position (GtkMenu *menu, + GtkWidget *widget, + gint *x, + gint *y) +{ + GdkScreen *screen = gtk_widget_get_screen (widget); + gint monitor_num; + GdkRectangle monitor; + GtkRequisition req; + + g_return_if_fail (widget != NULL); + + gtk_widget_size_request (GTK_WIDGET (menu), &req); + + monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); + gtk_menu_set_monitor (menu, monitor_num); + gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); + + *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width)); + *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height)); +} + +void +ev_gui_menu_position_tree_selection (GtkMenu *menu, + gint *x, + gint *y, + gboolean *push_in, + gpointer user_data) +{ + GtkTreeSelection *selection; + GList *selected_rows; + GtkTreeModel *model; + GtkTreeView *tree_view = GTK_TREE_VIEW (user_data); + GtkWidget *widget = GTK_WIDGET (user_data); + GtkRequisition req; + GdkRectangle visible; + + gtk_widget_size_request (GTK_WIDGET (menu), &req); + gdk_window_get_origin (widget->window, x, y); + + *x += (widget->allocation.width - req.width) / 2; + + /* Add on height for the treeview title */ + gtk_tree_view_get_visible_rect (tree_view, &visible); + *y += widget->allocation.height - visible.height; + + selection = gtk_tree_view_get_selection (tree_view); + selected_rows = gtk_tree_selection_get_selected_rows (selection, &model); + if (selected_rows) + { + GdkRectangle cell_rect; + + gtk_tree_view_get_cell_area (tree_view, selected_rows->data, + NULL, &cell_rect); + + *y += CLAMP (cell_rect.y + cell_rect.height, 0, visible.height); + + g_list_foreach (selected_rows, (GFunc)gtk_tree_path_free, NULL); + g_list_free (selected_rows); + } + + ev_gui_sanitise_popup_position (menu, widget, x, y); +} +