diff options
-rw-r--r-- | mt.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -7,6 +7,7 @@ static void quit(); gboolean key_press_cb(GtkWidget *widget, GdkEventKey *event); static void tab_new(); static void tab_close(); +static void tab_geometry_hints(); static void config(); /* part of the code is from sakura. :) i just want a more minimal version, sakura is to code bloat for what i want. so snippets will do*/ /* i am very thankful for this part, because it really helped me figure out how to close tabs properly (sounds easy, but i am dumb as a doorknob*/ @@ -65,6 +66,33 @@ static void tab_close() { if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(mt.notebook)) == 1) { gtk_notebook_set_show_tabs(GTK_NOTEBOOK(mt.notebook), FALSE); } if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(mt.notebook)) == 0) { quit(); } } + + +static void tab_geometry_hints(struct term *t) { + + /*barrowed from sakura, but using non depreacated code*/ + + GdkGeometry hints; + GtkBorder *border; + gint pad_x, pad_y; + gint char_width, char_height; + puts("1"); + //vte_terminal_get_padding(VTE_TERMINAL(t->vte), (int *)&pad_x, (int *)&pad_y); + gtk_widget_style_get(GTK_WIDGET(t->vte), "inner-border", &border, NULL); + + char_width = vte_terminal_get_char_width(VTE_TERMINAL(t->vte)); + char_height = vte_terminal_get_char_height(VTE_TERMINAL(t->vte)); + puts("1"); + hints.min_width = char_width + border->left + border->right; + hints.min_height = char_height + border->top + border->bottom; + hints.base_width = border->left + border->right; + hints.base_height = border->top + border->bottom; + hints.width_inc = char_width; + hints.height_inc = char_height; + gtk_window_set_geometry_hints(GTK_WINDOW (mt.win), GTK_WIDGET (t->vte), &hints, GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE); +} + + static void tab_new() { @@ -76,9 +104,13 @@ static void tab_new() { int index = gtk_notebook_append_page(GTK_NOTEBOOK(mt.notebook), t->vte, t->label); gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(mt.notebook), t->vte, TRUE); + if ( gtk_notebook_get_n_pages(GTK_NOTEBOOK(mt.notebook)) == 1) { + tab_geometry_hints(t); + } if (index == 0) { gtk_notebook_set_show_tabs(GTK_NOTEBOOK(mt.notebook), FALSE); } else { gtk_notebook_set_show_tabs(GTK_NOTEBOOK(mt.notebook), TRUE); } + 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); |