summaryrefslogtreecommitdiff
path: root/mate-screenshot
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-11-22 15:49:16 +0300
committermonsta <[email protected]>2016-11-22 15:49:16 +0300
commitea481767c4e3ec19136a5b61ad46f244a9a5ffa7 (patch)
treebbcceb1d2a0be587e7127109f57e41e9e9b43f98 /mate-screenshot
parent8f9a34f003061d7c5e6cfe8a8cb64ec6e98d7c4a (diff)
downloadmate-utils-ea481767c4e3ec19136a5b61ad46f244a9a5ffa7.tar.bz2
mate-utils-ea481767c4e3ec19136a5b61ad46f244a9a5ffa7.tar.xz
move to GTK+3 (>= 3.14), drop GTK+2 code and --with-gtk build option
and require mate-panel >= 1.17
Diffstat (limited to 'mate-screenshot')
-rw-r--r--mate-screenshot/data/Makefile.am3
-rw-r--r--mate-screenshot/data/mate-screenshot.ui251
-rw-r--r--mate-screenshot/src/mate-screenshot.c64
-rw-r--r--mate-screenshot/src/screenshot-dialog.c79
-rw-r--r--mate-screenshot/src/screenshot-utils.c194
5 files changed, 5 insertions, 586 deletions
diff --git a/mate-screenshot/data/Makefile.am b/mate-screenshot/data/Makefile.am
index 3f26d30c..e3f8623e 100644
--- a/mate-screenshot/data/Makefile.am
+++ b/mate-screenshot/data/Makefile.am
@@ -5,8 +5,7 @@ mate_screenshot_DATA = $(mate_screenshot_in_files:.desktop.in=.desktop)
man_MANS = mate-screenshot.1
uidir = $(datadir)/mate-screenshot
-ui_DATA = mate-screenshot.ui \
- mate-screenshot-gtk3.ui
+ui_DATA = mate-screenshot-gtk3.ui
@INTLTOOL_XML_RULE@
appdatadir = $(datadir)/appdata
diff --git a/mate-screenshot/data/mate-screenshot.ui b/mate-screenshot/data/mate-screenshot.ui
deleted file mode 100644
index 80382ed4..00000000
--- a/mate-screenshot/data/mate-screenshot.ui
+++ /dev/null
@@ -1,251 +0,0 @@
-<?xml version="1.0"?>
-<!--*- mode: xml -*-->
-<interface>
- <object class="GtkDialog" id="toplevel">
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Save Screenshot</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">False</property>
- <property name="resizable">False</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <signal handler="on_toplevel_key_press_event" last_modification_time="Thu, 21 Oct 2004 13:29:25 GMT" name="key_press_event"/>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <object class="GtkButton" id="help_button">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-help</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="copy_button">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="use_underline">True</property>
- <property name="label" translatable="yes">C_opy to Clipboard</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <accelerator key="C" modifiers="GDK_CONTROL_MASK" signal="activate"/>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="ok_button">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-save</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="vbox3">
- <property name="border_width">5</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">18</property>
- <child>
- <object class="GtkHBox" id="hbox6">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkAlignment" id="alignment1">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <property name="top_padding">0</property>
- <property name="bottom_padding">0</property>
- <property name="left_padding">0</property>
- <property name="right_padding">0</property>
- <child>
- <object class="GtkAspectFrame" id="aspect_frame">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="label_yalign">0</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="ratio">1</property>
- <property name="obey_child">True</property>
- <child>
- <object class="GtkDrawingArea" id="preview_darea">
- <property name="visible">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="homogeneous">False</property>
- <property name="row_spacing">6</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Name:</property>
- <property name="use_underline">True</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="mnemonic_widget">filename_entry</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="x_options">fill</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Save in _folder:</property>
- <property name="use_underline">True</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">fill</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="filename_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"/>
- <property name="has_frame">True</property>
- <property name="invisible_char" translatable="yes">*</property>
- <property name="activates_default">True</property>
- <property name="width_chars">32</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="file_chooser_box">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">0</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">fill</property>
- <property name="y_options">fill</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="padding">0</property>
- <property name="expand">True</property>
- <property name="fill">True</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="-11">help_button</action-widget>
- <action-widget response="-6">cancel_button</action-widget>
- <action-widget response="-5">ok_button</action-widget>
- <action-widget response="1">copy_button</action-widget>
- </action-widgets>
- </object>
-</interface>
diff --git a/mate-screenshot/src/mate-screenshot.c b/mate-screenshot/src/mate-screenshot.c
index c51bebee..2a8d0db0 100644
--- a/mate-screenshot/src/mate-screenshot.c
+++ b/mate-screenshot/src/mate-screenshot.c
@@ -315,19 +315,12 @@ create_effects_frame (GtkWidget *outer_vbox,
const gchar *frame_title)
{
GtkWidget *main_vbox, *vbox, *hbox;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GtkWidget *align;
-#endif
GtkWidget *label;
GtkWidget *check;
GtkWidget *combo;
gchar *title;
-#if GTK_CHECK_VERSION (3, 0, 0)
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-#else
- main_vbox = gtk_vbox_new (FALSE, 6);
-#endif
gtk_widget_set_sensitive (main_vbox, !take_area_shot);
gtk_box_pack_start (GTK_BOX (outer_vbox), main_vbox, FALSE, FALSE, 0);
gtk_widget_show (main_vbox);
@@ -346,30 +339,13 @@ create_effects_frame (GtkWidget *outer_vbox,
gtk_widget_show (label);
g_free (title);
-#if GTK_CHECK_VERSION (3, 0, 0)
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
-#else
- hbox = gtk_hbox_new (FALSE, 12);
-#endif
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- align = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
- gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 12, 0);
- gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, FALSE, 0);
- gtk_widget_show (align);
-#endif
-
-#if GTK_CHECK_VERSION (3, 0, 0)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
gtk_widget_set_margin_start (vbox, 12);
-#else
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_container_add (GTK_CONTAINER (align), vbox);
-#endif
-
gtk_widget_show (vbox);
/** Include pointer **/
@@ -393,11 +369,7 @@ create_effects_frame (GtkWidget *outer_vbox,
border_check = check;
/** Effects **/
-#if GTK_CHECK_VERSION (3, 0, 0)
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
-#else
- hbox = gtk_hbox_new (FALSE, 12);
-#endif
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
@@ -426,9 +398,6 @@ create_screenshot_frame (GtkWidget *outer_vbox,
const gchar *frame_title)
{
GtkWidget *main_vbox, *vbox, *hbox;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GtkWidget *align;
-#endif
GtkWidget *radio;
GtkWidget *image;
GtkWidget *spin;
@@ -437,11 +406,7 @@ create_screenshot_frame (GtkWidget *outer_vbox,
GSList *group;
gchar *title;
-#if GTK_CHECK_VERSION (3, 0, 0)
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-#else
- main_vbox = gtk_vbox_new (FALSE, 6);
-#endif
gtk_box_pack_start (GTK_BOX (outer_vbox), main_vbox, FALSE, FALSE, 0);
gtk_widget_show (main_vbox);
@@ -458,39 +423,18 @@ create_screenshot_frame (GtkWidget *outer_vbox,
gtk_widget_show (label);
g_free (title);
-#if GTK_CHECK_VERSION (3, 0, 0)
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
-#else
- hbox = gtk_hbox_new (FALSE, 12);
-#endif
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- align = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
- gtk_widget_set_size_request (align, 48, -1);
- gtk_box_pack_start (GTK_BOX (hbox), align, FALSE, FALSE, 0);
- gtk_widget_show (align);
-#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
image = gtk_image_new_from_icon_name (SCREENSHOOTER_ICON,
GTK_ICON_SIZE_DIALOG);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_set_valign (image, GTK_ALIGN_START);
-#else
- image = gtk_image_new_from_stock (SCREENSHOOTER_ICON,
- GTK_ICON_SIZE_DIALOG);
- gtk_container_add (GTK_CONTAINER (align), image);
-#endif
-
gtk_widget_show (image);
-#if GTK_CHECK_VERSION (3, 0, 0)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
-#else
- vbox = gtk_vbox_new (FALSE, 6);
-#endif
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
@@ -531,11 +475,7 @@ create_screenshot_frame (GtkWidget *outer_vbox,
gtk_widget_show (radio);
/** Grab after delay **/
-#if GTK_CHECK_VERSION (3, 0, 0)
delay_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-#else
- delay_hbox = gtk_hbox_new (FALSE, 6);
-#endif
gtk_widget_set_sensitive (delay_hbox, !take_area_shot);
gtk_box_pack_start (GTK_BOX (vbox), delay_hbox, FALSE, FALSE, 0);
gtk_widget_show (delay_hbox);
@@ -594,11 +534,7 @@ create_interactive_dialog (void)
gtk_window_set_title (GTK_WINDOW (retval), _("Take Screenshot"));
/* main container */
-#if GTK_CHECK_VERSION (3, 0, 0)
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
-#else
- main_vbox = gtk_vbox_new (FALSE, 18);
-#endif
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 5);
gtk_box_pack_start (GTK_BOX (content_area), main_vbox, TRUE, TRUE, 0);
gtk_widget_show (main_vbox);
diff --git a/mate-screenshot/src/screenshot-dialog.c b/mate-screenshot/src/screenshot-dialog.c
index 2886458a..e66513ef 100644
--- a/mate-screenshot/src/screenshot-dialog.c
+++ b/mate-screenshot/src/screenshot-dialog.c
@@ -64,7 +64,6 @@ on_toplevel_key_press_event (GtkWidget *widget,
return FALSE;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
on_preview_draw (GtkWidget *drawing_area,
cairo_t *cr,
@@ -97,51 +96,6 @@ on_preview_draw (GtkWidget *drawing_area,
gtk_style_context_restore (context);
}
-#else
-static void
-on_preview_expose_event (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
-{
- ScreenshotDialog *dialog = data;
- GdkPixbuf *pixbuf = NULL;
- gboolean free_pixbuf = FALSE;
- cairo_t *cr;
- /* Stolen from GtkImage. I really should just make the drawing area an
- * image some day */
- if (gtk_widget_get_state (drawing_area) != GTK_STATE_NORMAL)
- {
- GtkIconSource *source;
-
- source = gtk_icon_source_new ();
- gtk_icon_source_set_pixbuf (source, dialog->preview_image);
- gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR);
- gtk_icon_source_set_size_wildcarded (source, FALSE);
-
- pixbuf = gtk_style_render_icon (gtk_widget_get_style (drawing_area),
- source,
- gtk_widget_get_direction (drawing_area),
- gtk_widget_get_state (drawing_area),
- (GtkIconSize) -1,
- drawing_area,
- "gtk-image");
- free_pixbuf = TRUE;
- gtk_icon_source_free (source);
- }
- else
- {
- pixbuf = g_object_ref (dialog->preview_image);
- }
-
- cr = gdk_cairo_create (gtk_widget_get_window (drawing_area));
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
-
- g_object_unref (pixbuf);
-}
-#endif
-
static gboolean
on_preview_button_press_event (GtkWidget *drawing_area,
GdkEventButton *event,
@@ -168,24 +122,6 @@ on_preview_button_release_event (GtkWidget *drawing_area,
return FALSE;
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void
-on_preview_configure_event (GtkWidget *drawing_area,
- GdkEventConfigure *event,
- gpointer data)
-{
- ScreenshotDialog *dialog = data;
-
- if (dialog->preview_image)
- g_object_unref (G_OBJECT (dialog->preview_image));
-
- dialog->preview_image = gdk_pixbuf_scale_simple (dialog->screenshot,
- event->width,
- event->height,
- GDK_INTERP_BILINEAR);
-}
-#endif
-
static void
drag_data_get (GtkWidget *widget,
GdkDragContext *context,
@@ -258,11 +194,7 @@ screenshot_dialog_new (GdkPixbuf *screenshot,
dialog = g_new0 (ScreenshotDialog, 1);
dialog->ui = gtk_builder_new ();
-#if GTK_CHECK_VERSION (3, 0, 0)
res = gtk_builder_add_from_file (dialog->ui, UIDIR "/mate-screenshot-gtk3.ui", &error);
-#else
- res = gtk_builder_add_from_file (dialog->ui, UIDIR "/mate-screenshot.ui", &error);
-#endif
dialog->screenshot = screenshot;
@@ -309,16 +241,9 @@ screenshot_dialog_new (GdkPixbuf *screenshot,
(gfloat) gdk_pixbuf_get_height (screenshot),
FALSE);
g_signal_connect (toplevel, "key_press_event", G_CALLBACK (on_toplevel_key_press_event), dialog);
-#if GTK_CHECK_VERSION (3, 0, 0)
g_signal_connect (preview_darea, "draw", G_CALLBACK (on_preview_draw), dialog);
-#else
- g_signal_connect (preview_darea, "expose_event", G_CALLBACK (on_preview_expose_event), dialog);
-#endif
g_signal_connect (preview_darea, "button_press_event", G_CALLBACK (on_preview_button_press_event), dialog);
g_signal_connect (preview_darea, "button_release_event", G_CALLBACK (on_preview_button_release_event), dialog);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- g_signal_connect (preview_darea, "configure_event", G_CALLBACK (on_preview_configure_event), dialog);
-#endif
if (take_window_shot)
gtk_frame_set_shadow_type (GTK_FRAME (aspect_frame), GTK_SHADOW_NONE);
@@ -438,11 +363,7 @@ screenshot_dialog_set_busy (ScreenshotDialog *dialog,
/* Change cursor to busy */
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
gdk_window_set_cursor (gtk_widget_get_window (toplevel), cursor);
-#if GTK_CHECK_VERSION (3, 0, 0)
g_object_unref (cursor);
-#else
- gdk_cursor_unref (cursor);
-#endif
}
else
{
diff --git a/mate-screenshot/src/screenshot-utils.c b/mate-screenshot/src/screenshot-utils.c
index 4c1f4f7e..5876eeb3 100644
--- a/mate-screenshot/src/screenshot-utils.c
+++ b/mate-screenshot/src/screenshot-utils.c
@@ -30,18 +30,6 @@
#include <X11/extensions/shape.h>
#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define GdkRegion cairo_region_t
-#define gdk_region_new cairo_region_create
-#define gdk_region_destroy cairo_region_destroy
-#define gdk_region_rectangle cairo_region_create_rectangle
-#define gdk_region_offset cairo_region_translate
-#define gdk_region_intersect cairo_region_intersect
-#define gdk_region_subtract cairo_region_subtract
-#define gdk_region_union_with_rect cairo_region_union_rectangle
-#define gdk_cursor_unref g_object_unref
-#endif
-
static GtkWidget *selection_window;
#define SELECTION_NAME "_MATE_PANEL_SCREENSHOT"
@@ -240,26 +228,18 @@ GdkWindow *
screenshot_find_current_window ()
{
GdkWindow *current_window;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkDeviceManager *manager;
GdkDevice *device;
-#endif
current_window = screenshot_find_active_window ();
-#if GTK_CHECK_VERSION (3, 0, 0)
manager = gdk_display_get_device_manager (gdk_display_get_default ());
device = gdk_device_manager_get_client_pointer (manager);
-#endif
/* If there's no active window, we fall back to returning the
* window that the cursor is in.
*/
if (!current_window)
-#if GTK_CHECK_VERSION (3, 0, 0)
current_window = gdk_device_get_window_at_position (device, NULL, NULL);
-#else
- current_window = gdk_window_at_pointer (NULL, NULL);
-#endif
if (current_window)
{
@@ -330,38 +310,24 @@ select_area_motion_notify (GtkWidget *window,
/* Shape the window to make only the outline visible */
if (draw_rect.width > 2 && draw_rect.height > 2)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_region_t *region, *region2;
cairo_rectangle_int_t region_rect = {
-#else
- GdkRegion *region, *region2;
- GdkRectangle region_rect = {
-#endif
0, 0,
draw_rect.width - 2, draw_rect.height - 2
};
-#if GTK_CHECK_VERSION (3, 0, 0)
region = cairo_region_create_rectangle (&region_rect);
-#else
- region = gdk_region_rectangle (&region_rect);
-#endif
region_rect.x++;
region_rect.y++;
region_rect.width -= 2;
region_rect.height -= 2;
-#if GTK_CHECK_VERSION (3, 0, 0)
region2 = cairo_region_create_rectangle (&region_rect);
cairo_region_subtract (region, region2);
-#else
- region2 = gdk_region_rectangle (&region_rect);
- gdk_region_subtract (region, region2);
-#endif
gdk_window_shape_combine_region (gdkwindow, region, 0, 0);
- gdk_region_destroy (region);
- gdk_region_destroy (region2);
+ cairo_region_destroy (region);
+ cairo_region_destroy (region2);
}
else
gdk_window_shape_combine_region (gdkwindow, NULL, 0, 0);
@@ -407,41 +373,18 @@ select_area_key_press (GtkWidget *window,
static gboolean
-#if GTK_CHECK_VERSION (3, 0, 0)
draw (GtkWidget *window, cairo_t *cr, gpointer unused)
-#else
-expose (GtkWidget *window, GdkEventExpose *event, gpointer unused)
-#endif
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkStyleContext *style;
style = gtk_widget_get_style_context (window);
-#else
- GtkAllocation allocation;
- GtkStyle *style;
- cairo_t *cr;
-
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
- style = gtk_widget_get_style (window);
-#endif
if (gtk_widget_get_app_paintable (window))
{
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_set_line_width (cr, 1.0);
-
- gtk_widget_get_allocation (window, &allocation);
-#endif
-
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba (cr, 0, 0, 0, 0);
cairo_paint (cr);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_style_context_save (style);
gtk_style_context_add_class (style, GTK_STYLE_CLASS_RUBBERBAND);
@@ -455,27 +398,8 @@ expose (GtkWidget *window, GdkEventExpose *event, gpointer unused)
gtk_widget_get_allocated_height (window));
gtk_style_context_restore (style);
-#else
- cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
- gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]);
- cairo_paint_with_alpha (cr, 0.25);
-
- cairo_rectangle (cr,
- allocation.x + 0.5, allocation.y + 0.5,
- allocation.width - 1, allocation.height - 1);
- cairo_stroke (cr);
- }
- else
- {
- gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]);
- cairo_paint (cr);
-#endif
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_destroy (cr);
-#endif
-
return TRUE;
}
@@ -485,27 +409,14 @@ create_select_window (void)
GdkScreen *screen = gdk_screen_get_default ();
GtkWidget *window = gtk_window_new (GTK_WINDOW_POPUP);
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkVisual *visual = gdk_screen_get_rgba_visual (screen);
if (gdk_screen_is_composited (screen) && visual)
{
gtk_widget_set_visual (window, visual);
gtk_widget_set_app_paintable (window, TRUE);
}
-#else
- GdkColormap *colormap = gdk_screen_get_rgba_colormap (screen);
- if (gdk_screen_is_composited (screen) && colormap)
- {
- gtk_widget_set_colormap (window, colormap);
- gtk_widget_set_app_paintable (window, TRUE);
- }
-#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
g_signal_connect (window, "draw", G_CALLBACK (draw), NULL);
-#else
- g_signal_connect (window, "expose-event", G_CALLBACK (expose), NULL);
-#endif
gtk_window_move (GTK_WINDOW (window), -100, -100);
gtk_window_resize (GTK_WINDOW (window), 10, 10);
@@ -535,11 +446,9 @@ screenshot_select_area_async (SelectAreaCallback callback)
{
GdkDisplay *display;
GdkCursor *cursor;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkDeviceManager *manager;
GdkDevice *pointer, *keyboard;
GdkGrabStatus res;
-#endif
select_area_filter_data data;
GdkRectangle *rectangle;
CallbackData *cb_data;
@@ -562,7 +471,6 @@ screenshot_select_area_async (SelectAreaCallback callback)
display = gdk_display_get_default ();
cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR);
-#if GTK_CHECK_VERSION (3, 0, 0)
manager = gdk_display_get_device_manager (display);
pointer = gdk_device_manager_get_client_pointer (manager);
keyboard = gdk_device_get_associated_device (pointer);
@@ -593,42 +501,13 @@ screenshot_select_area_async (SelectAreaCallback callback)
goto out;
}
-#else
-
- if (gdk_pointer_grab (gtk_widget_get_window (data.window), FALSE,
- GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK,
- NULL, cursor,
- GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
- {
- gdk_cursor_unref (cursor);
- goto out;
- }
-
- if (gdk_keyboard_grab (gtk_widget_get_window (data.window), FALSE, GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
- {
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- gdk_cursor_unref (cursor);
- goto out;
- }
-
-#endif
-
gtk_main ();
-#if GTK_CHECK_VERSION (3, 0, 0)
-
gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
-#else
-
- gdk_keyboard_ungrab (GDK_CURRENT_TIME);
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
-
-#endif
-
gtk_widget_destroy (data.window);
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
gdk_flush ();
out:
@@ -664,39 +543,23 @@ find_wm_window (Window xid)
while (TRUE);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static cairo_region_t *
-#else
-static GdkRegion *
-#endif
make_region_with_monitors (GdkScreen *screen)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_region_t *region;
-#else
- GdkRegion *region;
-#endif
int num_monitors;
int i;
num_monitors = gdk_screen_get_n_monitors (screen);
-#if GTK_CHECK_VERSION (3, 0, 0)
region = cairo_region_create ();
-#else
- region = gdk_region_new ();
-#endif
for (i = 0; i < num_monitors; i++)
{
GdkRectangle rect;
gdk_screen_get_monitor_geometry (screen, i, &rect);
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_region_union_rectangle (region, &rect);
-#else
- gdk_region_union_with_rect (region, &rect);
-#endif
}
return region;
@@ -743,7 +606,6 @@ blank_rectangle_in_pixbuf (GdkPixbuf *pixbuf, GdkRectangle *rect)
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
blank_region_in_pixbuf (GdkPixbuf *pixbuf, cairo_region_t *region)
{
int n_rects;
@@ -752,17 +614,6 @@ blank_region_in_pixbuf (GdkPixbuf *pixbuf, cairo_region_t *region)
cairo_rectangle_int_t pixbuf_rect;
n_rects = cairo_region_num_rectangles (region);
-#else
-blank_region_in_pixbuf (GdkPixbuf *pixbuf, GdkRegion *region)
-{
- GdkRectangle *rects;
- int n_rects;
- int i;
- int width, height;
- GdkRectangle pixbuf_rect;
-
- gdk_region_get_rectangles (region, &rects, &n_rects);
-#endif
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
@@ -774,22 +625,13 @@ blank_region_in_pixbuf (GdkPixbuf *pixbuf, GdkRegion *region)
for (i = 0; i < n_rects; i++)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_rectangle_int_t rect, dest;
cairo_region_get_rectangle (region, i, &rect);
if (gdk_rectangle_intersect (&rect, &pixbuf_rect, &dest))
-#else
- GdkRectangle dest;
-
- if (gdk_rectangle_intersect (rects + i, &pixbuf_rect, &dest))
-#endif
blank_rectangle_in_pixbuf (pixbuf, &dest);
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
- g_free (rects);
-#endif
}
/* When there are multiple monitors with different resolutions, the visible area
@@ -802,15 +644,9 @@ static void
mask_monitors (GdkPixbuf *pixbuf, GdkWindow *root_window)
{
GdkScreen *screen;
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_region_t *region_with_monitors;
cairo_region_t *invisible_region;
cairo_rectangle_int_t rect;
-#else
- GdkRegion *region_with_monitors;
- GdkRegion *invisible_region;
- GdkRectangle rect;
-#endif
screen = gdk_window_get_screen (root_window);
@@ -821,7 +657,6 @@ mask_monitors (GdkPixbuf *pixbuf, GdkWindow *root_window)
rect.width = gdk_screen_get_width (screen);
rect.height = gdk_screen_get_height (screen);
-#if GTK_CHECK_VERSION (3, 0, 0)
invisible_region = cairo_region_create_rectangle (&rect);
cairo_region_subtract (invisible_region, region_with_monitors);
@@ -829,15 +664,6 @@ mask_monitors (GdkPixbuf *pixbuf, GdkWindow *root_window)
cairo_region_destroy (region_with_monitors);
cairo_region_destroy (invisible_region);
-#else
- invisible_region = gdk_region_rectangle (&rect);
- gdk_region_subtract (invisible_region, region_with_monitors);
-
- blank_region_in_pixbuf (pixbuf, invisible_region);
-
- gdk_region_destroy (region_with_monitors);
- gdk_region_destroy (invisible_region);
-#endif
}
GdkPixbuf *
@@ -905,15 +731,9 @@ screenshot_get_pixbuf (GdkWindow *window,
height = rectangle->height;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
screenshot = gdk_pixbuf_get_from_window (root,
x_orig, y_orig,
width, height);
-#else
- screenshot = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
- x_orig, y_orig, 0, 0,
- width, height);
-#endif
/*
* Masking currently only works properly with full-screen shots
@@ -1019,20 +839,14 @@ screenshot_get_pixbuf (GdkWindow *window,
if (cursor_pixbuf != NULL)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkDeviceManager *manager;
GdkDevice *device;
-#endif
GdkRectangle r1, r2;
gint cx, cy, xhot, yhot;
-#if GTK_CHECK_VERSION (3, 0, 0)
manager = gdk_display_get_device_manager (gdk_display_get_default ());
device = gdk_device_manager_get_client_pointer (manager);
gdk_window_get_device_position (window, device, &cx, &cy, NULL);
-#else
- gdk_window_get_pointer (window, &cx, &cy, NULL);
-#endif
sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "x_hot"), "%d", &xhot);
sscanf (gdk_pixbuf_get_option (cursor_pixbuf, "y_hot"), "%d", &yhot);
@@ -1061,7 +875,7 @@ screenshot_get_pixbuf (GdkWindow *window,
}
g_object_unref (cursor_pixbuf);
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
}