[geany/geany-plugins] f0dbab: scope: added GTK3 support (keeping GTK2 support)
Lars Paulsen
git-noreply at xxxxx
Sat Oct 20 09:43:08 UTC 2018
Branch: refs/heads/master
Author: Lars Paulsen <lars_paulsen at web.de>
Committer: LarsGit223 <lars_paulsen at web.de>
Date: Sat, 20 Oct 2018 09:43:08 UTC
Commit: f0dbabab09f2ffc0f25054deb58ea7f32b8256e9
https://github.com/geany/geany-plugins/commit/f0dbabab09f2ffc0f25054deb58ea7f32b8256e9
Log Message:
-----------
scope: added GTK3 support (keeping GTK2 support)
- use vte-2.91 for GTK3 and vte >= 0.17 for GTK2
- for GTK 3.4 and higher use CSS padding instead of deprecated 'inner-border' style property
This prevents a warning in the debug messages.
- Fixed overlapping widgets in 'command_dialog':
A gtk3 specific glade file was created. In the 'command_dialog' the
deprecated 'GtkVBox' was replaced by 'GtkBox'. Also less frames were used.
This fixed overlapping of the widgets 'command_view' and 'command_history'.
- Corrected missing 'min-content-height' for 'command_view' in 'command_dialog'
Modified Paths:
--------------
build/scope.m4
po/POTFILES.in
scope/data/Makefile.am
scope/data/scope_gtk3.glade
scope/src/Makefile.am
scope/src/conterm.c
scope/src/plugme.c
scope/src/prefs.c
scope/src/prefs.h
scope/src/scope.c
scope/src/utils.c
utils/src/Makefile.am
utils/src/gp_gtkcompat.h
utils/src/gp_vtecompat.c
utils/src/gp_vtecompat.h
Modified: build/scope.m4
8 lines changed, 5 insertions(+), 3 deletions(-)
===================================================================
@@ -1,16 +1,18 @@
AC_DEFUN([GP_CHECK_SCOPE],
[
GP_ARG_DISABLE([Scope], [auto])
- GP_CHECK_PLUGIN_GTK2_ONLY([Scope])
case "$host_os" in
cygwin* | mingw* | win32*)
PTY_LIBS=""
;;
*)
- GP_CHECK_PLUGIN_DEPS([scope], [VTE],
- [vte >= 0.17])
+
+ GP_CHECK_GTK3([vte_package=vte-2.91], [vte_package="vte >= 0.17"])
+ GP_CHECK_PLUGIN_DEPS([scope], [VTE], [$vte_package])
+ AM_CONDITIONAL([GP_VTE291_USED], [test "$enable_scope" != no && test "$vte_package" = vte-2.91])
+
AC_CHECK_HEADERS([util.h pty.h libutil.h])
PTY_LIBS="-lutil"
;;
Modified: po/POTFILES.in
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -267,6 +267,7 @@ projectorganizer/src/prjorg-sidebar.c
# Scope
scope/data/scope.glade
+scope/data/scope_gtk3.glade
scope/src/break.c
scope/src/conterm.c
scope/src/debug.c
Modified: scope/data/Makefile.am
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -29,4 +29,5 @@ dist_plugindata_DATA = \
StepOver.png \
StepOver22.png \
StepOver24.png \
- scope.glade
+ scope.glade \
+ scope_gtk3.glade
Modified: scope/data/scope_gtk3.glade
3982 lines changed, 3982 insertions(+), 0 deletions(-)
===================================================================
No diff available, check online
Modified: scope/src/Makefile.am
6 lines changed, 4 insertions(+), 2 deletions(-)
===================================================================
@@ -51,11 +51,13 @@ scope_la_SOURCES = \
store/scptreestore.h \
store/scptreestore.c
-scope_la_LIBADD = $(COMMONLIBS) $(VTE_LIBS) $(PTY_LIBS)
+scope_la_LIBADD = $(COMMONLIBS) $(VTE_LIBS) $(PTY_LIBS) \
+ $(top_builddir)/utils/src/libgeanypluginutils.la
scope_la_CPPFLAGS = $(AM_CPPFLAGS) -DG_LOG_DOMAIN=\"Scope\"
scope_la_CFLAGS = $(AM_CFLAGS) $(VTE_CFLAGS) \
-DPLUGINHTMLDOCDIR=\"$(plugindocdir)/html\" \
- -Wno-shadow
+ -Wno-shadow \
+ -I$(top_srcdir)/utils/src
include $(top_srcdir)/build/cppcheck.mk
Modified: scope/src/conterm.c
45 lines changed, 44 insertions(+), 1 deletions(-)
===================================================================
@@ -33,6 +33,7 @@
#ifdef G_OS_UNIX
#include <vte/vte.h>
+#include <gp_vtecompat.h>
/* instead of detecting N kinds of *nix */
#if defined(HAVE_UTIL_H)
#include <util.h>
@@ -394,19 +395,53 @@ void conterm_load_config(void)
pref_vte_font = utils_get_setting_string(config, "VTE", "font", "Monospace 10");
pref_vte_scrollback = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500);
tmp_string = utils_get_setting_string(config, "VTE", "colour_fore", "#ffffff");
+#if !GTK_CHECK_VERSION(3, 14, 0)
gdk_color_parse(tmp_string, &pref_vte_colour_fore);
+#else
+ gdk_rgba_parse(&pref_vte_colour_fore, tmp_string);
+#endif
g_free(tmp_string);
tmp_string = utils_get_setting_string(config, "VTE", "colour_back", "#000000");
+#if !GTK_CHECK_VERSION(3, 14, 0)
gdk_color_parse(tmp_string, &pref_vte_colour_back);
+#else
+ gdk_rgba_parse(&pref_vte_colour_back, tmp_string);
+#endif
g_free(tmp_string);
g_key_file_free(config);
g_free(configfile);
}
static void context_apply_config(GtkWidget *console)
{
+#if !GTK_CHECK_VERSION(3, 0, 0)
gtk_widget_modify_base(console, GTK_STATE_NORMAL, &pref_vte_colour_back);
gtk_widget_modify_cursor(console, &pref_vte_colour_fore, &pref_vte_colour_back);
+#else
+ GString *css_string;
+ GtkStyleContext *context;
+ GtkCssProvider *provider;
+ gchar *css_code, *color, *background_color;
+
+ color = gdk_rgba_to_string (&pref_vte_colour_fore);
+ background_color = gdk_rgba_to_string (&pref_vte_colour_back);
+
+ gtk_widget_set_name(console, "scope-console");
+ context = gtk_widget_get_style_context(console);
+ provider = gtk_css_provider_new();
+ gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ css_string = g_string_new(NULL);
+ g_string_printf(css_string, "#scope-console { color: %s; background-color: %s; }",
+ color, background_color);
+ css_code = g_string_free(css_string, FALSE);
+
+ gtk_css_provider_load_from_data(GTK_CSS_PROVIDER(provider), css_code, -1, NULL);
+
+ g_free(css_code);
+ g_object_unref(provider);
+#endif
ui_widget_modify_font_from_string(console, pref_vte_font);
}
@@ -457,7 +492,15 @@ void conterm_init(void)
{
gint vte_border_x, vte_border_y;
-#if VTE_CHECK_VERSION(0, 24, 0)
+#if GTK_CHECK_VERSION(3, 4, 0)
+ GtkStyleContext *context;
+ GtkBorder border;
+
+ context = gtk_widget_get_style_context (console);
+ gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &border);
+ vte_border_x = border.left + border.right;
+ vte_border_y = border.top + border.bottom;
+#elif VTE_CHECK_VERSION(0, 24, 0)
GtkBorder *border = NULL;
gtk_widget_style_get(console, "inner-border", &border, NULL);
Modified: scope/src/plugme.c
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,10 @@
#include <string.h>
+#include "common.h"
+
+#include <gp_gtkcompat.h>
+
#include "geanyplugin.h"
extern GeanyData *geany_data;
Modified: scope/src/prefs.c
6 lines changed, 6 insertions(+), 0 deletions(-)
===================================================================
@@ -76,8 +76,14 @@ gboolean pref_vte_blinken;
gchar *pref_vte_emulation;
gchar *pref_vte_font;
gint pref_vte_scrollback;
+
+#if !GTK_CHECK_VERSION(3, 14, 0)
GdkColor pref_vte_colour_fore;
GdkColor pref_vte_colour_back;
+#else
+GdkRGBA pref_vte_colour_fore;
+GdkRGBA pref_vte_colour_back;
+#endif
typedef struct _MarkerStyle
{
Modified: scope/src/prefs.h
6 lines changed, 6 insertions(+), 0 deletions(-)
===================================================================
@@ -64,8 +64,14 @@ extern gboolean pref_vte_blinken;
extern gchar *pref_vte_emulation;
extern gchar *pref_vte_font;
extern gint pref_vte_scrollback;
+
+#if !GTK_CHECK_VERSION(3, 14, 0)
extern GdkColor pref_vte_colour_fore;
extern GdkColor pref_vte_colour_back;
+#else
+extern GdkRGBA pref_vte_colour_fore;
+extern GdkRGBA pref_vte_colour_back;
+#endif
void prefs_apply(GeanyDocument *doc);
char *prefs_file_name(void);
Modified: scope/src/scope.c
8 lines changed, 8 insertions(+), 0 deletions(-)
===================================================================
@@ -25,6 +25,10 @@
#include "common.h"
+#include <vte/vte.h>
+
+#include <gp_gtkcompat.h>
+
GeanyPlugin *geany_plugin;
GeanyData *geany_data;
@@ -545,7 +549,11 @@ static gchar *get_data_dir_path(const gchar *filename)
void plugin_init(G_GNUC_UNUSED GeanyData *gdata)
{
GeanyKeyGroup *scope_key_group;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ char *gladefile = get_data_dir_path("scope_gtk3.glade");
+#else
char *gladefile = get_data_dir_path("scope.glade");
+#endif
GError *gerror = NULL;
GtkWidget *menubar1 = ui_lookup_widget(geany->main_widgets->window, "menubar1");
guint item;
Modified: scope/src/utils.c
11 lines changed, 11 insertions(+), 0 deletions(-)
===================================================================
@@ -437,10 +437,21 @@ void utils_remark(GeanyDocument *doc)
guint utils_parse_sci_color(const gchar *string)
{
+#if !GTK_CHECK_VERSION(3, 14, 0)
GdkColor color;
gdk_color_parse(string, &color);
return ((color.blue >> 8) << 16) + (color.green & 0xFF00) + (color.red >> 8);
+#else
+ GdkRGBA color;
+ guint blue, green, red;
+
+ gdk_rgba_parse(&color, string);
+ blue = color.blue * 0xFF;
+ green = color.green * 0xFF;
+ red = color.red * 0xFF;
+ return (blue << 16) + (green << 8) + red;
+#endif
}
gboolean utils_key_file_write_to_file(GKeyFile *config, const char *configfile)
Modified: utils/src/Makefile.am
11 lines changed, 9 insertions(+), 2 deletions(-)
===================================================================
@@ -6,9 +6,16 @@ libgeanypluginutils_la_SOURCES = \
filelist.h \
filelist.c
+if GP_VTE291_USED
+libgeanypluginutils_la_SOURCES += \
+ gp_vtecompat.h \
+ gp_vtecompat.c
+endif
+
libgeanypluginutils_la_CPPFLAGS = $(AM_CPPFLAGS) \
-DG_LOG_DOMAIN=\"Utils\"
-libgeanypluginutils_la_CFLAGS = $(AM_CFLAGS)
-libgeanypluginutils_la_LIBADD = $(COMMONLIBS)
+libgeanypluginutils_la_CFLAGS = $(AM_CFLAGS) $(VTE_CFLAGS)
+libgeanypluginutils_la_LIBADD = $(COMMONLIBS) $(VTE_LIBS)
libgeanypluginutils_la_LDFLAGS = -no-undefined $(GP_LDFLAGS)
include $(top_srcdir)/build/cppcheck.mk
+
Modified: utils/src/gp_gtkcompat.h
57 lines changed, 57 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017 LarsGit223
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Compatibility macros to support different GTK versions */
+
+#ifndef GP_GTKCOMPAT_H
+#define GP_GTKCOMPAT_H
+
+G_BEGIN_DECLS
+
+/* Remove gtk_window_set_has_resize_grip() starting from version 3.14 */
+#if GTK_CHECK_VERSION(3, 14, 0)
+#define gtk_window_set_has_resize_grip(window, value)
+#endif
+
+/* Replace calls to gtk_widget_set_state() with call to
+ gtk_widget_set_state_flags() and translate States to State-Flags.
+ Starting from version 3.0.*/
+#if GTK_CHECK_VERSION(3, 0, 0)
+#define GTK_STATE_NORMAL GTK_STATE_FLAG_NORMAL
+#define GTK_STATE_ACTIVE GTK_STATE_FLAG_ACTIVE
+#define GTK_STATE_PRELIGHT GTK_STATE_FLAG_PRELIGHT
+#define GTK_STATE_SELECTED GTK_STATE_FLAG_SELECTED
+#define GTK_STATE_INSENSITIVE GTK_STATE_FLAG_INSENSITIVE
+#define GTK_STATE_INCONSISTENT GTK_STATE_FLAG_INCONSISTENT
+#define GTK_STATE_FOCUSED GTK_STATE_FLAG_FOCUSED
+#define gtk_widget_set_state(widget, state) \
+ gtk_widget_set_state_flags(widget, state, FALSE)
+#endif
+
+/* Replace some GTK_STOCK constants with labels.
+ Add new ones on-demand. Starting from version 3.10 */
+#if GTK_CHECK_VERSION(3, 10, 0)
+#undef GTK_STOCK_OPEN
+#undef GTK_STOCK_CANCEL
+#define GTK_STOCK_OPEN _("_Open")
+#define GTK_STOCK_CANCEL _("_Cancel")
+#endif
+G_END_DECLS
+
+#endif /* GP_GTKCOMPAT_H */
+
Modified: utils/src/gp_vtecompat.c
47 lines changed, 47 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017 LarsGit223
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <glib/gstdio.h>
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef G_OS_UNIX
+#include <vte/vte.h>
+#include <../../utils/src/gp_vtecompat.h>
+#endif
+
+/** Set font from string.
+ *
+ * Compatibility function to replace deprecated vte_terminal_set_font_from_string().
+ *
+ * @param vte Pointer to VteTerminal
+ * @param font Font specification as string
+ *
+ **/
+void gp_vtecompat_set_font_from_string(VteTerminal *vte, char *font)
+{
+ PangoFontDescription *font_desc;
+
+ font_desc = pango_font_description_from_string(font);
+ vte_terminal_set_font(vte, font_desc);
+ pango_font_description_free (font_desc);
+}
+
Modified: utils/src/gp_vtecompat.h
60 lines changed, 60 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2017 LarsGit223
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/* Compatibility macros to support different VTE versions */
+
+#ifndef GP_VTECOMPAT_H
+#define GP_VTECOMPAT_H
+
+G_BEGIN_DECLS
+
+/* Replace call to vte_terminal_copy_clipboard() with a call to
+ vte_terminal_copy_clipboard_format starting from version 0.50 */
+#if VTE_CHECK_VERSION(0, 50, 0)
+#define vte_terminal_copy_clipboard(terminal) \
+ vte_terminal_copy_clipboard_format(terminal, VTE_FORMAT_TEXT)
+#endif
+
+/* Version info for VTE is incomplete so we use all the macros below
+ simply if GTK3 is used. */
+#if GTK_CHECK_VERSION(3, 0, 0)
+/* Remove vte_terminal_set_emulation() starting from 0.26.2 version */
+#define vte_terminal_set_emulation(vte, emulation)
+
+/* Replace call to vte_terminal_set_font_from_string() with a call to
+ gp_vtecompat_set_font_from_string() starting from version 0.26.2 */
+#define vte_terminal_set_font_from_string(vte, font) \
+ gp_vtecompat_set_font_from_string(vte, font)
+
+/* Replace call to vte_pty_new_foreign() with a call to
+ vte_pty_new_foreign_sync() starting from version 0.26.2 */
+#define vte_pty_new_foreign(pty, error) \
+ vte_pty_new_foreign_sync(pty, NULL, error)
+
+/* Replace call to vte_terminal_set_pty_object() with a call to
+ vte_terminal_set_pty() starting from version 0.26.2 */
+#define vte_terminal_set_pty_object(terminal, pty) \
+ vte_terminal_set_pty(terminal, pty)
+
+void gp_vtecompat_set_font_from_string(VteTerminal *vte, char *font);
+#endif
+
+G_END_DECLS
+
+#endif /* GP_VTECOMPAT_H */
+
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list