tab size more correct
This commit is contained in:
parent
32d0bf7f8f
commit
809b65ea57
28
surf.c
28
surf.c
|
@ -448,16 +448,35 @@ void fill_tab_bar(Client *c) {
|
|||
GdkRGBA fg_color;
|
||||
gdk_rgba_parse(&fg_color, tab_bar_color[1]);
|
||||
|
||||
|
||||
GtkAllocation allocation;
|
||||
gtk_widget_get_allocation(GTK_WIDGET(c->win), &allocation);
|
||||
int width = allocation.width;
|
||||
|
||||
int tab_width;
|
||||
|
||||
if (width < 10000) {
|
||||
tab_width = width/MAX(4, g_list_length(c->tabs) + 1);
|
||||
} else {
|
||||
tab_width = 210;
|
||||
}
|
||||
|
||||
int tab_index = 0;
|
||||
// Add tabs to the tab bar
|
||||
for (GList *l = c->tabs; l != NULL; l = l->next) {
|
||||
Tab *tab = (Tab *)l->data;
|
||||
GtkWidget *label = gtk_label_new(tab->title);
|
||||
|
||||
gchar *padded_title = g_strdup_printf(" %s", tab->title);
|
||||
GtkWidget *label = gtk_label_new(padded_title);
|
||||
g_free(padded_title);
|
||||
|
||||
gtk_label_set_xalign(GTK_LABEL(label), 0.0);
|
||||
gtk_widget_set_margin_start(label, 5);
|
||||
gtk_widget_set_valign(label, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_size_request(label, -1, tab_bar_height);
|
||||
|
||||
gtk_widget_set_size_request(label, tab_width, tab_bar_height);
|
||||
|
||||
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END); //if too long cut it
|
||||
|
||||
if (tab_index == c->selected_tab) {
|
||||
gtk_widget_override_background_color(label, GTK_STATE_FLAG_NORMAL, &fg_color);
|
||||
}
|
||||
|
@ -467,7 +486,7 @@ void fill_tab_bar(Client *c) {
|
|||
tab_index++;
|
||||
}
|
||||
|
||||
GtkWidget *new_tab = gtk_label_new("+"); // Create an empty label as a spacer
|
||||
GtkWidget *new_tab = gtk_label_new(" +"); // Create an empty label as a spacer
|
||||
gtk_grid_attach_next_to(GTK_GRID(c->tab_bar), new_tab, NULL, GTK_POS_RIGHT, 1, 1);
|
||||
gtk_widget_show(new_tab);
|
||||
}
|
||||
|
@ -479,7 +498,6 @@ void create_tab_bar(Client *c) {
|
|||
c->tab_bar = gtk_grid_new();
|
||||
gtk_widget_override_background_color(c->tab_bar, GTK_STATE_FLAG_NORMAL, &bg_color);
|
||||
gtk_widget_set_size_request(c->tab_bar, -1, tab_bar_height); // Set the height of the black bar
|
||||
gtk_grid_set_column_spacing(c->tab_bar, 10);
|
||||
gtk_widget_set_events(GTK_GRID(c->tab_bar), GDK_BUTTON_PRESS_MASK);
|
||||
|
||||
//int num_tabs = g_list_length(c->tabs);
|
||||
|
|
Loading…
Reference in a new issue