From fac69ff705b8ecec8a31def9292b5d30fe6acce2 Mon Sep 17 00:00:00 2001 From: thegala <10523048+thegala@users.noreply.github.com> Date: Thu, 23 Jan 2020 01:28:02 +0100 Subject: [PATCH] Port to Gtk3. --- README | 6 +++--- configure.ac | 4 ++-- src/eggaccelerators.c | 18 +++++++++--------- src/keybinder.c | 6 +++--- src/main.c | 24 +++++++++++++++++------- src/preferences.c | 10 +++++----- 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/README b/README index 6dc09fc..036c5f1 100644 --- a/README +++ b/README @@ -20,7 +20,7 @@ How to compile and install parcellite ------------------------------------------------------------------------------- Requirements: - * gtk+ >= 2.10.0 + * gtk+ >= 3.10.0 Download the parcellite source code, then: $ tar zxvf parcellite-x.y.z.tar.gz @@ -48,9 +48,9 @@ GNU make is usually available on BSD systems by installing the "gmake" package. the configure script needs to be invoked as follows on OpenBSD: - LIBS="`pkg-config --libs gtk+-2.0`" ./configure + LIBS="`pkg-config --libs gtk+-3.0`" ./configure -If not, configure will report that the gtk >= 2.10.0 requirement is not met on OpenBSD. +If not, configure will report that the gtk >= 3.10.0 requirement is not met on OpenBSD. Release instructions: 1) run rel.sh - it copies the trunk to the tag the script asks the developer for. diff --git a/configure.ac b/configure.ac index aef9ea1..3fed56a 100644 --- a/configure.ac +++ b/configure.ac @@ -87,10 +87,10 @@ AC_SUBST(X11_LIBS, -lX11) # Checks for libraries. # ------------------------------------------------------------------------------- # AC_CHECK_LIB(pthread, pthread_create) -pkg_modules="gtk+-2.0 >= 2.10.0" +pkg_modules="gtk+-3.0 >= 3.10.0" PKG_CHECK_MODULES([GTK], [$pkg_modules]) #keep pkg-config from being called -GTK_LIBS=`$PKG_CONFIG --libs gtk+-2.0|sed 's/.* \(-lgtk-[[^ ]]*\) .*/\1/'` +GTK_LIBS=`$PKG_CONFIG --libs gtk+-3.0|sed 's/.* \(-lgtk-[[^ ]]*\) .*/\1/'` gtk_libs=`echo "$GTK_LIBS"|sed 's/-l//'` #gtk_libs=`$PKG_CONFIG --libs gtk+-2.0|sed 's/.* -l\(gtk-[[^ ]]*\) .*/\1/'` #echo "gtk_libs = '$gtk_libs'" diff --git a/src/eggaccelerators.c b/src/eggaccelerators.c index de1f545..4df367e 100644 --- a/src/eggaccelerators.c +++ b/src/eggaccelerators.c @@ -537,20 +537,20 @@ static void reload_modmap (GdkKeymap *keymap, EggModmap *modmap) j = 0; while (j < n_entries) { - if (keyvals[j] == GDK_Num_Lock) + if (keyvals[j] == GDK_KEY_Num_Lock) mask |= EGG_VIRTUAL_NUM_LOCK_MASK; - else if (keyvals[j] == GDK_Scroll_Lock) + else if (keyvals[j] == GDK_KEY_Scroll_Lock) mask |= EGG_VIRTUAL_SCROLL_LOCK_MASK; - else if (keyvals[j] == GDK_Meta_L || - keyvals[j] == GDK_Meta_R) + else if (keyvals[j] == GDK_KEY_Meta_L || + keyvals[j] == GDK_KEY_Meta_R) mask |= EGG_VIRTUAL_META_MASK; - else if (keyvals[j] == GDK_Hyper_L || - keyvals[j] == GDK_Hyper_R) + else if (keyvals[j] == GDK_KEY_Hyper_L || + keyvals[j] == GDK_KEY_Hyper_R) mask |= EGG_VIRTUAL_HYPER_MASK; - else if (keyvals[j] == GDK_Super_L || - keyvals[j] == GDK_Super_R) + else if (keyvals[j] == GDK_KEY_Super_L || + keyvals[j] == GDK_KEY_Super_R) mask |= EGG_VIRTUAL_SUPER_MASK; - else if (keyvals[j] == GDK_Mode_switch) + else if (keyvals[j] == GDK_KEY_Mode_switch) mask |= EGG_VIRTUAL_MODE_SWITCH_MASK; ++j; diff --git a/src/keybinder.c b/src/keybinder.c index 7f40999..fdc2525 100644 --- a/src/keybinder.c +++ b/src/keybinder.c @@ -86,7 +86,7 @@ grab_ungrab_with_ignorable_modifiers (GdkWindow *rootwin, XGrabKey (GDK_WINDOW_XDISPLAY (rootwin), binding->keycode, binding->modifiers | mod_masks [i], - GDK_WINDOW_XWINDOW (rootwin), + GDK_WINDOW_XID (rootwin), False, GrabModeAsync, GrabModeAsync); @@ -94,7 +94,7 @@ grab_ungrab_with_ignorable_modifiers (GdkWindow *rootwin, XUngrabKey (GDK_WINDOW_XDISPLAY (rootwin), binding->keycode, binding->modifiers | mod_masks [i], - GDK_WINDOW_XWINDOW (rootwin)); + GDK_WINDOW_XID (rootwin)); } } } @@ -309,7 +309,7 @@ keybinder_is_modifier (guint keycode) XModifierKeymap *mod_keymap; gboolean retval = FALSE; - mod_keymap = XGetModifierMapping (gdk_display); + mod_keymap = XGetModifierMapping (GDK_DISPLAY_XDISPLAY(gdk_display_get_default())); map_size = 8 * mod_keymap->max_keypermod; diff --git a/src/main.c b/src/main.c index 9fcdd04..b0ddddf 100644 --- a/src/main.c +++ b/src/main.c @@ -396,7 +396,17 @@ gchar *update_clipboard(GtkClipboard *clip,gchar *intext, gint mode) if( H_MODE_CHECK==mode &&clip == primary){/*fix auto-deselect of text in applications like DevHelp and LyX*/ - gdk_window_get_pointer(NULL, NULL, NULL, &button_state); + GdkScreen *screen = gdk_screen_get_default(); + if (screen) + { + GdkDisplay *display = gdk_screen_get_display(screen); + GdkWindow *window = gdk_screen_get_root_window(screen); + GdkSeat *seat = gdk_display_get_default_seat(display); + + gdk_window_get_device_position(window, gdk_seat_get_pointer(seat), NULL, + NULL, &button_state); + } + /* gdk_window_get_pointer(NULL, NULL, NULL, &button_state); */ if ( button_state & (GDK_BUTTON1_MASK|GDK_SHIFT_MASK) ) /**button down, done. */ goto done; } @@ -704,7 +714,7 @@ static void action_exit(GPid pid, gint status, gpointer data) g_spawn_close_pid(pid); if (!have_appindicator && show_icon) { gtk_status_icon_set_from_icon_name((GtkStatusIcon*)status_icon, get_pref_string("icon_name")); - gtk_status_icon_set_tooltip((GtkStatusIcon*)status_icon, _("Clipboard Manager")); + gtk_status_icon_set_has_tooltip((GtkStatusIcon*)status_icon, _("Clipboard Manager")); } actions_lock = FALSE; } @@ -716,7 +726,7 @@ static void action_selected(GtkButton *button, gpointer user_data) actions_lock = TRUE; if (!have_appindicator && show_icon) { gtk_status_icon_set_from_stock((GtkStatusIcon*)status_icon, GTK_STOCK_EXECUTE); - gtk_status_icon_set_tooltip((GtkStatusIcon*)status_icon, _("Executing action...")); + gtk_status_icon_set_has_tooltip((GtkStatusIcon*)status_icon, _("Executing action...")); } /* Insert clipboard into command (user_data), and prepare it for execution */ gchar* clipboard_text = gtk_clipboard_wait_for_text(clipboard); @@ -811,7 +821,7 @@ static void edit_selected(GtkMenuItem *menu_item, gpointer user_data) /* Create the dialog */ GtkWidget* dialog = gtk_dialog_new_with_buttons(_("Editing Clipboard"), NULL, - (GTK_DIALOG_MODAL + GTK_DIALOG_NO_SEPARATOR), + GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); @@ -825,7 +835,7 @@ static void edit_selected(GtkMenuItem *menu_item, gpointer user_data) gtk_scrolled_window_set_policy((GtkScrolledWindow*)scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrolled_window, TRUE, TRUE, 2); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)), scrolled_window, TRUE, TRUE, 2); GtkWidget* text_view = gtk_text_view_new_with_buffer(text_buffer); gtk_text_view_set_left_margin((GtkTextView*)text_view, 2); gtk_text_view_set_right_margin((GtkTextView*)text_view, 2); @@ -1142,7 +1152,7 @@ static void show_about_dialog(GtkMenuItem *menu_item, gpointer user_data) gtk_window_set_icon((GtkWindow*)about_dialog, gtk_widget_render_icon(about_dialog, GTK_STOCK_ABOUT, -1, NULL)); - gtk_about_dialog_set_name((GtkAboutDialog*)about_dialog, "Parcellite"); + gtk_about_dialog_set_program_name((GtkAboutDialog*)about_dialog, "Parcellite"); #ifdef HAVE_CONFIG_H /**VER=555; sed "s#\(.*\)svn.*\".*#\1svn$VER\"#" config.h */ gtk_about_dialog_set_version((GtkAboutDialog*)about_dialog, VERSION); #endif @@ -2175,7 +2185,7 @@ void setup_icon( void ) if(0 == have_appindicator){/* no Indicator */ if(NULL == status_icon){ status_icon = gtk_status_icon_new_from_icon_name(get_pref_string("icon_name")); - gtk_status_icon_set_tooltip((GtkStatusIcon*)status_icon, _("Clipboard Manager")); + gtk_status_icon_set_has_tooltip((GtkStatusIcon*)status_icon, _("Clipboard Manager")); g_signal_connect((GObject*)status_icon, "activate", (GCallback)status_icon_clicked, NULL); g_signal_connect((GObject*)status_icon, "popup-menu", (GCallback)show_parcellite_menu, NULL); } else { diff --git a/src/preferences.c b/src/preferences.c index 6af0b28..5fe4383 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -1113,7 +1113,7 @@ void show_preferences(gint tab) /* Create the dialog */ GtkWidget* dialog = gtk_dialog_new_with_buttons(_("Preferences"), NULL, - (GTK_DIALOG_MODAL + GTK_DIALOG_NO_SEPARATOR), + GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); @@ -1171,10 +1171,10 @@ void show_preferences(gint tab) label = gtk_label_new(_(p->desc)); gtk_misc_set_alignment((GtkMisc*)label, 0.0, 0.50); gtk_box_pack_start((GtkBox*)hbox, label, FALSE, FALSE, 0); - p->w = gtk_combo_box_new_text(); - gtk_combo_box_append_text((GtkComboBox*)p->w, _("Beginning")); - gtk_combo_box_append_text((GtkComboBox*)p->w, _("Middle")); - gtk_combo_box_append_text((GtkComboBox*)p->w, _("End")); + p->w = gtk_combo_box_text_new(); + gtk_combo_box_text_append_text((GtkComboBox*)p->w, _("Beginning")); + gtk_combo_box_text_append_text((GtkComboBox*)p->w, _("Middle")); + gtk_combo_box_text_append_text((GtkComboBox*)p->w, _("End")); gtk_box_pack_start((GtkBox*)hbox, p->w, FALSE, FALSE, 0); gtk_box_pack_start((GtkBox*)vbox_display, frame, FALSE, FALSE, 0);