diff --git a/wmcliphist/clipboard.c b/wmcliphist/clipboard.c index 79f1055..49d6ac3 100644 --- a/wmcliphist/clipboard.c +++ b/wmcliphist/clipboard.c @@ -64,7 +64,7 @@ my_get_selection_text(GtkClipboard *clipboard, const gchar *text, gpointer } if (g_utf8_collate(text, old_content) != 0 && - !GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)->active) { + !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore))) { /* new data in clipboard */ /* store new content for future comparation */ content = g_strdup(text); @@ -83,8 +83,8 @@ my_get_selection_text(GtkClipboard *clipboard, const gchar *text, gpointer } /* when clipboard is locked, set selection owener to myself */ - if (GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)->active || - GTK_CHECK_MENU_ITEM(menu_app_clip_lock)->active) { + if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)) || + gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_lock))) { if (gtk_selection_owner_set(dock_app, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME) == 0) @@ -118,13 +118,13 @@ my_get_xselection(GtkWidget *window, GdkEvent *event) return_val(TRUE); - length = (size_t) gdk_selection_property_get(window->window, + length = (size_t) gdk_selection_property_get(gtk_widget_get_window(window), (guchar **) &content, &atom, &format); if (length > 0) { if ((length != old_content_len || memcmp(content, old_content, length) != 0) && - !GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)->active) { + !gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore))) { /* new data in clipboard */ /* store new content for future comparation */ if (old_content_len > 0) @@ -140,8 +140,8 @@ my_get_xselection(GtkWidget *window, GdkEvent *event) } /* when clipboard is locked, set selection owener to myself */ - if (GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)->active || - GTK_CHECK_MENU_ITEM(menu_app_clip_lock)->active) { + if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_ignore)) || + gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu_app_clip_lock))) { if (gtk_selection_owner_set(dock_app, GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME) == 0) diff --git a/wmcliphist/gui.c b/wmcliphist/gui.c index cdf434a..550a0d9 100644 --- a/wmcliphist/gui.c +++ b/wmcliphist/gui.c @@ -74,13 +74,13 @@ menu_item_button_released(GtkWidget *widget, return_val(TRUE); } - gtk_widget_set_style(GTK_BIN(data->menu_item)->child, + gtk_widget_set_style(gtk_bin_get_child(GTK_BIN(data->menu_item)), style_locked); data->locked = 1; locked_count++; } else { - gtk_widget_set_style(GTK_BIN(data->menu_item)->child, + gtk_widget_set_style(gtk_bin_get_child(GTK_BIN(data->menu_item)), style_normal); data->locked = 0; locked_count--; @@ -217,24 +217,24 @@ menu_item_add(gchar *content, gint locked, GtkWidget *target_menu) hist_item->menu = target_menu; if (locked == 1) { - gtk_widget_set_style(GTK_BIN(hist_item->menu_item)->child, + gtk_widget_set_style(gtk_bin_get_child(GTK_BIN(hist_item->menu_item)), style_locked); locked_count++; } /* add to menu */ - gtk_menu_insert(GTK_MENU(hist_item->menu), hist_item->menu_item, 1); + gtk_menu_shell_insert(GTK_MENU_SHELL(hist_item->menu), hist_item->menu_item, 1); /* connect actions to signals */ - gtk_signal_connect(GTK_OBJECT(hist_item->menu_item), + g_signal_connect(G_OBJECT(hist_item->menu_item), "button-release-event", - GTK_SIGNAL_FUNC(menu_item_button_released), + G_CALLBACK(menu_item_button_released), (gpointer)hist_item); - gtk_signal_connect(GTK_OBJECT(hist_item->menu_item), + g_signal_connect(G_OBJECT(hist_item->menu_item), "activate", - GTK_SIGNAL_FUNC(menu_item_activated), + G_CALLBACK(menu_item_activated), (gpointer)hist_item); gtk_widget_show(hist_item->menu_item); @@ -283,7 +283,7 @@ menu_app_item_click(GtkWidget *menuitem, gpointer data) history_free(); rcconfig_free(); - gtk_exit(0); + exit(0); return_val(TRUE); } return_val(FALSE); @@ -372,7 +372,7 @@ static gboolean dialog_key_press_yes(GtkWidget *button, GdkEventKey *event, gpointer data) { begin_func("dialog_key_press_yes"); - return dialog_handle_key_press_event(event, data, GDK_Return); + return dialog_handle_key_press_event(event, data, GDK_KEY_Return); } @@ -381,7 +381,7 @@ static gboolean dialog_key_press_no(GtkWidget *button, GdkEventKey *event, gpointer data) { begin_func("dialog_key_press_no"); - return dialog_handle_key_press_event(event, data, GDK_Escape); + return dialog_handle_key_press_event(event, data, GDK_KEY_Escape); } @@ -408,43 +408,43 @@ show_message(gchar *message, char *title, /* create buttons and set signals */ button_0 = gtk_button_new_with_label(b0_text); - gtk_signal_connect(GTK_OBJECT(button_0), "clicked", - GTK_SIGNAL_FUNC(dialog_button_press), + g_signal_connect(G_OBJECT(button_0), "clicked", + G_CALLBACK(dialog_button_press), GINT_TO_POINTER(0)); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), button_0); if (!b2_text) { - gtk_signal_connect(GTK_OBJECT(dialog), "key-press-event", - GTK_SIGNAL_FUNC(dialog_key_press_yes), + g_signal_connect(G_OBJECT(dialog), "key-press-event", + G_CALLBACK(dialog_key_press_yes), GINT_TO_POINTER(0)); } if (b1_text != NULL) { button_1 = gtk_button_new_with_label(b1_text); - gtk_signal_connect(GTK_OBJECT(button_1), "clicked", - GTK_SIGNAL_FUNC(dialog_button_press), + g_signal_connect(G_OBJECT(button_1), "clicked", + G_CALLBACK(dialog_button_press), GINT_TO_POINTER(1)); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), button_1); if (!b2_text) { - gtk_signal_connect(GTK_OBJECT(dialog), "key-press-event", - GTK_SIGNAL_FUNC(dialog_key_press_no), + g_signal_connect(G_OBJECT(dialog), "key-press-event", + G_CALLBACK(dialog_key_press_no), GINT_TO_POINTER(1)); } } if (b2_text) { button_2 = gtk_button_new_with_label(b2_text); - gtk_signal_connect(GTK_OBJECT(button_2), "clicked", - GTK_SIGNAL_FUNC(dialog_button_press), + g_signal_connect(G_OBJECT(button_2), "clicked", + G_CALLBACK(dialog_button_press), GINT_TO_POINTER(2)); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), button_2); } /* add the label, and show everything we've added to the dialog. */ gtk_misc_set_padding(>K_LABEL(label)->misc, 10, 10); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); + gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), label); gtk_widget_show_all(dialog); /* set window title */ diff --git a/wmcliphist/hotkeys.c b/wmcliphist/hotkeys.c index f9260d4..7ad8b09 100644 --- a/wmcliphist/hotkeys.c +++ b/wmcliphist/hotkeys.c @@ -29,7 +29,7 @@ global_keys_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) if (xevent->type == KeyPress) { if (xevent->xkey.keycode == - XKeysymToKeycode(GDK_DISPLAY(), menukey) && + XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), menukey) && xevent->xkey.state & menukey_mask) { /* popup history menu */ gtk_menu_popup(GTK_MENU(menu_hist), @@ -39,7 +39,7 @@ global_keys_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) GDK_CURRENT_TIME); return_val(GDK_FILTER_REMOVE); } else if (xevent->xkey.keycode == - XKeysymToKeycode(GDK_DISPLAY(), prev_item_key) + XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), prev_item_key) && xevent->xkey.state & prev_item_mask) { /* switch first two history items */ GList *second; @@ -55,7 +55,7 @@ global_keys_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) return_val(GDK_FILTER_REMOVE); } else if (xevent->xkey.keycode == - XKeysymToKeycode(GDK_DISPLAY(), exec_item_key) && + XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), exec_item_key) && xevent->xkey.state & exec_item_mask) { /* exec command on current item */ if (exec_hotkey) { @@ -108,7 +108,7 @@ hotkey_parse(char *hotkey, guint *key, guint *mask) } } - if ((*key = gdk_keyval_from_name(tmp)) == GDK_VoidSymbol) { + if ((*key = gdk_keyval_from_name(tmp)) == GDK_KEY_VoidSymbol) { g_free(tmp); return_val(-1); } @@ -120,28 +120,28 @@ hotkey_parse(char *hotkey, guint *key, guint *mask) #define grab_key(keysym, basemask) \ - XGrabKey(GDK_DISPLAY(), XKeysymToKeycode(GDK_DISPLAY(), keysym), \ + XGrabKey(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym), \ basemask, GDK_ROOT_WINDOW(), True, GrabModeAsync, \ GrabModeAsync); \ - XGrabKey(GDK_DISPLAY(), XKeysymToKeycode(GDK_DISPLAY(), keysym), \ + XGrabKey(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym), \ basemask | LockMask, GDK_ROOT_WINDOW(), True, \ GrabModeAsync, GrabModeAsync); \ - XGrabKey(GDK_DISPLAY(), XKeysymToKeycode(GDK_DISPLAY(), keysym), \ + XGrabKey(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym), \ basemask | Mod2Mask, GDK_ROOT_WINDOW(), True, \ GrabModeAsync, GrabModeAsync); \ - XGrabKey(GDK_DISPLAY(), XKeysymToKeycode(GDK_DISPLAY(), keysym), \ + XGrabKey(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym), \ basemask | Mod2Mask | LockMask, GDK_ROOT_WINDOW(), \ True, GrabModeAsync, GrabModeAsync); #define ungrab_key(keysym, basemask) \ - XUngrabKey(GDK_DISPLAY(), XKeysymToKeycode(GDK_DISPLAY(), keysym), \ + XUngrabKey(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym), \ basemask, GDK_ROOT_WINDOW()); \ - XUngrabKey(GDK_DISPLAY(), XKeysymToKeycode(GDK_DISPLAY(), keysym), \ + XUngrabKey(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym), \ basemask | LockMask, GDK_ROOT_WINDOW()); \ - XUngrabKey(GDK_DISPLAY(), XKeysymToKeycode(GDK_DISPLAY(), keysym), \ + XUngrabKey(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym), \ basemask | Mod2Mask, GDK_ROOT_WINDOW()); \ - XUngrabKey(GDK_DISPLAY(), XKeysymToKeycode(GDK_DISPLAY(), keysym), \ + XUngrabKey(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XKeysymToKeycode(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), keysym), \ basemask | Mod2Mask | LockMask, GDK_ROOT_WINDOW()); @@ -178,7 +178,7 @@ hotkeys_init() hotkey_parse(DEF_EXEC_ITEM_KEY, &exec_item_key, &exec_item_mask); } - gdk_window_add_filter(GDK_ROOT_PARENT(), global_keys_filter, NULL); + gdk_window_add_filter(gdk_get_default_root_window(), global_keys_filter, NULL); grab_key(menukey, menukey_mask); grab_key(prev_item_key, prev_item_mask); grab_key(exec_item_key, exec_item_mask); diff --git a/wmcliphist/wmcliphist.c b/wmcliphist/wmcliphist.c index 8452d83..399c22d 100644 --- a/wmcliphist/wmcliphist.c +++ b/wmcliphist/wmcliphist.c @@ -57,7 +57,7 @@ static void wmcliphist_exit(gint code) { begin_func("wmcliphist_exit"); - gtk_exit(code); + exit(code); return_void(); } @@ -195,7 +195,6 @@ main(int argc, char **argv) signal(SIGCHLD, SIG_IGN); /* initialize Gtk */ - gtk_set_locale(); gtk_init(&argc, &argv); @@ -209,7 +208,7 @@ main(int argc, char **argv) /* create icon_mask */ if (icon_size == 60) { /* 60x60 icon */ - icon_mask = gdk_bitmap_create_from_data(main_window->window, + icon_mask = gdk_bitmap_create_from_data(gtk_widget_get_window(main_window), (gchar *) ico_60x60_mask_bits, ico_60x60_mask_width, ico_60x60_mask_height); @@ -223,7 +222,7 @@ main(int argc, char **argv) } } else if (icon_size == 40) { /* 40x40 icon */ - icon_mask = gdk_bitmap_create_from_data(main_window->window, + icon_mask = gdk_bitmap_create_from_data(gtk_widget_get_window(main_window), (gchar *) ico_40x40_mask_bits, ico_40x40_mask_width, ico_40x40_mask_height); @@ -237,7 +236,7 @@ main(int argc, char **argv) } } else if (icon_size == 30) { /* 30x30 icon */ - icon_mask = gdk_bitmap_create_from_data(main_window->window, + icon_mask = gdk_bitmap_create_from_data(gtk_widget_get_window(main_window), (gchar *) ico_30x30_mask_bits, ico_30x30_mask_width, ico_30x30_mask_height); @@ -251,7 +250,7 @@ main(int argc, char **argv) } } else { /* 16x16 icon */ - icon_mask = gdk_bitmap_create_from_data(main_window->window, + icon_mask = gdk_bitmap_create_from_data(gtk_widget_get_window(main_window), (gchar *) ico_16x16_mask_bits, ico_16x16_mask_width, ico_16x16_mask_height); @@ -259,9 +258,9 @@ main(int argc, char **argv) icon_data = ico_16x16_xpm; } - icon = gdk_pixmap_create_from_xpm_d(main_window->window, + icon = gdk_pixmap_create_from_xpm_d(gtk_widget_get_window(main_window), NULL, NULL, icon_data); - pixmap = gtk_pixmap_new(icon, icon_mask); + pixmap = gtk_image_new_from_pixmap(icon, icon_mask); gtk_widget_show(pixmap); gtk_container_add(GTK_CONTAINER(dock_app), pixmap); } @@ -271,7 +270,7 @@ main(int argc, char **argv) menu_hist = gtk_menu_new(); gtk_menu_set_title(GTK_MENU(menu_hist), "Clipboard history"); menu_title = gtk_tearoff_menu_item_new(); - gtk_menu_append(GTK_MENU(menu_hist), menu_title); + gtk_menu_shell_append(GTK_MENU_SHELL(menu_hist), menu_title); gtk_widget_show(menu_title); gtk_widget_show(menu_hist); @@ -280,23 +279,23 @@ main(int argc, char **argv) menu_app = gtk_menu_new(); menu_app_clip_lock = gtk_check_menu_item_new_with_label("Clipboard lock"); - gtk_menu_append(GTK_MENU(menu_app), menu_app_clip_lock); + gtk_menu_shell_append(GTK_MENU_SHELL(menu_app), menu_app_clip_lock); menu_app_clip_ignore = gtk_check_menu_item_new_with_label("Clipboard ignore"); - gtk_menu_append(GTK_MENU(menu_app), menu_app_clip_ignore); + gtk_menu_shell_append(GTK_MENU_SHELL(menu_app), menu_app_clip_ignore); menu_app_save = gtk_menu_item_new_with_label("Save history"); - gtk_menu_append(GTK_MENU(menu_app), menu_app_save); - gtk_signal_connect(GTK_OBJECT(menu_app_save), + gtk_menu_shell_append(GTK_MENU_SHELL(menu_app), menu_app_save); + g_signal_connect(G_OBJECT(menu_app_save), "activate", - GTK_SIGNAL_FUNC(menu_app_item_click), + G_CALLBACK(menu_app_item_click), GINT_TO_POINTER(0)); menu_app_exit = gtk_menu_item_new_with_label("Exit"); - gtk_menu_append(GTK_MENU(menu_app), menu_app_exit); - gtk_signal_connect(GTK_OBJECT(menu_app_exit), + gtk_menu_shell_append(GTK_MENU_SHELL(menu_app), menu_app_exit); + g_signal_connect(G_OBJECT(menu_app_exit), "activate", - GTK_SIGNAL_FUNC(menu_app_item_click), + G_CALLBACK(menu_app_item_click), GINT_TO_POINTER(1)); gtk_widget_show_all(menu_app); @@ -310,14 +309,14 @@ main(int argc, char **argv) strcmp(action->command, "-") != 0) { action->menu_item = gtk_menu_item_new_with_label( action->command); - gtk_menu_append(GTK_MENU(menu_hist), + gtk_menu_shell_append(GTK_MENU_SHELL(menu_hist), action->menu_item); action->submenu = gtk_menu_new(); gtk_menu_item_set_submenu( GTK_MENU_ITEM(action->menu_item), action->submenu); menu_title = gtk_tearoff_menu_item_new(); - gtk_menu_append(GTK_MENU(action->submenu), menu_title); + gtk_menu_shell_append(GTK_MENU_SHELL(action->submenu), menu_title); gtk_widget_show(menu_title); gtk_widget_show(action->menu_item); gtk_widget_show(action->submenu); @@ -335,7 +334,7 @@ main(int argc, char **argv) separator = gtk_menu_item_new(); gtk_widget_show(separator); - gtk_menu_insert(GTK_MENU(menu_hist), separator, 1); + gtk_menu_shell_insert(GTK_MENU_SHELL(menu_hist), separator, 1); } /* prepare colors and styles */ @@ -365,43 +364,44 @@ main(int argc, char **argv) "history will be lost. May I continue?", "Warning", "Yes", "No", NULL) == 1) { rcconfig_free(); - gtk_exit(1); + exit(1); } } else if (errno != E_OPEN) { rcconfig_free(); fprintf(stderr, "cannot load history (%d)\n", errno); - gtk_exit(1); + exit(1); } } if (dump_only) { rcconfig_free(); - gtk_exit(1); + exit(1); } if (icon_size) { /* connect signal for menu popup */ - gtk_signal_connect(GTK_OBJECT(dock_app), - "event", - GTK_SIGNAL_FUNC(button_press), - GTK_OBJECT(menu_hist)); + gtk_widget_add_events(dock_app, GDK_BUTTON_PRESS_MASK); + g_signal_connect(G_OBJECT(dock_app), + "event", + G_CALLBACK(button_press), + G_OBJECT(menu_hist)); - gdk_window_shape_combine_mask(main_window->window, icon_mask, 0, 0); - gdk_window_shape_combine_mask(dock_app->window, icon_mask, 0, 0); + gdk_window_shape_combine_mask(gtk_widget_get_window(main_window), icon_mask, 0, 0); + gdk_window_shape_combine_mask(gtk_widget_get_window(dock_app), icon_mask, 0, 0); } /* run clipboard monitor */ - gtk_signal_connect(GTK_OBJECT(main_window), + g_signal_connect(G_OBJECT(main_window), "selection_received", - GTK_SIGNAL_FUNC(my_get_xselection), + G_CALLBACK(my_get_xselection), NULL); - gtk_timeout_add(250, time_conv_select, NULL); + g_timeout_add(250, time_conv_select, NULL); /* run autosave timer */ if (autosave_period > 0) - gtk_timeout_add(autosave_period * 1000, history_autosave, NULL); + g_timeout_add(autosave_period * 1000, history_autosave, NULL); /* setup everything for supplying selection to other apps */ @@ -410,14 +410,14 @@ main(int argc, char **argv) GDK_SELECTION_TYPE_STRING, 1); - gtk_signal_connect(GTK_OBJECT(dock_app), + g_signal_connect(G_OBJECT(dock_app), "selection_get", - GTK_SIGNAL_FUNC(selection_handle), + G_CALLBACK(selection_handle), NULL); - gtk_signal_connect(GTK_OBJECT(dock_app), + g_signal_connect(G_OBJECT(dock_app), "destroy", - GTK_SIGNAL_FUNC(wmcliphist_exit), + G_CALLBACK(wmcliphist_exit), NULL);