support both gtk2 and gtk3

This commit is contained in:
Daniel Micay 2012-05-22 14:19:47 -04:00
parent 7ed00e06e1
commit 956d1fb1d9
2 changed files with 21 additions and 6 deletions

View File

@ -1,14 +1,22 @@
PREFIX = /usr/local PREFIX = /usr/local
ifeq (${GTK3}, 1)
GTK = gtk+-3.0
VTE = vte-2.90
else
GTK = gtk+-2.0
VTE = vte
endif
CFLAGS += -std=c99 -O3 \ CFLAGS += -std=c99 -O3 \
-Wall -Wextra -pedantic \ -Wall -Wextra -pedantic \
-Winit-self \ -Winit-self \
-Wshadow \ -Wshadow \
-Wformat=2 \ -Wformat=2 \
-Wmissing-declarations \ -Wmissing-declarations \
$(shell pkg-config --cflags gtk+-2.0 vte) $(shell pkg-config --cflags ${GTK} ${VTE})
LDFLAGS += -s -Wl,--as-needed $(shell pkg-config --libs gtk+-2.0 vte) LDFLAGS += -s -Wl,--as-needed $(shell pkg-config --libs ${GTK} ${VTE})
termite: termite.c config.h termite: termite.c config.h
${CC} ${CFLAGS} -o $@ $< ${LDFLAGS} ${CC} ${CFLAGS} -o $@ $< ${LDFLAGS}

View File

@ -6,6 +6,13 @@
#include "config.h" #include "config.h"
#if GTK_CHECK_VERSION (2, 90, 7)
#define GDK_KEY(symbol) GDK_KEY_##symbol
#else
#include <gdk/gdkkeysyms.h>
#define GDK_KEY(symbol) GDK_##symbol
#endif
#ifndef __GNUC__ #ifndef __GNUC__
# define __attribute__(x) # define __attribute__(x)
#endif #endif
@ -73,18 +80,18 @@ static gboolean key_press_cb(GtkWidget *vte, GdkEventKey *event, search_dialog_i
if (modifiers == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) { if (modifiers == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) {
switch (gdk_keyval_to_lower(event->keyval)) { switch (gdk_keyval_to_lower(event->keyval)) {
case GDK_p: case GDK_KEY(p):
vte_terminal_search_find_previous(VTE_TERMINAL(vte)); vte_terminal_search_find_previous(VTE_TERMINAL(vte));
return TRUE; return TRUE;
case GDK_n: case GDK_KEY(n):
vte_terminal_search_find_next(VTE_TERMINAL(vte)); vte_terminal_search_find_next(VTE_TERMINAL(vte));
return TRUE; return TRUE;
case GDK_question: case GDK_KEY(question):
open_search_dialog(vte, search_backward, info); open_search_dialog(vte, search_backward, info);
return TRUE; return TRUE;
} }
} }
if (modifiers == GDK_CONTROL_MASK && event->keyval == GDK_slash) { if (modifiers == GDK_CONTROL_MASK && event->keyval == GDK_KEY(slash)) {
open_search_dialog(vte, search_forward, info); open_search_dialog(vte, search_forward, info);
return TRUE; return TRUE;
} }