Skip to content

Commit

Permalink
Port to Gtk3.
Browse files Browse the repository at this point in the history
  • Loading branch information
thegala committed Jan 23, 2020
1 parent 73f28da commit fac69ff
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
6 changes: 3 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
18 changes: 9 additions & 9 deletions src/eggaccelerators.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/keybinder.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ 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);
} else {
XUngrabKey (GDK_WINDOW_XDISPLAY (rootwin),
binding->keycode,
binding->modifiers | mod_masks [i],
GDK_WINDOW_XWINDOW (rootwin));
GDK_WINDOW_XID (rootwin));
}
}
}
Expand Down Expand Up @@ -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;

Expand Down
24 changes: 17 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions src/preferences.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit fac69ff

Please sign in to comment.