diff options
Diffstat (limited to 'src/gs-window-x11.c')
-rw-r--r-- | src/gs-window-x11.c | 329 |
1 files changed, 3 insertions, 326 deletions
diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c index 41adbb6..87eac00 100644 --- a/src/gs-window-x11.c +++ b/src/gs-window-x11.c @@ -27,12 +27,10 @@ #include <sys/wait.h> #include <string.h> -#include <gtk/gtk.h> #include <gdk/gdkx.h> #include <gdk/gdkkeysyms.h> -#if GTK_CHECK_VERSION (3, 0, 0) +#include <gtk/gtk.h> #include <gtk/gtkx.h> -#endif #include "gs-window.h" #include "gs-marshal.h" @@ -88,11 +86,7 @@ struct GSWindowPrivate GtkWidget *info_bar; GtkWidget *info_content; -#if GTK_CHECK_VERSION (3, 0, 0) cairo_surface_t *background_surface; -#else - GdkPixmap *background_pixmap; -#endif guint popup_dialog_idle_id; @@ -174,11 +168,7 @@ set_invisible_cursor (GdkWindow *window, if (cursor) { -#if GTK_CHECK_VERSION (3, 0, 0) g_object_unref (cursor); -#else - gdk_cursor_unref (cursor); -#endif } } @@ -258,15 +248,9 @@ widget_clear_all_children (GtkWidget *widget) clear_children (GDK_WINDOW_XID (w)); -#if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); -#else - gdk_display_sync (gtk_widget_get_display (widget)); - gdk_error_trap_pop (); -#endif } -#if GTK_CHECK_VERSION (3, 0, 0) static void gs_window_reset_background_surface (GSWindow *window) { @@ -277,47 +261,13 @@ gs_window_reset_background_surface (GSWindow *window) cairo_pattern_destroy (pattern); gtk_widget_queue_draw (GTK_WIDGET (window)); } -#else -static void -force_no_pixmap_background (GtkWidget *widget) -{ - static gboolean first_time = TRUE; - - if (first_time) - { - gtk_rc_parse_string ("\n" - " style \"gs-theme-engine-style\"\n" - " {\n" - " bg_pixmap[NORMAL] = \"<none>\"\n" - " bg_pixmap[INSENSITIVE] = \"<none>\"\n" - " bg_pixmap[ACTIVE] = \"<none>\"\n" - " bg_pixmap[PRELIGHT] = \"<none>\"\n" - " bg[NORMAL] = { 0.0, 0.0, 0.0 }\n" - " bg[INSENSITIVE] = { 0.0, 0.0, 0.0 }\n" - " bg[ACTIVE] = { 0.0, 0.0, 0.0 }\n" - " bg[PRELIGHT] = { 0.0, 0.0, 0.0 }\n" - " }\n" - " widget \"gs-window-drawing-area*\" style : highest \"gs-theme-engine-style\"\n" - "\n"); - first_time = FALSE; - } - - gtk_widget_set_name (widget, "gs-window-drawing-area"); -} -#endif void -#if GTK_CHECK_VERSION (3, 0, 0) gs_window_set_background_surface (GSWindow *window, cairo_surface_t *surface) -#else -gs_window_set_background_pixmap (GSWindow *window, - GdkPixmap *pixmap) -#endif { g_return_if_fail (GS_IS_WINDOW (window)); -#if GTK_CHECK_VERSION (3, 0, 0) if (window->priv->background_surface != NULL) { cairo_surface_destroy (window->priv->background_surface); @@ -328,34 +278,11 @@ gs_window_set_background_pixmap (GSWindow *window, window->priv->background_surface = cairo_surface_reference (surface); gs_window_reset_background_surface (window); } -#else - if (window->priv->background_pixmap != NULL) - { - g_object_unref (window->priv->background_pixmap); - } - - if (pixmap != NULL) - { - window->priv->background_pixmap = g_object_ref (pixmap); - gdk_window_set_back_pixmap (gtk_widget_get_window (GTK_WIDGET (window)), - pixmap, - FALSE); - } -#endif } static void -#if GTK_CHECK_VERSION (3, 0, 0) gs_window_clear_to_background_surface (GSWindow *window) -#else -gs_window_clear_to_background_pixmap (GSWindow *window) -#endif { -#if !GTK_CHECK_VERSION (3, 0, 0) - GtkStateType state; - GtkStyle *style; -#endif - g_return_if_fail (GS_IS_WINDOW (window)); if (! gtk_widget_get_visible (GTK_WIDGET (window))) @@ -363,66 +290,23 @@ gs_window_clear_to_background_pixmap (GSWindow *window) return; } -#if GTK_CHECK_VERSION (3, 0, 0) if (window->priv->background_surface == NULL) -#else - if (window->priv->background_pixmap == NULL) -#endif { - /* don't allow null pixmaps */ + /* don't allow null surfaces */ return; } gs_debug ("Clearing window to background pixmap"); -#if GTK_CHECK_VERSION (3, 0, 0) gs_window_reset_background_surface (window); -#else - style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (window))); - - state = (GtkStateType) 0; - while (state < (GtkStateType) G_N_ELEMENTS (gtk_widget_get_style (GTK_WIDGET (window))->bg_pixmap)) - { - - if (style->bg_pixmap[state] != NULL) - { - g_object_unref (style->bg_pixmap[state]); - } - - style->bg_pixmap[state] = g_object_ref (window->priv->background_pixmap); - state++; - } - - gtk_widget_set_style (GTK_WIDGET (window), style); - g_object_unref (style); - - if (window->priv->background_pixmap != NULL) - { - gdk_window_set_back_pixmap (gtk_widget_get_window (GTK_WIDGET (window)), - window->priv->background_pixmap, - FALSE); - } - - gdk_window_clear (gtk_widget_get_window (GTK_WIDGET (window))); - - gdk_flush (); -#endif } static void clear_widget (GtkWidget *widget) { -#if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA rgba = { 0.0, 0.0, 0.0, 1.0 }; GtkStateFlags state; -#else - GdkColormap *colormap; - GdkColor color = { 0, 0x0000, 0x0000, 0x0000 }; - GtkStateType state; - GtkStyle *style; -#endif -#if GTK_CHECK_VERSION (3, 0, 0) if (!gtk_widget_get_realized (widget)) { return; @@ -434,45 +318,6 @@ clear_widget (GtkWidget *widget) gtk_widget_override_background_color (widget, state, &rgba); gdk_window_set_background_rgba (gtk_widget_get_window (widget), &rgba); gtk_widget_queue_draw (GTK_WIDGET (widget)); -#else - if (!gtk_widget_get_visible (widget)) - { - return; - } - - gs_debug ("Clearing widget"); - - state = (GtkStateType) 0; - while (state < (GtkStateType) G_N_ELEMENTS (gtk_widget_get_style (widget)->bg)) - { - gtk_widget_modify_bg (widget, state, &color); - state++; - } - - style = gtk_style_copy (gtk_widget_get_style (widget)); - - state = (GtkStateType) 0; - while (state < (GtkStateType) G_N_ELEMENTS (gtk_widget_get_style (widget)->bg_pixmap)) - { - - if (style->bg_pixmap[state] != NULL) - { - g_object_unref (style->bg_pixmap[state]); - } - - style->bg_pixmap[state] = NULL; - state++; - } - - colormap = gdk_drawable_get_colormap (gtk_widget_get_window (widget)); - gdk_colormap_alloc_color (colormap, &color, FALSE, TRUE); - gdk_window_set_background (gtk_widget_get_window (widget), &color); - - gtk_widget_set_style (widget, style); - g_object_unref (style); - - gdk_window_clear (gtk_widget_get_window (widget)); -#endif /* If a screensaver theme adds child windows we need to clear them too */ widget_clear_all_children (widget); @@ -489,33 +334,19 @@ gs_window_clear (GSWindow *window) clear_widget (window->priv->drawing_area); } -#if GTK_CHECK_VERSION (3, 0, 0) static cairo_region_t * -#else -static GdkRegion * -#endif get_outside_region (GSWindow *window) { int i; -#if GTK_CHECK_VERSION (3, 0, 0) cairo_region_t *region; -#else - GdkRegion *region; -#endif -#if GTK_CHECK_VERSION (3, 0, 0) region = cairo_region_create (); -#else - region = gdk_region_new (); -#endif + for (i = 0; i < window->priv->monitor; i++) { GdkRectangle geometry; -#if GTK_CHECK_VERSION (3, 0, 0) cairo_rectangle_int_t rectangle; -#endif -#if GTK_CHECK_VERSION (3, 0, 0) gdk_screen_get_monitor_geometry (gtk_widget_get_screen (GTK_WIDGET (window)), i, &geometry); rectangle.x = geometry.x; @@ -523,11 +354,6 @@ get_outside_region (GSWindow *window) rectangle.width = geometry.width; rectangle.height = geometry.height; cairo_region_union_rectangle (region, &rectangle); -#else - gdk_screen_get_monitor_geometry (gtk_window_get_screen (GTK_WINDOW (window)), - i, &geometry); - gdk_region_union_with_rect (region, &geometry); -#endif } return region; @@ -537,13 +363,8 @@ static void update_geometry (GSWindow *window) { GdkRectangle geometry; -#if GTK_CHECK_VERSION (3, 0, 0) cairo_region_t *outside_region; cairo_region_t *monitor_region; -#else - GdkRegion *outside_region; - GdkRegion *monitor_region; -#endif outside_region = get_outside_region (window); @@ -556,23 +377,12 @@ update_geometry (GSWindow *window) geometry.y, geometry.width, geometry.height); -#if GTK_CHECK_VERSION (3, 0, 0) monitor_region = cairo_region_create_rectangle ((const cairo_rectangle_int_t *)&geometry); cairo_region_subtract (monitor_region, outside_region); cairo_region_destroy (outside_region); -#else - monitor_region = gdk_region_rectangle (&geometry); - gdk_region_subtract (monitor_region, outside_region); - gdk_region_destroy (outside_region); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry); cairo_region_destroy (monitor_region); -#else - gdk_region_get_clipbox (monitor_region, &geometry); - gdk_region_destroy (monitor_region); -#endif gs_debug ("using geometry for monitor %d: x=%d y=%d w=%d h=%d", window->priv->monitor, @@ -780,7 +590,6 @@ out: return g_object_ref (visual); } -#if GTK_CHECK_VERSION (3, 0, 0) static void widget_set_best_visual (GtkWidget *widget) { @@ -795,50 +604,11 @@ widget_set_best_visual (GtkWidget *widget) g_object_unref (visual); } } -#else -static GdkColormap * -get_best_colormap_for_screen (GdkScreen *screen) -{ - GdkColormap *colormap; - GdkVisual *visual; - - g_return_val_if_fail (screen != NULL, NULL); - - visual = get_best_visual_for_screen (screen); - - colormap = NULL; - if (visual != NULL) - { - colormap = gdk_colormap_new (visual, FALSE); - } - - return colormap; -} - -static void -widget_set_best_colormap (GtkWidget *widget) -{ - GdkColormap *colormap; - - g_return_if_fail (widget != NULL); - - colormap = get_best_colormap_for_screen (gtk_widget_get_screen (widget)); - if (colormap != NULL) - { - gtk_widget_set_colormap (widget, colormap); - g_object_unref (colormap); - } -} -#endif static void gs_window_real_realize (GtkWidget *widget) { -#if GTK_CHECK_VERSION (3, 0, 0) widget_set_best_visual (widget); -#else - widget_set_best_colormap (widget); -#endif if (GTK_WIDGET_CLASS (gs_window_parent_class)->realize) { @@ -1040,12 +810,7 @@ select_popup_events (void) events = SubstructureNotifyMask | attr.your_event_mask; XSelectInput (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_ROOT_WINDOW (), events); -#if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); -#else - gdk_display_sync (gdk_display_get_default ()); - gdk_error_trap_pop (); -#endif } static void @@ -1062,12 +827,7 @@ window_select_shape_events (GSWindow *window) XShapeSelectInput (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window))), events); } -#if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); -#else - gdk_display_sync (gdk_display_get_default ()); - gdk_error_trap_pop (); -#endif #endif } @@ -1115,27 +875,15 @@ set_info_text_and_icon (GSWindow *window, GtkWidget *primary_label; GtkWidget *secondary_label; -#if GTK_CHECK_VERSION (3, 0, 0) hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8); -#else - hbox_content = gtk_hbox_new (FALSE, 8); -#endif gtk_widget_show (hbox_content); image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG); gtk_widget_show (image); gtk_box_pack_start (GTK_BOX (hbox_content), image, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_valign (image, GTK_ALIGN_START); -#else - gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); -#else - vbox = gtk_vbox_new (FALSE, 6); -#endif gtk_widget_show (vbox); gtk_box_pack_start (GTK_BOX (hbox_content), vbox, FALSE, FALSE, 0); @@ -1146,11 +894,7 @@ set_info_text_and_icon (GSWindow *window, gtk_box_pack_start (GTK_BOX (vbox), primary_label, TRUE, TRUE, 0); gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_halign (primary_label, GTK_ALIGN_START); -#else - gtk_misc_set_alignment (GTK_MISC (primary_label), 0, 0.5); -#endif if (secondary_text != NULL) { @@ -1162,11 +906,7 @@ set_info_text_and_icon (GSWindow *window, gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0); gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE); gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_halign (secondary_label, GTK_ALIGN_START); -#else - gtk_misc_set_alignment (GTK_MISC (secondary_label), 0, 0.5); -#endif } /* remove old content */ @@ -1323,9 +1063,7 @@ spawn_on_window (GSWindow *window, { int argc; char **argv; -#if GTK_CHECK_VERSION (3, 0, 0) char **envp; -#endif GError *error; gboolean result; GIOChannel *channel; @@ -1343,7 +1081,6 @@ spawn_on_window (GSWindow *window, } error = NULL; -#if GTK_CHECK_VERSION (3, 0, 0) envp = spawn_make_environment_for_screen (gtk_window_get_screen (GTK_WINDOW (window)), NULL); result = g_spawn_async_with_pipes (NULL, argv, @@ -1356,20 +1093,6 @@ spawn_on_window (GSWindow *window, &standard_output, &standard_error, &error); -#else - result = gdk_spawn_on_screen_with_pipes (gtk_window_get_screen (GTK_WINDOW (window)), - NULL, - argv, - NULL, - G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, - NULL, - NULL, - &child_pid, - NULL, - &standard_output, - &standard_error, - &error); -#endif if (! result) { @@ -1417,9 +1140,7 @@ spawn_on_window (GSWindow *window, g_io_channel_unref (channel); g_strfreev (argv); -#if GTK_CHECK_VERSION (3, 0, 0) g_strfreev (envp); -#endif return result; } @@ -1703,15 +1424,11 @@ create_lock_socket (GSWindow *window, guint32 id) { window->priv->lock_socket = gtk_socket_new (); -#if GTK_CHECK_VERSION(3, 12, 0) window->priv->lock_box = gtk_grid_new (); gtk_widget_set_halign (GTK_WIDGET (window->priv->lock_box), GTK_ALIGN_CENTER); gtk_widget_set_valign (GTK_WIDGET (window->priv->lock_box), GTK_ALIGN_CENTER); -#else - window->priv->lock_box = gtk_alignment_new (0.5, 0.5, 0, 0); -#endif gtk_widget_show (window->priv->lock_box); gtk_box_pack_start (GTK_BOX (window->priv->vbox), window->priv->lock_box, TRUE, TRUE, 0); @@ -1797,16 +1514,10 @@ shake_dialog (GSWindow *window) break; } -#if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start (GTK_WIDGET (window->priv->lock_box), start); gtk_widget_set_margin_end (GTK_WIDGET (window->priv->lock_box), end); -#else - gtk_alignment_set_padding (GTK_ALIGNMENT (window->priv->lock_box), - 0, 0, - start, end); -#endif while (gtk_events_pending ()) { @@ -2027,11 +1738,7 @@ popup_dialog (GSWindow *window) gtk_widget_hide (window->priv->drawing_area); -#if GTK_CHECK_VERSION (3, 0, 0) gs_window_clear_to_background_surface (window); -#else - gs_window_clear_to_background_pixmap (window); -#endif set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)), FALSE); window->priv->dialog_quit_requested = FALSE; @@ -2494,11 +2201,7 @@ gs_window_real_size_request (GtkWidget *widget, if (child && gtk_widget_get_visible (child)) { -#if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_get_preferred_size (child, requisition, NULL); -#else - gtk_widget_size_request (child, requisition); -#endif } old_geometry = window->priv->geometry; @@ -2528,7 +2231,6 @@ gs_window_real_size_request (GtkWidget *widget, gs_window_move_resize_window (window, position_changed, size_changed); } -#if GTK_CHECK_VERSION (3, 0, 0) static void gs_window_real_get_preferred_width (GtkWidget *widget, gint *minimal_width, @@ -2548,7 +2250,6 @@ gs_window_real_get_preferred_height (GtkWidget *widget, gs_window_real_size_request (widget, &requisition); *minimal_height = *natural_height = requisition.height; } -#endif static gboolean gs_window_real_grab_broken (GtkWidget *widget, @@ -2639,12 +2340,8 @@ gs_window_class_init (GSWindowClass *klass) widget_class->motion_notify_event = gs_window_real_motion_notify_event; widget_class->button_press_event = gs_window_real_button_press_event; widget_class->scroll_event = gs_window_real_scroll_event; -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->get_preferred_width = gs_window_real_get_preferred_width; widget_class->get_preferred_height = gs_window_real_get_preferred_height; -#else - widget_class->size_request = gs_window_real_size_request; -#endif widget_class->grab_broken_event = gs_window_real_grab_broken; widget_class->visibility_notify_event = gs_window_real_visibility_notify_event; @@ -2757,7 +2454,6 @@ create_info_bar (GSWindow *window) gtk_box_pack_end (GTK_BOX (window->priv->vbox), window->priv->info_bar, FALSE, FALSE, 0); } -#if GTK_CHECK_VERSION (3, 0, 0) static void on_drawing_area_realized (GtkWidget *drawing_area) { @@ -2766,7 +2462,6 @@ on_drawing_area_realized (GtkWidget *drawing_area) gdk_window_set_background_rgba (gtk_widget_get_window (drawing_area), &black); } -#endif static void gs_window_init (GSWindow *window) @@ -2802,31 +2497,20 @@ gs_window_init (GSWindow *window) | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); -#if GTK_CHECK_VERSION (3, 0, 0) window->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); -#else - window->priv->vbox = gtk_vbox_new (FALSE, 12); -#endif gtk_widget_show (window->priv->vbox); gtk_container_add (GTK_CONTAINER (window), window->priv->vbox); window->priv->drawing_area = gtk_drawing_area_new (); gtk_widget_show (window->priv->drawing_area); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_app_paintable (window->priv->drawing_area, TRUE); -#endif gtk_box_pack_start (GTK_BOX (window->priv->vbox), window->priv->drawing_area, TRUE, TRUE, 0); -#if GTK_CHECK_VERSION (3, 0, 0) g_signal_connect (window->priv->drawing_area, "realize", G_CALLBACK (on_drawing_area_realized), NULL); -#endif create_info_bar (window); -#if !GTK_CHECK_VERSION (3, 0, 0) - force_no_pixmap_background (window->priv->drawing_area); -#endif } static void @@ -2879,17 +2563,10 @@ gs_window_finalize (GObject *object) gs_window_dialog_finish (window); -#if GTK_CHECK_VERSION (3, 0, 0) if (window->priv->background_surface) { cairo_surface_destroy (window->priv->background_surface); } -#else - if (window->priv->background_pixmap) - { - g_object_unref (window->priv->background_pixmap); - } -#endif G_OBJECT_CLASS (gs_window_parent_class)->finalize (object); } |