Permalink
Browse files

Merge branch 'gtk3-support'

Conflicts:
	src/ui_utils.c
  • Loading branch information...
2 parents 7e3a235 + e0104a4 commit 35cc441b74dc8103144d09c429f5da5c11770680 @b4n b4n committed Mar 10, 2013
Showing with 498 additions and 78 deletions.
  1. +6 −1 Makefile.am
  2. +15 −2 configure.ac
  3. +36 −0 data/geany.css
  4. +5 −4 plugins/filebrowser.c
  5. +6 −5 plugins/saveactions.c
  6. +3 −2 plugins/splitwindow.c
  7. +2 −0 src/Makefile.am
  8. +2 −1 src/build.c
  9. +2 −1 src/callbacks.c
  10. +20 −5 src/dialogs.c
  11. +20 −0 src/document.c
  12. +14 −1 src/editor.c
  13. +2 −1 src/gb.c
  14. +96 −3 src/geanywraplabel.c
  15. +128 −0 src/gtkcompat.h
  16. +18 −5 src/keybindings.c
  17. +6 −5 src/notebook.c
  18. +10 −2 src/plugindata.h
  19. +20 −20 src/search.c
  20. +8 −0 src/sidebar.c
  21. +8 −2 src/socket.c
  22. +22 −2 src/stash.c
  23. +3 −0 src/toolbar.c
  24. +32 −11 src/ui_utils.c
  25. +4 −2 src/ui_utils.h
  26. +10 −3 src/vte.c
