Re: How to create a tab bar that imitates the look an feel of a GtkNotebook?



That's exactly what I was thinking of. I was just looking for a way to make it look like a tab bar in terms of display, tab-width and scrolling / floating.

Am 28.03.2018 um 14:36 schrieb Nicolas Soubeiran:
Hello,
The simplest idea I suggest is using a button box with radio (use gtk_toggle_button_set_mode or css to customize their display and connect the radio "toggled"  signal to switch your models in the treeview  )
something like :

GtkButtonBox* bbox;
GSList *filegroup;
GtkTreeView *file_treeview;



void open_new_file (char* path)
{
GtkRadioButton* file_radio;
GtkTreeModel* file_model;
file_radio = gtk_radio_button_new (filegroup);

/* fill your model */


g_signal_connect(G_OBJECT(file_radio), "toggled", G_CALLBACK(switch_model), file_model);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_radio) , TRUE);
}

void switch_model (GtkToggleButton *radio, GtkTreeModel* model)
{
if (gtk_toggle_button_get_active(radio))
{
/* switch model to the selected radio */
gtk_tree_view_set_model(file_treeview , model);
}
}

If you need more control over the 'tab' button (e.g a close button), you should build a custom widget or an eventbox with controls inside...





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]