aboutsummaryrefslogtreecommitdiff
path: root/mt.c
diff options
context:
space:
mode:
authormutantturkey <crazycal00@gmail.com>2010-04-23 17:53:43 -0400
committermutantturkey <crazycal00@gmail.com>2010-04-23 17:53:43 -0400
commit670b300e63551722d16e88603cbafa496702a4da (patch)
tree02531e5849520581fe6466c60175fbbc296da5c9 /mt.c
parente8e07100e812676ddaf9b228dbfde182159126ac (diff)
basic keybinding callback added, function in place, just have to add more bindings, may do an array, not sure
Diffstat (limited to 'mt.c')
-rw-r--r--mt.c54
1 files changed, 15 insertions, 39 deletions
diff --git a/mt.c b/mt.c
index 8188dc3..99ca1d4 100644
--- a/mt.c
+++ b/mt.c
@@ -30,46 +30,19 @@ static void quit() {
gtk_main_quit();
}
gboolean key_press_cb (GtkWidget *widget, GdkEventKey *event) {
-if (event->state == GDK_CONTROL_MASK) {
+if (event->state == (GDK_CONTROL_MASK|GDK_SHIFT_MASK)) {
- if (gdk_keyval_to_lower(event->keyval) == GDK_T) {
+ if (gdk_keyval_to_lower(event->keyval) == GDK_t) {
tab_new();
return TRUE;
}
- /*
- if (gdk_keyval_to_lower(event->keyval) == GDK_l) {
- gtk_widget_grab_focus(GTK_WIDGET(sb.bar));
- return TRUE;
- }
- if (gdk_keyval_to_lower(event->keyval) == GDK_j) {
- go_back_cb(NULL, NULL);
-
- return TRUE;
- }
- if (gdk_keyval_to_lower(event->keyval) == GDK_k) {
- go_forward_cb(NULL, NULL);
- return TRUE;
- }
- if (gdk_keyval_to_lower(event->keyval) == GDK_bracketright) {
-
- webkit_web_view_set_zoom_level(sb.view, (webkit_web_view_get_zoom_level(sb.view) + .05));
+ if (gdk_keyval_to_lower(event->keyval) == GDK_x) {
+ tab_close();
return TRUE;
}
- if (gdk_keyval_to_lower(event->keyval) == GDK_bracketleft) {
-
- webkit_web_view_set_zoom_level(sb.view, (webkit_web_view_get_zoom_level(sb.view) - .05));
- return TRUE;
+
}
- else {
return FALSE;
- }
-}
-
- if (gtk_widget_has_focus(sb.bar) && gdk_keyval_to_lower(event->keyval) == GDK_Escape) {
- gtk_widget_grab_focus(GTK_WIDGET(sb.view));
- return TRUE;
- }*/}
- return FALSE;
}
static void tab_close() {
@@ -83,7 +56,9 @@ static void tab_close() {
gtk_notebook_remove_page(GTK_NOTEBOOK(mt.notebook), page);
page = gtk_notebook_get_current_page(GTK_NOTEBOOK(mt.notebook));
g_free(t);
+
if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(mt.notebook)) == 0) { quit(); }
+
gtk_widget_grab_focus(gtk_notebook_get_nth_page(GTK_NOTEBOOK(mt.notebook), page));
}
@@ -96,14 +71,14 @@ static void tab_new() {
t->vte = vte_terminal_new();
vte_terminal_fork_command(VTE_TERMINAL(t->vte), NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE);
int index = gtk_notebook_append_page(GTK_NOTEBOOK(mt.notebook), t->vte, t->label);
- printf("%d \n", index);
//sakura_set_page_term(NULL, index, t);
g_object_set_qdata_full(G_OBJECT(gtk_notebook_get_nth_page((GtkNotebook*)mt.notebook, index)), term_data_id, t, NULL);
g_signal_connect(t->vte, "child-exited", G_CALLBACK(tab_close), NULL);
+
+ gtk_widget_show_all(mt.notebook);
gtk_notebook_set_current_page(GTK_NOTEBOOK(mt.notebook), index);
gtk_widget_grab_focus(t->vte);
-
}
int main (int argc, char* argv[]) {
@@ -111,13 +86,14 @@ int main (int argc, char* argv[]) {
term_data_id = g_quark_from_static_string("mt");
mt.notebook = gtk_notebook_new();
mt.win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (G_OBJECT (mt.win), "destroy", G_CALLBACK (quit), NULL);
- g_signal_connect(mt.win, "key-press-event", G_CALLBACK(key_press_cb), NULL);
- tab_new();
+ gtk_window_set_default_size(GTK_WINDOW(mt.win), 800, 800);
tab_new();
gtk_container_add (GTK_CONTAINER(mt.win), mt.notebook);
- gtk_window_set_default_size(GTK_WINDOW(mt.win), 800, 800);
- gtk_widget_show_all(mt.win);
+
+ gtk_widget_show_all(mt.win);
+
+ g_signal_connect (G_OBJECT (mt.win), "destroy", G_CALLBACK (quit), NULL);
+ g_signal_connect(mt.win, "key-press-event", G_CALLBACK(key_press_cb), NULL);
gtk_main();
};