View
@@ -24,8 +24,13 @@ SYS_DATA_FILES = \
$(srcdir)/data/templates/* \
$(srcdir)/data/templates/files/* \
$(srcdir)/data/colorschemes/* \
- $(top_srcdir)/data/geany.glade \
+ $(top_srcdir)/data/geany.glade
+
+if GTK3
+ $(top_srcdir)/data/geany.css
+else
$(top_srcdir)/data/geany.gtkrc
+endif
EXTRA_DIST = \
autogen.sh \
View
@@ -56,14 +56,27 @@ GEANY_CHECK_REVISION([dnl force debug mode for a SVN working copy
CFLAGS="-g -DGEANY_DEBUG $CFLAGS"])
+AC_ARG_ENABLE([gtk3],
+ [AS_HELP_STRING([--enable-gtk3],
+ [compile with GTK3 support (experimental) [default=no]])],
+ [enable_gtk3=$enableval],
+ [enable_gtk3=no])
+
+AS_IF([test "x$enable_gtk3" = xyes],
+ [gtk_package=gtk+-3.0
+ gtk_min_version=3.0],
+ [gtk_package=gtk+-2.0
+ gtk_min_version=2.16])
+AM_CONDITIONAL([GTK3], [test "x$gtk_package" = "xgtk+-3.0"])
+
# GTK/GLib/GIO checks
-gtk_modules="gtk+-2.0 >= 2.16 glib-2.0 >= 2.20"
+gtk_modules="$gtk_package >= $gtk_min_version glib-2.0 >= 2.20"
gtk_modules_private="gio-2.0 >= 2.20 gmodule-2.0"
PKG_CHECK_MODULES([GTK], [$gtk_modules $gtk_modules_private])
AC_SUBST([DEPENDENCIES], [$gtk_modules])
AC_SUBST([GTK_CFLAGS])
AC_SUBST([GTK_LIBS])
-GTK_VERSION=`$PKG_CONFIG --modversion gtk+-2.0`
+GTK_VERSION=`$PKG_CONFIG --modversion $gtk_package`
GEANY_STATUS_ADD([Using GTK version], [${GTK_VERSION}])
# GTHREAD checks
gthread_modules="gthread-2.0"
View
@@ -0,0 +1,36 @@
+/* custom GTK3 CSS for Geany */
+
+/* make close button on the editor's tabs smaller */
+#geany-close-tab-button {
+ -GtkWidget-focus-padding: 0;
+ -GtkWidget-focus-line-width: 0;
+ -GtkButton-default-border: 0;
+ -GtkButton-default-outside-border: 0;
+ -GtkButton-inner-border: 0;
+ padding: 0;
+}
+
+/* use monospaced font in search entries for easier reading of regexp (#1907117) */
+#GeanyDialogSearch GtkEntry {
+ font-family: monospace;
+}
+
+/* set red background for GtkEntries showing unmatched searches */
+#geany-search-entry-no-match {
+ color: #fff;
+ background: #ff6666;
+}
+#geany-search-entry-no-match:selected {
+ background-color: #771111;
+}
+
+/* document status colors */
+#geany-document-status-changed {
+ color: #ff0000;
+}
+#geany-document-status-disk-changed {
+ color: #ff7f00;
+}
+#geany-document-status-readonly {
+ color: #007f00;
+}
View
@@ -26,6 +26,7 @@
#endif
#include "geanyplugin.h"
+#include "gtkcompat.h"
#include <string.h>
#include <gdk/gdkkeysyms.h>
@@ -280,7 +281,7 @@ static void refresh(void)
utf8_dir = utils_get_utf8_from_locale(current_dir);
gtk_entry_set_text(GTK_ENTRY(path_entry), utf8_dir);
gtk_widget_set_tooltip_text(path_entry, utf8_dir);
- ui_combo_box_add_to_history(GTK_COMBO_BOX_ENTRY(path_combo), utf8_dir, 0);
+ ui_combo_box_add_to_history(GTK_COMBO_BOX_TEXT(path_combo), utf8_dir, 0);
g_free(utf8_dir);
add_top_level_entry(); /* ".." item */
@@ -803,7 +804,7 @@ static void on_filter_activate(GtkEntry *entry, gpointer user_data)
{
clear_filter();
}
- ui_combo_box_add_to_history(GTK_COMBO_BOX_ENTRY(filter_combo), NULL, 0);
+ ui_combo_box_add_to_history(GTK_COMBO_BOX_TEXT(filter_combo), NULL, 0);
refresh();
}
@@ -897,7 +898,7 @@ static GtkWidget *make_filterbar(void)
label = gtk_label_new(_("Filter:"));
- filter_combo = gtk_combo_box_entry_new_text();
+ filter_combo = gtk_combo_box_text_new_with_entry();
filter_entry = gtk_bin_get_child(GTK_BIN(filter_combo));
ui_entry_add_clear_icon(GTK_ENTRY(filter_entry));
@@ -1091,7 +1092,7 @@ void plugin_init(GeanyData *data)
filterbar = make_filterbar();
gtk_box_pack_start(GTK_BOX(file_view_vbox), filterbar, FALSE, FALSE, 0);
- path_combo = gtk_combo_box_entry_new_text();
+ path_combo = gtk_combo_box_text_new_with_entry();
gtk_box_pack_start(GTK_BOX(file_view_vbox), path_combo, FALSE, FALSE, 2);
g_signal_connect(path_combo, "changed", G_CALLBACK(ui_combo_box_changed), NULL);
path_entry = gtk_bin_get_child(GTK_BIN(path_combo));
View
@@ -25,6 +25,7 @@
#endif
#include "geanyplugin.h"
+#include "gtkcompat.h"
#include <unistd.h>
#include <errno.h>
@@ -429,8 +430,8 @@ static void configure_response_cb(GtkDialog *dialog, gint response, G_GNUC_UNUSE
GTK_TOGGLE_BUTTON(pref_widgets.autosave_save_all_radio2));
g_free(instantsave_default_ft);
- instantsave_default_ft = gtk_combo_box_get_active_text(
- GTK_COMBO_BOX(pref_widgets.instantsave_ft_combo));
+ instantsave_default_ft = gtk_combo_box_text_get_active_text(
+ GTK_COMBO_BOX_TEXT(pref_widgets.instantsave_ft_combo));
text_dir = gtk_entry_get_text(GTK_ENTRY(pref_widgets.backupcopy_entry_dir));
text_time = gtk_entry_get_text(GTK_ENTRY(pref_widgets.backupcopy_entry_time));
@@ -529,7 +530,7 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
vbox = gtk_vbox_new(FALSE, 6);
notebook = gtk_notebook_new();
- GTK_WIDGET_UNSET_FLAGS(notebook, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus(notebook, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(notebook), 5);
gtk_box_pack_start(GTK_BOX(vbox), notebook, FALSE, TRUE, 0);
@@ -620,13 +621,13 @@ GtkWidget *plugin_configure(GtkDialog *dialog)
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_box_pack_start(GTK_BOX(inner_vbox), label, FALSE, FALSE, 0);
- pref_widgets.instantsave_ft_combo = combo = gtk_combo_box_new_text();
+ pref_widgets.instantsave_ft_combo = combo = gtk_combo_box_text_new();
i = 0;
foreach_slist(node, filetypes_get_sorted_by_name())
{
GeanyFiletype *ft = node->data;
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo), ft->name);
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), ft->name);
if (utils_str_equal(ft->name, instantsave_default_ft))
gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i);
View
@@ -26,6 +26,7 @@
#endif
#include "geanyplugin.h"
+#include "gtkcompat.h"
#include <string.h>
@@ -300,8 +301,8 @@ static void split_view(gboolean horizontal)
GtkWidget *parent = gtk_widget_get_parent(notebook);
GtkWidget *pane, *toolbar, *box;
GeanyDocument *doc = document_get_current();
- gint width = notebook->allocation.width / 2;
- gint height = notebook->allocation.height / 2;
+ gint width = gtk_widget_get_allocated_width(notebook) / 2;
+ gint height = gtk_widget_get_allocated_height(notebook) / 2;
g_return_if_fail(doc);
g_return_if_fail(edit_window.editor == NULL);
View
@@ -20,6 +20,7 @@ SRCS = \
geanymenubuttonaction.c geanymenubuttonaction.h \
geanyobject.c geanyobject.h \
geanywraplabel.c geanywraplabel.h \
+ gtkcompat.h \
highlighting.c highlighting.h \
highlightingmappings.h \
keybindings.c keybindings.h \
@@ -59,6 +60,7 @@ geany_include_HEADERS = \
encodings.h \
filetypes.h \
geany.h \
+ gtkcompat.h \
highlighting.h \
keybindings.h \
msgwindow.h \
View
@@ -61,6 +61,7 @@
#include "win32.h"
#include "toolbar.h"
#include "geanymenubuttonaction.h"
+#include "gtkcompat.h"
/* g_spawn_async_with_pipes doesn't work on Windows */
#ifdef G_OS_WIN32
@@ -1922,7 +1923,7 @@ static void on_label_button_clicked(GtkWidget *wid, gpointer user_data)
const gchar *old = gtk_button_get_label(GTK_BUTTON(wid));
gchar *str;
- if (GTK_WIDGET_TOPLEVEL(top_level) && GTK_IS_WINDOW(top_level))
+ if (gtk_widget_is_toplevel(top_level) && GTK_IS_WINDOW(top_level))
str = dialogs_show_input(_("Set menu item label"), GTK_WINDOW(top_level), NULL, old);
else
str = dialogs_show_input(_("Set menu item label"), NULL, NULL, old);
View
@@ -65,6 +65,7 @@
#include "toolbar.h"
#include "highlighting.h"
#include "pluginutils.h"
+#include "gtkcompat.h"
#ifdef HAVE_VTE
@@ -1811,7 +1812,7 @@ G_MODULE_EXPORT void on_back_activate(GtkMenuItem *menuitem, gpointer user_data)
G_MODULE_EXPORT gboolean on_motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
{
- if (prefs.auto_focus && ! GTK_WIDGET_HAS_FOCUS(widget))
+ if (prefs.auto_focus && ! gtk_widget_has_focus(widget))
gtk_widget_grab_focus(widget);
return FALSE;
View
@@ -55,6 +55,7 @@
#include "build.h"
#include "main.h"
#include "project.h"
+#include "gtkcompat.h"
enum
@@ -319,7 +320,7 @@ static GtkWidget *add_file_open_extra_widget(GtkWidget *dialog)
(GtkAttachOptions) (0), 4, 5);
/* the ebox is for the tooltip, because gtk_combo_box can't show tooltips */
filetype_ebox = gtk_event_box_new();
- filetype_combo = gtk_combo_box_new_text();
+ filetype_combo = gtk_combo_box_text_new();
gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(filetype_combo), 2);
gtk_widget_set_tooltip_text(filetype_ebox,
_("Explicitly defines a filetype for the file, if it would not be detected by filename extension.\nNote if you choose multiple files, they will all be opened with the chosen filetype."));
@@ -377,7 +378,7 @@ static GtkWidget *create_open_file_dialog(void)
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), add_file_open_extra_widget(dialog));
filetype_combo = ui_lookup_widget(dialog, "filetype_combo");
- gtk_combo_box_append_text(GTK_COMBO_BOX(filetype_combo), _("Detect by file extension"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(filetype_combo), _("Detect by file extension"));
/* add FileFilters(start with "All Files") */
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),
filetypes_create_file_filter(filetypes[GEANY_FILETYPES_NONE]));
@@ -390,7 +391,7 @@ static GtkWidget *create_open_file_dialog(void)
if (G_UNLIKELY(ft->id == GEANY_FILETYPES_NONE))
continue;
- gtk_combo_box_append_text(GTK_COMBO_BOX(filetype_combo), ft->title);
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(filetype_combo), ft->title);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filetypes_create_file_filter(ft));
}
gtk_combo_box_set_active(GTK_COMBO_BOX(filetype_combo), 0);
@@ -820,6 +821,20 @@ gboolean dialogs_show_unsaved_file(GeanyDocument *doc)
#ifndef G_OS_WIN32
+/* Use GtkFontChooserDialog on GTK3.2 for consistency, and because
+ * GtkFontSelectionDialog is somewhat broken on 3.4 */
+#if GTK_CHECK_VERSION(3, 2, 0)
+# undef GTK_FONT_SELECTION_DIALOG
+# define GTK_FONT_SELECTION_DIALOG GTK_FONT_CHOOSER_DIALOG
+
+# define gtk_font_selection_dialog_new(title) \
+ gtk_font_chooser_dialog_new((title), NULL)
+# define gtk_font_selection_dialog_get_font_name(dlg) \
+ gtk_font_chooser_get_font(GTK_FONT_CHOOSER(dlg))
+# define gtk_font_selection_dialog_set_font_name(dlg, font) \
+ gtk_font_chooser_set_font(GTK_FONT_CHOOSER(dlg), (font))
+#endif
+
static void
on_font_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
{
@@ -926,7 +941,7 @@ on_input_dialog_response(GtkDialog *dialog, gint response, GtkWidget *entry)
if (persistent)
{
GtkWidget *combo = (GtkWidget *) g_object_get_data(G_OBJECT(dialog), "combo");
- ui_combo_box_add_to_history(GTK_COMBO_BOX_ENTRY(combo), str, 0);
+ ui_combo_box_add_to_history(GTK_COMBO_BOX_TEXT(combo), str, 0);
}
input_cb(str);
}
@@ -950,7 +965,7 @@ static void add_input_widgets(GtkWidget *dialog, GtkWidget *vbox,
if (persistent) /* remember previous entry text in a combo box */
{
- GtkWidget *combo = gtk_combo_box_entry_new_text();
+ GtkWidget *combo = gtk_combo_box_text_new_with_entry();
entry = gtk_bin_get_child(GTK_BIN(combo));
ui_entry_add_clear_icon(GTK_ENTRY(entry));
View
@@ -2771,6 +2771,25 @@ const GdkColor *document_get_status_color(GeanyDocument *doc)
return NULL;
if (! document_status_styles[status].loaded)
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GdkRGBA color;
+ GtkWidgetPath *path = gtk_widget_path_new();
+ GtkStyleContext *ctx = gtk_style_context_new();
+ gtk_widget_path_append_type(path, GTK_TYPE_WINDOW);
+ gtk_widget_path_append_type(path, GTK_TYPE_BOX);
+ gtk_widget_path_append_type(path, GTK_TYPE_NOTEBOOK);
+ gtk_widget_path_append_type(path, GTK_TYPE_LABEL);
+ gtk_widget_path_iter_set_name(path, -1, document_status_styles[status].name);
+ gtk_style_context_set_screen(ctx, gtk_widget_get_screen(GTK_WIDGET(doc->editor->sci)));
+ gtk_style_context_set_path(ctx, path);
+ gtk_style_context_get_color(ctx, GTK_STATE_NORMAL, &color);
+ document_status_styles[status].color.red = 0xffff * color.red;
+ document_status_styles[status].color.green = 0xffff * color.green;
+ document_status_styles[status].color.blue = 0xffff * color.blue;
+ document_status_styles[status].loaded = TRUE;
+ gtk_widget_path_unref(path);
+ g_object_unref(ctx);
+#else
GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(doc->editor->sci));
gchar *path = g_strconcat("GeanyMainWindow.GtkHBox.GtkNotebook.",
document_status_styles[status].name, NULL);
@@ -2779,6 +2798,7 @@ const GdkColor *document_get_status_color(GeanyDocument *doc)
document_status_styles[status].color = style->fg[GTK_STATE_NORMAL];
document_status_styles[status].loaded = TRUE;
g_free(path);
+#endif
}
return &document_status_styles[status].color;
}
View
@@ -60,6 +60,7 @@
#include "projectprivate.h"
#include "main.h"
#include "highlighting.h"
+#include "gtkcompat.h"
/* Note: use sciwrappers.h instead where possible.
@@ -192,7 +193,7 @@ static void on_snippet_keybinding_activate(gchar *key)
const gchar *s;
GHashTable *specials;
- if (!doc || !GTK_WIDGET_HAS_FOCUS(doc->editor->sci))
+ if (!doc || !gtk_widget_has_focus(GTK_WIDGET(doc->editor->sci)))
return;
s = snippets_find_completion_by_name(doc->file_type->name, key);
@@ -4645,6 +4646,14 @@ static gboolean on_editor_expose_event(GtkWidget *widget, GdkEventExpose *event,
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+static gboolean on_editor_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
+{
+ return on_editor_expose_event(widget, NULL, user_data);
+}
+#endif
+
+
static void setup_sci_keys(ScintillaObject *sci)
{
/* disable some Scintilla keybindings to be able to redefine them cleanly */
@@ -4768,7 +4777,11 @@ static ScintillaObject *create_new_sci(GeanyEditor *editor)
g_signal_connect(sci, "scroll-event", G_CALLBACK(on_editor_scroll_event), editor);
g_signal_connect(sci, "motion-notify-event", G_CALLBACK(on_motion_event), NULL);
g_signal_connect(sci, "focus-in-event", G_CALLBACK(on_editor_focus_in), editor);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ g_signal_connect(sci, "draw", G_CALLBACK(on_editor_draw), editor);
+#else
g_signal_connect(sci, "expose-event", G_CALLBACK(on_editor_expose_event), editor);
+#endif
}
return sci;
}
Oops, something went wrong.

0 comments on commit 35cc441

Please sign in to comment.