diff options
author | infirit <[email protected]> | 2014-05-20 12:45:42 +0200 |
---|---|---|
committer | infirit <[email protected]> | 2014-05-20 13:22:53 +0200 |
commit | 50ac67e11f946fb6539b30fbb86e60b94fa695d9 (patch) | |
tree | 5acef8e787da447ec51c4fd3b69f7a06cd13fbcb /src | |
parent | 0b75b3c4b4354b72b604c6313ceef97d9ecb007c (diff) | |
download | mate-terminal-50ac67e11f946fb6539b30fbb86e60b94fa695d9.tar.bz2 mate-terminal-50ac67e11f946fb6539b30fbb86e60b94fa695d9.tar.xz |
Cleanup GTK_CHECK_VERSION and unify gtk+2/3 code where possible
Always use gdk_window_get_display and GDK_WINDOW_XID
Replace GtkObject with GObject
Always use gtk_message_dialog_get_message_area (since gtk 2.22)
Unify notebook code between gtk2 and gtk3
Diffstat (limited to 'src')
-rw-r--r-- | src/terminal-screen.c | 3 | ||||
-rw-r--r-- | src/terminal-tabs-menu.c | 8 | ||||
-rw-r--r-- | src/terminal-util.c | 33 | ||||
-rw-r--r-- | src/terminal-window.c | 36 |
4 files changed, 9 insertions, 71 deletions
diff --git a/src/terminal-screen.c b/src/terminal-screen.c index 91d503f..79995dc 100644 --- a/src/terminal-screen.c +++ b/src/terminal-screen.c @@ -51,7 +51,6 @@ #if GTK_CHECK_VERSION(3, 0, 0) #include <gdk/gdkkeysyms-compat.h> - #define GDK_WINDOW_XWINDOW GDK_WINDOW_XID #endif #define URL_MATCH_CURSOR (GDK_HAND2) @@ -1413,7 +1412,7 @@ get_child_environment (TerminalScreen *screen, /* FIXME: moving the tab between windows, or the window between displays will make the next two invalid... */ if (GDK_IS_X11_DISPLAY(display)) { - g_hash_table_replace (env_table, g_strdup ("WINDOWID"), g_strdup_printf ("%ld", GDK_WINDOW_XWINDOW (gtk_widget_get_window (window)))); + g_hash_table_replace (env_table, g_strdup ("WINDOWID"), g_strdup_printf ("%ld", GDK_WINDOW_XID (gtk_widget_get_window (window)))); g_hash_table_replace (env_table, g_strdup ("DISPLAY"), g_strdup (gdk_display_get_name (display))); } #endif diff --git a/src/terminal-tabs-menu.c b/src/terminal-tabs-menu.c index 56e427b..f891d47 100644 --- a/src/terminal-tabs-menu.c +++ b/src/terminal-tabs-menu.c @@ -265,11 +265,7 @@ notebook_page_reordered_cb (GtkNotebook *notebook, static void notebook_page_switch_cb (GtkNotebook *notebook, -#if GTK_CHECK_VERSION (2, 90, 6) GtkWidget *page, -#else - gpointer page, -#endif guint position, TerminalTabsMenu *menu) { @@ -277,11 +273,7 @@ notebook_page_switch_cb (GtkNotebook *notebook, TerminalScreen *screen; GtkAction *action; -#if GTK_CHECK_VERSION (2, 90, 6) container = TERMINAL_SCREEN_CONTAINER (page); -#else - container = TERMINAL_SCREEN_CONTAINER (gtk_notebook_get_nth_page (notebook, position)); -#endif screen = terminal_screen_container_get_screen (container); action = g_object_get_data (G_OBJECT (screen), DATA_KEY); diff --git a/src/terminal-util.c b/src/terminal-util.c index 5cfa350..320afd1 100644 --- a/src/terminal-util.c +++ b/src/terminal-util.c @@ -45,10 +45,7 @@ #include "terminal-util.h" #include "terminal-window.h" -#if GTK_CHECK_VERSION(3, 0, 0) - #define GDK_WINDOW_XWINDOW GDK_WINDOW_XID - #define GDK_DRAWABLE_XID GDK_WINDOW_XID -#else +#if !GTK_CHECK_VERSION(3, 0, 0) #define gdk_error_trap_pop_ignored gdk_error_trap_pop #endif @@ -1027,11 +1024,7 @@ gboolean terminal_util_x11_get_net_wm_desktop (GdkWindow *window, guint32 *desktop) { - #if GTK_CHECK_VERSION(3, 0, 0) GdkDisplay *display = gdk_window_get_display (window); - #else - GdkDisplay *display = gdk_drawable_get_display (window); - #endif Atom type; int format; guchar *data; @@ -1039,7 +1032,7 @@ terminal_util_x11_get_net_wm_desktop (GdkWindow *window, gboolean result = FALSE; if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), - GDK_DRAWABLE_XID (window), + GDK_WINDOW_XID (window), gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"), 0, G_MAXLONG, False, AnyPropertyType, @@ -1074,11 +1067,7 @@ terminal_util_x11_set_net_wm_desktop (GdkWindow *window, * http://bugzilla.mate.org/show_bug.cgi?id=586311 asks for GTK+ * to just handle everything behind the scenes including the desktop. */ - #if GTK_CHECK_VERSION(3, 0, 0) GdkScreen *screen = gdk_window_get_screen (window); - #else - GdkScreen *screen = gdk_drawable_get_screen (window); - #endif GdkDisplay *display = gdk_screen_get_display (screen); Display *xdisplay = GDK_DISPLAY_XDISPLAY (display); char *wm_selection_name; @@ -1103,7 +1092,7 @@ terminal_util_x11_set_net_wm_desktop (GdkWindow *window, xclient.type = ClientMessage; xclient.serial = 0; xclient.send_event = True; - xclient.window = GDK_WINDOW_XWINDOW (window); + xclient.window = GDK_WINDOW_XID (window); xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"); xclient.format = 32; @@ -1114,7 +1103,7 @@ terminal_util_x11_set_net_wm_desktop (GdkWindow *window, xclient.data.l[4] = 0; XSendEvent (xdisplay, - GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)), + GDK_WINDOW_XID (gdk_screen_get_root_window (screen)), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient); @@ -1124,7 +1113,7 @@ terminal_util_x11_set_net_wm_desktop (GdkWindow *window, gulong long_desktop = desktop; XChangeProperty (xdisplay, - GDK_DRAWABLE_XID (window), + GDK_WINDOW_XID (window), gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"), XA_CARDINAL, 32, PropModeReplace, @@ -1145,11 +1134,7 @@ void terminal_util_x11_clear_demands_attention (GdkWindow *window) { - #if GTK_CHECK_VERSION(3, 0, 0) GdkScreen *screen = gdk_window_get_screen (window); - #else - GdkScreen *screen = gdk_drawable_get_screen (window); - #endif GdkDisplay *display = gdk_screen_get_display (screen); XClientMessageEvent xclient; @@ -1157,7 +1142,7 @@ terminal_util_x11_clear_demands_attention (GdkWindow *window) xclient.type = ClientMessage; xclient.serial = 0; xclient.send_event = True; - xclient.window = GDK_WINDOW_XWINDOW (window); + xclient.window = GDK_WINDOW_XID (window); xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"); xclient.format = 32; @@ -1168,7 +1153,7 @@ terminal_util_x11_clear_demands_attention (GdkWindow *window) xclient.data.l[4] = 0; XSendEvent (GDK_DISPLAY_XDISPLAY (display), - GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)), + GDK_WINDOW_XID (gdk_screen_get_root_window (screen)), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient); @@ -1186,11 +1171,7 @@ terminal_util_x11_clear_demands_attention (GdkWindow *window) gboolean terminal_util_x11_window_is_minimized (GdkWindow *window) { - #if GTK_CHECK_VERSION(3, 0, 0) GdkDisplay *display = gdk_window_get_display (window); - #else - GdkDisplay *display = gdk_drawable_get_display (window); - #endif Atom type; gint format; diff --git a/src/terminal-window.c b/src/terminal-window.c index 3c6f734..4c15774 100644 --- a/src/terminal-window.c +++ b/src/terminal-window.c @@ -152,11 +152,7 @@ static gboolean notebook_button_press_cb (GtkWidget *notebook, static gboolean notebook_popup_menu_cb (GtkWidget *notebook, TerminalWindow *window); static void notebook_page_selected_callback (GtkWidget *notebook, -#if GTK_CHECK_VERSION (2, 90, 6) GtkWidget *page, -#else - gpointer page, -#endif guint page_num, TerminalWindow *window); static void notebook_page_added_callback (GtkWidget *notebook, @@ -2167,11 +2163,7 @@ terminal_window_init (TerminalWindow *window) gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE); gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE); - #if GTK_CHECK_VERSION (3, 0, 0) - gtk_notebook_set_group_name (GTK_NOTEBOOK (priv->notebook), I_("mate-terminal-window")); - #else - gtk_notebook_set_group (GTK_NOTEBOOK (priv->notebook), GUINT_TO_POINTER (1)); - #endif + gtk_notebook_set_group_name (GTK_NOTEBOOK (priv->notebook), I_("mate-terminal-window")); gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE); g_signal_connect (priv->notebook, "button-press-event", @@ -2188,10 +2180,8 @@ terminal_window_init (TerminalWindow *window) G_CALLBACK (terminal_window_update_tabs_menu_sensitivity), window, NULL, G_CONNECT_SWAPPED | G_CONNECT_AFTER); - #if GTK_CHECK_VERSION(3, 0, 0) g_signal_connect (priv->notebook, "create-window", G_CALLBACK (handle_tab_droped_on_desktop), window); - #endif gtk_box_pack_end (GTK_BOX (main_vbox), priv->notebook, TRUE, TRUE, 0); gtk_widget_show (priv->notebook); @@ -2306,9 +2296,6 @@ terminal_window_class_init (TerminalWindowClass *klass) "}\n" "widget \"*.mate-terminal-tab-close-button\" style \"mate-terminal-tab-close-button-style\""); - #if !GTK_CHECK_VERSION(3, 0, 0) - gtk_notebook_set_window_creation_hook (handle_tab_droped_on_desktop, NULL, NULL); - #endif } static void @@ -2900,11 +2887,7 @@ notebook_popup_menu_cb (GtkWidget *widget, static void notebook_page_selected_callback (GtkWidget *notebook, -#if GTK_CHECK_VERSION (2, 90, 6) GtkWidget *page_widget, -#else - gpointer useless_crap, -#endif guint page_num, TerminalWindow *window) { @@ -2912,9 +2895,6 @@ notebook_page_selected_callback (GtkWidget *notebook, GtkWidget *widget; TerminalScreen *screen; int old_grid_width, old_grid_height; -#if !GTK_CHECK_VERSION (2, 90, 6) - GtkWidget *page_widget; -#endif _terminal_debug_print (TERMINAL_DEBUG_MDI, "[window %p] MDI: page-selected %d\n", @@ -2923,10 +2903,6 @@ notebook_page_selected_callback (GtkWidget *notebook, if (priv->disposed) return; -#if !GTK_CHECK_VERSION (2, 90, 6) - page_widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page_num); -#endif - screen = terminal_screen_container_get_screen (TERMINAL_SCREEN_CONTAINER (page_widget)); widget = GTK_WIDGET (screen); g_assert (screen != NULL); @@ -3970,14 +3946,8 @@ terminal_set_title_callback (GtkAction *action, g_signal_connect (dialog, "delete-event", G_CALLBACK (terminal_util_dialog_response_on_delete), NULL); -#if GTK_CHECK_VERSION (2, 90, 6) message_area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog)); gtk_container_foreach (GTK_CONTAINER (message_area), (GtkCallback) gtk_widget_hide, NULL); -#else - label = GTK_MESSAGE_DIALOG (dialog)->label; - gtk_widget_hide (label); - message_area = gtk_widget_get_parent (label); -#endif hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (message_area), hbox, FALSE, FALSE, 0); @@ -4056,11 +4026,7 @@ tabs_next_or_previous_tab_cb (GtkAction *action, gtk_binding_set_activate (gtk_binding_set_by_class (klass), keyval, GDK_CONTROL_MASK, - #if GTK_CHECK_VERSION(3, 0, 0) G_OBJECT (priv->notebook)); - #else - GTK_OBJECT (priv->notebook)); - #endif } static void |