Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for platform-specific keybindings #1395

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -104,6 +104,7 @@ AC_DEFINE([HAVE_REGCOMP], [1], [Should always be 1, required for CTags.])
GEANY_CHECK_PLUGINS
# check for mingw specific settings
GEANY_CHECK_MINGW
GEANY_CHECK_OSX

GEANY_CHECK_SOCKET
GEANY_CHECK_VTE
Expand Down
7 changes: 6 additions & 1 deletion data/Makefile.am
Expand Up @@ -109,11 +109,16 @@ nobase_dist_pkgdata_DATA = \
$(template_files) \
$(templates) \
filetype_extensions.conf \
keybindings_osx.conf \
snippets.conf \
ui_toolbar.xml \
geany.glade

dist_pkgdata_DATA =

if OSX
dist_pkgdata_DATA += osx/keybindings.conf
endif OSX

if GTK3
nobase_dist_pkgdata_DATA += \
geany-3.0.css \
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions m4/geany-osx.m4
@@ -0,0 +1,14 @@
dnl GEANY_CHECK_OSX
dnl Checks whether we're building for OSX, and defines appropriate stuff
dnl if it is the case.
dnl Most importantly, AM_CODITIONALs OSX
AC_DEFUN([GEANY_CHECK_OSX],
[
AC_REQUIRE([AC_CANONICAL_HOST])

AC_MSG_CHECKING([whether we are building for OSX])
AS_CASE(["${host}"], [*-darwin*], [host_is_osx=yes], [host_is_osx=no])
AC_MSG_RESULT([$host_is_osx])

AM_CONDITIONAL([OSX], [test x$host_is_osx = xyes])
])
8 changes: 3 additions & 5 deletions src/keybindings.c
Expand Up @@ -768,18 +768,16 @@ static void load_kb(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer user_dat
}


static void init_platform_kb(void)
static void init_system_kb(void)
{
#ifdef __APPLE__
gchar *configfile = g_build_filename(app->datadir, "keybindings_osx.conf", NULL);
gchar *configfile = g_build_filename(app->datadir, "keybindings.conf", NULL);
GKeyFile *config = g_key_file_new();

if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
keybindings_foreach(load_kb, config);

g_free(configfile);
g_key_file_free(config);
#endif
}


Expand All @@ -791,7 +789,7 @@ void keybindings_init(void)
kb_accel_group = gtk_accel_group_new();

init_default_kb();
init_platform_kb();
init_system_kb();
gtk_window_add_accel_group(GTK_WINDOW(main_widgets.window), kb_accel_group);

g_signal_connect(main_widgets.window, "key-press-event", G_CALLBACK(on_key_press_event), NULL);
Expand Down