diff options
author | Laszlo Boros <[email protected]> | 2013-08-02 14:22:42 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2013-08-11 16:53:33 +0200 |
commit | 9537fb9c0567157ca181c106c9c79756cee541bd (patch) | |
tree | 2aaa7562a71c5405bac3b170f568c3bd5929bb19 /src | |
parent | ff67cbbd09a93cd247a0228896a354181f564691 (diff) | |
download | mate-terminal-9537fb9c0567157ca181c106c9c79756cee541bd.tar.bz2 mate-terminal-9537fb9c0567157ca181c106c9c79756cee541bd.tar.xz |
GTK3 support
Diffstat (limited to 'src')
-rw-r--r-- | src/profile-editor.c | 27 | ||||
-rw-r--r-- | src/terminal-accels.c | 6 | ||||
-rw-r--r-- | src/terminal-screen.c | 5 | ||||
-rw-r--r-- | src/terminal-util.c | 22 | ||||
-rw-r--r-- | src/terminal-window.c | 70 |
5 files changed, 114 insertions, 16 deletions
diff --git a/src/profile-editor.c b/src/profile-editor.c index 4cf2af6..f3eb4e1 100644 --- a/src/profile-editor.c +++ b/src/profile-editor.c @@ -522,6 +522,31 @@ reset_compat_defaults_cb (GtkWidget *button, static void init_color_scheme_menu (GtkWidget *combo_box) { + #if GTK_CHECK_VERSION(3, 0, 0) + + GtkCellRenderer *renderer; + GtkTreeIter iter; + GtkListStore *store; + int i; + + store = gtk_list_store_new (1, G_TYPE_STRING); + for (i = 0; i < G_N_ELEMENTS (color_schemes); ++i) + gtk_list_store_insert_with_values (store, &iter, -1, + 0, _(color_schemes[i].name), + -1); + gtk_list_store_insert_with_values (store, &iter, -1, + 0, _("Custom"), + -1); + + gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store)); + g_object_unref (store); + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, "text", 0, NULL); + + #else + int i; i = G_N_ELEMENTS (color_schemes); @@ -530,6 +555,8 @@ init_color_scheme_menu (GtkWidget *combo_box) gtk_combo_box_prepend_text (GTK_COMBO_BOX (combo_box), _(color_schemes[--i].name)); } + + #endif } static char* diff --git a/src/terminal-accels.c b/src/terminal-accels.c index 44b003b..499a2f5 100644 --- a/src/terminal-accels.c +++ b/src/terminal-accels.c @@ -29,6 +29,10 @@ #include "terminal-profile.h" #include "terminal-util.h" +#if GTK_CHECK_VERSION(3, 0, 0) + #include <gdk/gdkkeysyms-compat.h> +#endif + /* NOTES * * There are two sources of keybindings changes, from GSettings and from @@ -814,7 +818,7 @@ accel_edited_callback (GtkCellRendererAccel *cell, GTK_BUTTONS_OK, _("The shortcut key ā%sā is already bound to the ā%sā action"), name, - + other_key->user_visible_name ? _(other_key->user_visible_name) : other_key->gsettings_key); g_free (name); diff --git a/src/terminal-screen.c b/src/terminal-screen.c index d64f876..562d793 100644 --- a/src/terminal-screen.c +++ b/src/terminal-screen.c @@ -44,6 +44,11 @@ #include "eggshell.h" +#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) #define SKEY_MATCH_CURSOR (GDK_HAND2) diff --git a/src/terminal-util.c b/src/terminal-util.c index 63a4859..0ffb8b8 100644 --- a/src/terminal-util.c +++ b/src/terminal-util.c @@ -44,6 +44,11 @@ #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 +#endif + void terminal_util_set_unique_role (GtkWindow *window, const char *prefix) { @@ -1049,7 +1054,11 @@ 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; @@ -1092,7 +1101,11 @@ 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; @@ -1158,7 +1171,12 @@ terminal_util_x11_set_net_wm_desktop (GdkWindow *window, 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; @@ -1195,7 +1213,11 @@ 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 92276a5..dfa1b9d 100644 --- a/src/terminal-window.c +++ b/src/terminal-window.c @@ -43,6 +43,11 @@ #include "skey-popup.h" #endif +#if GTK_CHECK_VERSION(3, 0, 0) + #include <gdk/gdk.h> + #include <gdk/gdkkeysyms-compat.h> +#endif + struct _TerminalWindowPrivate { GtkActionGroup *action_group; @@ -1518,23 +1523,43 @@ terminal_window_realize (GtkWidget *widget) TerminalWindowPrivate *priv = window->priv; #ifdef GDK_WINDOWING_X11 GdkScreen *screen; - GdkColormap *colormap; GtkAllocation widget_allocation; - + #if GTK_CHECK_VERSION (3, 0, 0) + GdkVisual *visual; + #else + GdkColormap *colormap; + #endif gtk_widget_get_allocation (widget, &widget_allocation); screen = gtk_widget_get_screen (GTK_WIDGET (window)); - if (gdk_screen_is_composited (screen) && - (colormap = gdk_screen_get_rgba_colormap (screen)) != NULL) - { - /* Set RGBA colormap if possible so VTE can use real transparency */ - gtk_widget_set_colormap (widget, colormap); - priv->have_argb_visual = TRUE; - } - else - { - gtk_widget_set_colormap (widget, gdk_screen_get_default_colormap (screen)); - priv->have_argb_visual = FALSE; - } + + #if GTK_CHECK_VERSION (3, 0, 0) + if (gdk_screen_is_composited (screen) && + (visual = gdk_screen_get_rgba_visual (screen)) != NULL) + { + /* Set RGBA visual if possible so VTE can use real transparency */ + gtk_widget_set_visual (GTK_WIDGET (widget), visual); + priv->have_argb_visual = TRUE; + } + else + { + gtk_widget_set_visual (GTK_WIDGET (window), gdk_screen_get_system_visual (screen)); + priv->have_argb_visual = FALSE; + } + #else + if (gdk_screen_is_composited (screen) && + (colormap = gdk_screen_get_rgba_colormap (screen)) != NULL) + { + /* Set RGBA colormap if possible so VTE can use real transparency */ + gtk_widget_set_colormap (widget, colormap); + priv->have_argb_visual = TRUE; + } + else + { + gtk_widget_set_colormap (widget, gdk_screen_get_default_colormap (screen)); + priv->have_argb_visual = FALSE; + } + #endif + #endif _terminal_debug_print (TERMINAL_DEBUG_GEOMETRY, @@ -2113,7 +2138,11 @@ 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); - gtk_notebook_set_group (GTK_NOTEBOOK (priv->notebook), GUINT_TO_POINTER (1)); + #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_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE); g_signal_connect (priv->notebook, "button-press-event", @@ -2130,6 +2159,11 @@ 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); @@ -2243,7 +2277,9 @@ 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 @@ -3911,7 +3947,11 @@ 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 |