X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=gtk-gui.c;h=8ae67ecaa6bcf3ad445b2a52be889a9dfd7716a3;hb=a32d28d5e388ab3e31eadcd329814488fa5e8b1b;hp=701e8fe4671ae4fe9718d3030a7be7b4e40e20b4;hpb=fda230235ce8879736803dc9e0ae918ce471201f;p=ext%2Fsubsurface.git diff --git a/gtk-gui.c b/gtk-gui.c index 701e8fe..8ae67ec 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -203,6 +203,42 @@ static void quit(GtkWidget *w, gpointer data) gtk_main_quit(); } +GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char *title, + data_func_t data_func, PangoAlignment align, gboolean visible) +{ + GtkCellRenderer *renderer; + GtkTreeViewColumn *col; + double xalign = 0.0; /* left as default */ + + renderer = gtk_cell_renderer_text_new(); + col = gtk_tree_view_column_new(); + + gtk_tree_view_column_set_title(col, title); + gtk_tree_view_column_set_sort_column_id(col, index); + gtk_tree_view_column_set_resizable(col, TRUE); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + if (data_func) + gtk_tree_view_column_set_cell_data_func(col, renderer, data_func, (void *)(long)index, NULL); + else + gtk_tree_view_column_add_attribute(col, renderer, "text", index); + gtk_object_set(GTK_OBJECT(renderer), "alignment", align, NULL); + switch (align) { + case PANGO_ALIGN_LEFT: + xalign = 0.0; + break; + case PANGO_ALIGN_CENTER: + xalign = 0.5; + break; + case PANGO_ALIGN_RIGHT: + xalign = 1.0; + break; + } + gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(renderer), xalign, 0.5); + gtk_tree_view_column_set_visible(col, visible); + gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), col); + return col; +} + static void create_radio(GtkWidget *vbox, const char *name, ...) { va_list args; @@ -460,8 +496,8 @@ static void switch_page(GtkNotebook *notebook, gint arg1, gpointer user_data) repaint_dive(); } -static const char notebook_name[] = "123"; - +static const char notebook_group[] = "123"; +#define GRP_ID ((void *)notebook_group) typedef struct { char *name; GtkWidget *widget; @@ -500,8 +536,10 @@ static GtkNotebook *create_new_notebook_window(GtkNotebook *source, gtk_container_add(GTK_CONTAINER(win), vbox); notebook = gtk_notebook_new(); + gtk_notebook_set_group(GTK_NOTEBOOK(notebook), GRP_ID); gtk_widget_set_name(notebook, nbdp->name); - gtk_notebook_set_group_name(GTK_NOTEBOOK(notebook), notebook_name); + /* disallow drop events */ + gtk_drag_dest_set(notebook, 0, NULL, 0, 0); gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 6); gtk_widget_set_size_request(notebook, 450, 350); @@ -510,19 +548,12 @@ static GtkNotebook *create_new_notebook_window(GtkNotebook *source, } static void drag_cb(GtkWidget *widget, GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, - guint info, guint time, + gint x, gint y, guint time, gpointer user_data) { GtkWidget *source; notebook_data_t *nbdp; - /* - * We don't actually really *use* this yet, but Dirk wants to - * do all the tabs as detatched tabs, and we'd need to use - * this all to figure out which window we're talking about. - */ source = gtk_drag_get_source_widget(context); if (nbd[0].name && ! strcmp(nbd[0].name,gtk_widget_get_name(source))) nbdp = nbd; @@ -598,7 +629,7 @@ void init_ui(int argc, char **argv) /* Notebook for dive info vs profile vs .. */ notebook = gtk_notebook_new(); gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 6); - gtk_notebook_set_group_name(GTK_NOTEBOOK(notebook), notebook_name); + gtk_notebook_set_group(GTK_NOTEBOOK(notebook), GRP_ID); g_signal_connect(notebook, "create-window", G_CALLBACK(create_new_notebook_window), NULL); gtk_drag_dest_set(notebook, GTK_DEST_DEFAULT_ALL, ¬ebook_target, 1, GDK_ACTION_MOVE); g_signal_connect(notebook, "drag-drop", G_CALLBACK(drag_cb), notebook);