Example #1
0
/*
 * Construct a simple text page widget from a file.
 */
GtkWidget * text_page_new(const char *absolute_path)
{
    GtkWidget *page_vb, *txt_scrollw, *txt;

    page_vb =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(page_vb), 1);
    txt_scrollw = scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scrollw),
                                   GTK_SHADOW_IN);
    gtk_box_pack_start(GTK_BOX(page_vb), txt_scrollw, TRUE, TRUE, 0);

    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    txt = gtk_text_view_new();
    gtk_text_view_set_editable(GTK_TEXT_VIEW(txt), FALSE);
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt), GTK_WRAP_WORD);
    gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(txt), FALSE);
    /* XXX: there seems to be no way to add a small border *around* the whole text,
     * so the text will be "bump" against the edges.
     * the following is only working for left and right edges,
     * there is no such thing for top and bottom :-( */
    /* gtk_text_view_set_left_margin(GTK_TEXT_VIEW(txt), 3); */
    /* gtk_text_view_set_right_margin(GTK_TEXT_VIEW(txt), 3); */

    g_object_set_data(G_OBJECT(page_vb), TEXT_KEY, txt);

    text_page_set_text(page_vb, absolute_path);
    gtk_container_add(GTK_CONTAINER(txt_scrollw), txt);
    gtk_widget_show(txt_scrollw);
    gtk_widget_show(txt);

    return page_vb;
}
Example #2
0
GtkWidget *
packet_list_create(void)
{
	GtkWidget *view, *scrollwin;

	scrollwin = scrolled_window_new(NULL, NULL);

	view = create_view_and_model();

	gtk_container_add(GTK_CONTAINER(scrollwin), view);

	g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY, view);

	return scrollwin;
}
Example #3
0
GtkWidget *graph_new(track_state_t *track_state) {
  graph_priv_t *priv = g_new0(graph_priv_t, 1);
  priv->track_state = track_state;
  priv->zoom = 1;

  /* outmost widget: a vbox */
  GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
  g_object_set_data(G_OBJECT(vbox), "priv", priv);

  GtkWidget *win = scrolled_window_new(GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
  priv->graph = gtk_drawing_area_new();

  int flags = track_contents(track_state);
  
  printf("flags = %x\n", flags);

  gtk_signal_connect(GTK_OBJECT(priv->graph), "expose_event",
		     G_CALLBACK(graph_expose_event), vbox);
  gtk_signal_connect(GTK_OBJECT(priv->graph),"configure_event",
		     G_CALLBACK(graph_configure_event), vbox);
  g_signal_connect(G_OBJECT(priv->graph), "destroy", 
		   G_CALLBACK(graph_destroy_event), vbox);

  gtk_widget_add_events(win, GDK_STRUCTURE_MASK);
  gtk_signal_connect(GTK_OBJECT(win), "expose_event",
		     G_CALLBACK(swin_expose_event), vbox);

  scrolled_window_add_with_viewport(win, priv->graph);

  priv->adj = 
    gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(win));
  gtk_signal_connect(GTK_OBJECT(priv->adj), "value_changed",
		     G_CALLBACK(scroll_changed), priv);

  GtkWidget *hbox = gtk_hbox_new(FALSE, 5);

  gtk_box_pack_start(GTK_BOX(hbox), graph_range_new(priv), FALSE, FALSE, 0);
  gtk_box_pack_start_defaults(GTK_BOX(hbox), win);

  gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox);

  GtkWidget *bottom_box = graph_bottom_box(vbox);
  gtk_box_pack_start(GTK_BOX(vbox), bottom_box, FALSE, FALSE, 0);

  return vbox;
}
Example #4
0
static GtkWidget *
scroll_box_dynamic_add(GtkWidget *parent_box)
{
    GtkWidget *child_box;
    GtkWidget *scrollw;
    guint max_cnt;
    guint curr_cnt;
    guint scrollw_y_size;
    GList *childs;

    child_box = (GtkWidget *)g_object_get_data(G_OBJECT(parent_box), SCROLL_BOX_CHILD_BOX);
    max_cnt = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(parent_box), SCROLL_BOX_MAX_CHILDS));

    /* get the current number of children */
    childs = gtk_container_get_children(GTK_CONTAINER(child_box));
    curr_cnt = g_list_length(childs);
    g_list_free(childs);

    /* have we just reached the max? */
    if(curr_cnt == max_cnt) {
        /* create the scrolled window */
        /* XXX - there's no way to get rid of the shadow frame - except for creating an own widget :-( */
        scrollw = scrolled_window_new(NULL, NULL);
        scrollw_y_size = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(parent_box), SCROLL_BOX_SCROLLW_Y_SIZE));
        gtk_widget_set_size_request(scrollw, -1, scrollw_y_size);

        g_object_set_data(G_OBJECT(parent_box), SCROLL_BOX_SCROLLW, scrollw);
        gtk_box_pack_start(GTK_BOX(parent_box), scrollw, TRUE, TRUE, 0);

        /* move child_box from parent_box into scrolled window */
        g_object_ref(child_box);
        gtk_container_remove(GTK_CONTAINER(parent_box), child_box);
#if ! GTK_CHECK_VERSION(3,8,0)
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrollw), child_box);
#else
        gtk_container_add(GTK_CONTAINER(scrollw), child_box);
#endif
        gtk_widget_show_all(scrollw);
    }

    return child_box;
}
Example #5
0
GtkWidget *
about_plugins_page_new(void)
{
    GtkWidget *scrolledwindow;
    GtkWidget *plugins_list;
    static const gchar *titles[] = {"Name", "Version", "Type", "Path"};


    scrolledwindow = scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
                                   GTK_SHADOW_IN);

    plugins_list = simple_list_new(4, titles);
    plugins_scan(plugins_list);

    /* connect a callback so we can spot a double-click */
    g_signal_connect(plugins_list, "button_press_event",
                     G_CALLBACK(about_plugins_callback), NULL);

    gtk_container_add(GTK_CONTAINER(scrolledwindow), plugins_list);

    return scrolledwindow;
}
Example #6
0
GtkWidget *
new_packet_list_create(void)
{
	GtkWidget *view, *scrollwin;

	scrollwin = scrolled_window_new(NULL, NULL);

	view = create_view_and_model();

	gtk_container_add(GTK_CONTAINER(scrollwin), view);

	/* XXX - Implement me
	g_signal_connect(view, "row-activated",
			 G_CALLBACK(popup_menu_handler),
			 g_object_get_data(G_OBJECT(popup_menu_object),
					   PM_PACKET_LIST_KEY));
	g_signal_connect(view, "button_press_event",
			 G_CALLBACK(new_packet_list_button_pressed_cb), NULL);
	*/

	g_object_set_data(G_OBJECT(popup_menu_object), E_MPACKET_LIST_KEY, view);

	return scrollwin;
}
Example #7
0
static void
ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
{
	GtkWidget	  *ifopts_edit_dlg, *cur_scr_win, *main_hb, *main_tb,
			  *cur_opts_fr, *ed_opts_fr, *main_vb,
			  *if_descr_lb,
			  *if_hide_lb,
			  *bbox, *ok_bt, *cancel_bt, *help_bt;

	GtkListStore	  *list_store;
	GtkWidget	  *list;
	GtkTreeViewColumn *column;
	GtkCellRenderer   *renderer;
 	GtkTreeView       *list_view;
	GtkTreeSelection  *selection;

	int row = 0;

	GtkWidget   *caller   = gtk_widget_get_toplevel(w);

	/* Has an edit dialog box already been opened for that top-level
	   widget? */
	ifopts_edit_dlg = g_object_get_data(G_OBJECT(caller), IFOPTS_DIALOG_PTR_KEY);
	if (ifopts_edit_dlg != NULL) {
		/* Yes.  Just re-activate that dialog box. */
		reactivate_window(ifopts_edit_dlg);
		return;
	}

	/* create a new dialog */
	ifopts_edit_dlg = dlg_conf_window_new("Wireshark: Preferences: Interface Options");
	gtk_window_set_default_size(GTK_WINDOW(ifopts_edit_dlg), 1000, 440);

	main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 1, FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
	gtk_container_add(GTK_CONTAINER(ifopts_edit_dlg), main_vb);
	gtk_widget_show(main_vb);

	/* create current options frame */
	cur_opts_fr = gtk_frame_new("Interfaces");
	gtk_box_pack_start(GTK_BOX(main_vb), cur_opts_fr, TRUE, TRUE, 0);
	gtk_widget_show(cur_opts_fr);

	/* create a scrolled window to pack the current options TreeView widget into */
	cur_scr_win = scrolled_window_new(NULL, NULL);
	gtk_container_set_border_width(GTK_CONTAINER(cur_scr_win), 3);
	gtk_container_add(GTK_CONTAINER(cur_opts_fr), cur_scr_win);
	gtk_widget_show(cur_scr_win);

	/*
	 * Create current options TreeView.
	 */
	list_store = gtk_list_store_new(N_COLUMN,	/* Total number of columns XXX	*/
					G_TYPE_STRING,	/* Device			*/
					G_TYPE_STRING,	/* Description			*/
#ifdef HAVE_PCAP_CREATE
					G_TYPE_BOOLEAN,	/* Monitor mode		*/
#endif
					G_TYPE_STRING,	/* Default link-layer		*/
					G_TYPE_STRING,	/* Comment			*/
					G_TYPE_BOOLEAN,	/* Hide?			*/
					G_TYPE_INT);	/* Dlt 				*/

	list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));

	list_view = GTK_TREE_VIEW(list);

	/* The view now holds a reference.  We can get rid of our own reference */
	g_object_unref (G_OBJECT (list_store));

	/*
	 * Create the first column packet, associating the "text" attribute of the
	 * cell_renderer to the first column of the model
	 */
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Device", renderer,
							   "text", DEVICE_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
#ifdef _WIN32
	gtk_tree_view_column_set_min_width(column, 230);
#else
	gtk_tree_view_column_set_min_width(column, 70);
#endif
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Description", renderer,
							   "text", DESC_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_min_width(column, 260);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

#ifdef HAVE_PCAP_CREATE
	/*
	 * XXX - for some reason, this doesn't show up.
	 */
	renderer = gtk_cell_renderer_toggle_new ();
	column = gtk_tree_view_column_new_with_attributes ("Default to monitor mode", renderer,
							   "active", DEF_MONITOR_MODE_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, FALSE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);
#endif

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Default link-layer", renderer,
							   "text", DEF_LINK_LAYER_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_min_width(column, 230);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("Comment", renderer,
							   "text", COMMENT_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_min_width(column, 100);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

	renderer = gtk_cell_renderer_toggle_new ();
	column = gtk_tree_view_column_new_with_attributes ("Hide?", renderer,
							   "active", HIDE_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, FALSE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);

#if 0
	/* Don't show the DLT column */
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes ("DLT", renderer,
							   "text", DLT_COLUMN,
							   NULL);

	gtk_tree_view_column_set_resizable(column, TRUE);
	gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
	gtk_tree_view_column_set_min_width(column, 40);
	/* Add the column to the view. */
	gtk_tree_view_append_column (list_view, column);
#endif
	/* Setup the selection handler */
	selection = gtk_tree_view_get_selection(list_view);
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);

	cur_list = list;
	gtk_container_add(GTK_CONTAINER(cur_scr_win), cur_list);

	if_selection = selection;

	g_signal_connect (G_OBJECT (selection), "changed", /* select_row */
			  G_CALLBACK (ifopts_edit_ifsel_cb),
			  NULL);

	gtk_widget_show(cur_list);

	/* add interface names to cell */
	ifopts_if_liststore_add();

	/* create edit options frame */
	ed_opts_fr = gtk_frame_new("Properties");
	gtk_box_pack_start(GTK_BOX(main_vb), ed_opts_fr, FALSE, FALSE, 0);
	gtk_widget_show(ed_opts_fr);

	main_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5, TRUE);
	gtk_container_set_border_width(GTK_CONTAINER(main_hb), 3);
	gtk_container_add(GTK_CONTAINER(ed_opts_fr), main_hb);
	gtk_widget_show(main_hb);

	/* table to hold description text entry and hide button */
	main_tb = gtk_table_new(IFOPTS_TABLE_ROWS, 4, FALSE);
	gtk_box_pack_start(GTK_BOX(main_hb), main_tb, TRUE, FALSE, 10);
	gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
	gtk_table_set_col_spacings(GTK_TABLE(main_tb), 10);
	gtk_widget_show(main_tb);

	if_dev_lb = gtk_label_new("Device:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_dev_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_dev_lb), 1.0f, 0.5f);
	gtk_widget_show(if_dev_lb);

	if_dev_lb = gtk_label_new("");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_dev_lb, 1, 2, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_dev_lb), 0.0f, 0.5f);
	gtk_widget_show(if_dev_lb);
	row++;

	if_name_lb = gtk_label_new("Description:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_name_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_name_lb), 1.0f, 0.5f);
	gtk_widget_show(if_name_lb);

	if_name_lb = gtk_label_new("");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_name_lb, 1, 2, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_name_lb), 0.0f, 0.5f);
	gtk_widget_show(if_name_lb);
	row++;

#ifdef HAVE_PCAP_CREATE
	/* create "monitor mode" label and button */
	if_monitor_lb = gtk_label_new("Monitor mode:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_monitor_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_monitor_lb), 1.0f, 0.5f);
	gtk_widget_show(if_monitor_lb);

	if_monitor_cb = gtk_check_button_new();
	g_signal_connect(if_monitor_cb, "toggled", G_CALLBACK(ifopts_edit_monitor_changed_cb),
			cur_list);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_monitor_cb, 1, 2, row, row+1);
	gtk_widget_show(if_monitor_cb);
        row++;
#endif

	if_linktype_lb = gtk_label_new("Default link-layer header type:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_linktype_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_linktype_lb), 1.0f, 0.5f);
	gtk_widget_show(if_linktype_lb);

	if_linktype_cb = gtk_combo_box_text_new();
	num_linktypes = 0;
	interfaces_info_nochange = FALSE;
	g_signal_connect(if_linktype_cb, "changed", G_CALLBACK(ifopts_edit_linktype_changed_cb),
			cur_list);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_linktype_cb, 1, 2, row, row+1);
	gtk_widget_show(if_linktype_cb);
	row++;

	/* create interface description label and text entry */
	if_descr_lb = gtk_label_new("Comment:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_descr_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_descr_lb), 1.0f, 0.5f);
	gtk_widget_show(if_descr_lb);

	if_descr_te = gtk_entry_new();
	g_signal_connect(if_descr_te, "changed", G_CALLBACK(ifopts_edit_descr_changed_cb),
			cur_list);
	gtk_entry_set_max_length(GTK_ENTRY(if_descr_te), IFOPTS_MAX_DESCR_LEN);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_descr_te, 1, 2, row, row+1);
	gtk_widget_show(if_descr_te);
	row++;

	/* create "hide interface" label and button */
	if_hide_lb = gtk_label_new("Hide interface?:");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_hide_lb, 0, 1, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_hide_lb), 1.0f, 0.5f);
	gtk_widget_show(if_hide_lb);

	if_hide_cb = gtk_check_button_new();
	g_signal_connect(if_hide_cb, "toggled", G_CALLBACK(ifopts_edit_hide_changed_cb),
			cur_list);
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_hide_cb, 1, 2, row, row+1);
	gtk_widget_show(if_hide_cb);

	if_default_if_lb = gtk_label_new("(Default interface cannot be hidden)");
	gtk_table_attach_defaults(GTK_TABLE(main_tb), if_default_if_lb, 1, 3, row, row+1);
	gtk_misc_set_alignment(GTK_MISC(if_default_if_lb), 0.15f, 0.5f);
	row++;

	/* button row: OK and Cancel buttons */
	bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
	gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
	gtk_widget_show(bbox);

	ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
	gtk_widget_set_tooltip_text(ok_bt, "Save changes and exit dialog");
	g_signal_connect(ok_bt, "clicked", G_CALLBACK(ifopts_edit_ok_cb), ifopts_edit_dlg);

	cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
	gtk_widget_set_tooltip_text(cancel_bt, "Cancel and exit dialog");
        window_set_cancel_button(ifopts_edit_dlg, cancel_bt, window_cancel_button_cb);

	help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
	g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb),
			 (gpointer)HELP_CAPTURE_INTERFACE_OPTIONS_DIALOG);
	gtk_widget_set_tooltip_text (help_bt, "Show topic specific help");

	gtk_widget_grab_default(ok_bt);

	g_signal_connect(ifopts_edit_dlg, "delete_event", G_CALLBACK(window_delete_event_cb),
                 NULL);
	/* Call a handler when we're destroyed, so we can inform
	   our caller, if any, that we've been destroyed. */
	g_signal_connect(ifopts_edit_dlg, "destroy", G_CALLBACK(ifopts_edit_destroy_cb), NULL);

	/* Set the key for the new dialog to point to our caller. */
	g_object_set_data(G_OBJECT(ifopts_edit_dlg), IFOPTS_CALLER_PTR_KEY, caller);
	/* Set the key for the caller to point to us */
	g_object_set_data(G_OBJECT(caller), IFOPTS_DIALOG_PTR_KEY, ifopts_edit_dlg);

	gtk_widget_show(ifopts_edit_dlg); /* triggers ifopts_edit_ifsel_cb() with the  */
                                          /*  "interfaces" TreeView first row selected */
	window_present(ifopts_edit_dlg);
}
Example #8
0
static GtkWidget *
build_heur_dissectors_treeview(void)
{
  GtkWidget  *bbox, *proto_list, *label, *proto_sw, *proto_vb, *button,
             *ok_bt, *save_bt, *cancel_bt;

  static const gchar *titles[] = { "Status", "Heuristic Protocol", "Description" };
  GtkListStore *proto_store;
  GtkCellRenderer *proto_rend;
  GtkTreeViewColumn *proto_col;

  /* Protocol list */
  proto_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
  gtk_widget_show(proto_vb);

  proto_sw = scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(proto_sw),
                                   GTK_SHADOW_IN);
  gtk_box_pack_start(GTK_BOX(proto_vb), proto_sw, TRUE, TRUE, 0);
  gtk_widget_show(proto_sw);

  proto_store = gtk_list_store_new(4, G_TYPE_BOOLEAN, G_TYPE_STRING,
                                   G_TYPE_STRING, G_TYPE_POINTER);
  show_heur_selection(proto_store);
  /* default sort on "abbrev" column */
  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(proto_store), 1,
                                       GTK_SORT_ASCENDING);

  proto_list = tree_view_new(GTK_TREE_MODEL(proto_store));
  gtk_container_add(GTK_CONTAINER(proto_sw), proto_list);

  proto_rend = gtk_cell_renderer_toggle_new();
  g_signal_connect(proto_rend, "toggled", G_CALLBACK(status_toggled), proto_store);
  proto_col = gtk_tree_view_column_new_with_attributes(titles[0], proto_rend, "active", 0, NULL);
  gtk_tree_view_column_set_sort_column_id(proto_col, 0);
  g_signal_connect(proto_col, "clicked", G_CALLBACK(proto_col_clicked_cb), proto_list);
  gtk_tree_view_append_column(GTK_TREE_VIEW(proto_list), proto_col);

  proto_rend = gtk_cell_renderer_text_new();
  proto_col = gtk_tree_view_column_new_with_attributes(titles[1], proto_rend, "text", 1, NULL);
  gtk_tree_view_column_set_sort_column_id(proto_col, 1);
  g_signal_connect(proto_col, "clicked", G_CALLBACK(proto_col_clicked_cb), proto_list);
  gtk_tree_view_append_column(GTK_TREE_VIEW(proto_list), proto_col);

  proto_rend = gtk_cell_renderer_text_new();
  proto_col = gtk_tree_view_column_new_with_attributes(titles[2], proto_rend, "text", 2, NULL);
  gtk_tree_view_column_set_sort_column_id(proto_col, 2);
  g_signal_connect(proto_col, "clicked", G_CALLBACK(proto_col_clicked_cb), proto_list);
  gtk_tree_view_append_column(GTK_TREE_VIEW(proto_list), proto_col);

  gtk_tree_view_set_search_column(GTK_TREE_VIEW(proto_list), 1); /* col 1 in the *model* */
  g_object_unref(G_OBJECT(proto_store));
  gtk_widget_show(proto_list);

  label = gtk_label_new("Disabling a heuristic dissector prevents higher "
			"layer protocols from being displayed");
  gtk_misc_set_alignment(GTK_MISC(label), 0.5f, 0.5f);
  gtk_widget_show(label);
  gtk_box_pack_start(GTK_BOX(proto_vb), label, FALSE, FALSE, 5);

  bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
  gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
  gtk_box_set_spacing(GTK_BOX(bbox), 5);
  gtk_box_pack_start(GTK_BOX(proto_vb), bbox, FALSE, FALSE, 0);
  gtk_widget_show(bbox);

  /* Enable All */
  button = gtk_button_new_with_label("Enable All");
  g_signal_connect(button, "clicked", G_CALLBACK(enable_all_cb), proto_list);
  gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0);
  gtk_widget_show(button);

  /* Disable All */
  button = gtk_button_new_with_label("Disable All");
  g_signal_connect(button, "clicked", G_CALLBACK(disable_all_cb), proto_list);
  gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0);
  gtk_widget_show(button);

  /* Invert */
  button = gtk_button_new_with_label("Invert");
  g_signal_connect(button, "clicked", G_CALLBACK(toggle_all_cb), proto_list);
  gtk_box_pack_start(GTK_BOX(bbox), button, TRUE, TRUE, 0);
  gtk_widget_show(button);


  /* Button row */
  bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_APPLY, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
  gtk_box_pack_start(GTK_BOX(proto_vb), bbox, FALSE, FALSE, 0);
  gtk_widget_show(bbox);

  ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
  /*g_signal_connect(ok_bt, "clicked", G_CALLBACK(proto_ok_cb), proto_w);*/
  gtk_widget_grab_default(ok_bt);

  /*apply_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_APPLY);*/
 /* g_signal_connect(apply_bt, "clicked", G_CALLBACK(proto_apply_cb), proto_w);*/

  save_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE);
 /* g_signal_connect(save_bt, "clicked", G_CALLBACK(proto_save_cb), proto_w);*/

  cancel_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
  window_set_cancel_button(proto_w, cancel_bt, proto_cancel_cb);

  /*help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);*/
  /*g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_ENABLED_PROTOCOLS_DIALOG);*/

  /*g_signal_connect(proto_w, "delete_event", G_CALLBACK(proto_delete_event_cb), NULL);*/
  g_signal_connect(proto_w, "destroy", G_CALLBACK(heur_proto_destroy_cb), NULL);

  gtk_widget_show(proto_w);

  gtk_widget_grab_focus(proto_list); /* XXX: force focus to the tree_view. This hack req'd so "type-ahead find"
                                      *  will be effective after the window is displayed. The issue is
                                      *  that any call to gtk_tree_view_column_set_sort_column_id above
                                      *  apparently sets the focus to the column header button and thus
                                      *  type-ahead find is, in effect, disabled on the column.
                                      *  Also required: a grab_focus whenever the column header is
                                      *  clicked to change the column sort order since the click
                                      *  also changes the focus to the column header button.
                                      *  Is there a better way to do this ?
                                      */

  /* hide the Save button if the user uses implicit save */
  if(!prefs.gui_use_pref_save) {
    gtk_widget_hide(save_bt);
  }

  return proto_vb;

}
static GtkWidget *
about_folders_page_new(void)
{
  GtkWidget   *table;
  const char *constpath;
  char *path;
  const gchar *titles[] = { "Name", "Folder", "Typical Files"};
  GtkWidget *scrolledwindow;
#if defined (HAVE_LIBSMI) || defined (HAVE_GEOIP)
  gint i;
  gchar **resultArray;
#endif

  scrolledwindow = scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
                                   GTK_SHADOW_IN);

  /* Container for our data */
  table = simple_list_new(3, titles);

  /* connect a callback so we can spot a double-click */
  g_signal_connect(table, "button_press_event",
		     G_CALLBACK(about_folders_callback), NULL);

  simple_list_url_col(table, 1);

  /* "file open" */
  about_folders_row(table, "\"File\" dialogs", get_last_open_dir(),
      "capture files");

  /* temp */
  path = get_tempfile_path("");
  about_folders_row(table, "Temp", path,
      "untitled capture files");
  g_free(path);

  /* pers conf */
  path = get_persconffile_path("", FALSE, FALSE);
  about_folders_row(table, "Personal configuration", path,
      "\"dfilters\", \"preferences\", \"ethers\", ...");
  g_free(path);

  /* global conf */
  constpath = get_datafile_dir();
  if (constpath != NULL) {
    about_folders_row(table, "Global configuration", constpath,
        "\"dfilters\", \"preferences\", \"manuf\", ...");
  }

  /* system */
  constpath = get_systemfile_dir();
  about_folders_row(table, "System", constpath,
      "\"ethers\", \"ipxnets\"");

  /* program */
  constpath = get_progfile_dir();
  about_folders_row(table, "Program", constpath,
      "program files");

#if defined(HAVE_PLUGINS) || defined(HAVE_LUA_5_1)
  /* pers plugins */
  path = get_plugins_pers_dir();
  about_folders_row(table, "Personal Plugins", path,
      "dissector plugins");
  g_free(path);

  /* global plugins */
  about_folders_row(table, "Global Plugins", get_plugin_dir(),
      "dissector plugins");
#endif

#ifdef HAVE_PYTHON
  /* global python bindings */
  about_folders_row(table, "Python Bindings", get_wspython_dir(),
      "python bindings");
#endif

#ifdef HAVE_GEOIP
  /* GeoIP */
  path = geoip_db_get_paths();

  resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10);

  for(i = 0; resultArray[i]; i++)
    about_folders_row(table, "GeoIP path", g_strstrip(resultArray[i]),
		      "GeoIP database search path");
  g_strfreev(resultArray);
  g_free(path);
#endif

#ifdef HAVE_LIBSMI
  /* SMI MIBs/PIBs */
  path = oid_get_default_mib_path();

  resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10);

  for(i = 0; resultArray[i]; i++)
    about_folders_row(table, "MIB/PIB path", g_strstrip(resultArray[i]),
		      "SMI MIB/PIB search path");
  g_strfreev(resultArray);
  g_free(path);
#endif

  gtk_container_add(GTK_CONTAINER(scrolledwindow), table);

  return scrolledwindow;
}
Example #10
0
/*
 * Create and display the column selection widgets.
 * Called as part of the creation of the Preferences notebook ( Edit ! Preferences )
 */
GtkWidget *
column_prefs_show(GtkWidget *prefs_window) {
    GtkWidget         *main_vb, *bottom_hb, *column_l, *add_bt, *tb, *lb;
    GtkWidget         *list_vb, *list_lb, *list_sc;
    GtkWidget         *add_remove_vb;
    GtkWidget         *props_fr, *props_hb;
    GList             *clp;
    fmt_data          *cfmt;
    gint               i;
    gchar             *fmt;
    gint               cur_fmt;
    const gchar       *column_titles[] = {"Title", "Field type"};
    GtkListStore      *store;
    GtkCellRenderer   *renderer;
    GtkTreeViewColumn *column;
    GtkTreeSelection  *sel;
    GtkTreeIter        iter;
    GtkTreeIter        first_iter;
    gint               first_row = TRUE;

    GtkTooltips   *tooltips = gtk_tooltips_new();

    /* Container for each row of widgets */
    main_vb = gtk_vbox_new(FALSE, 5);
    gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
    gtk_widget_show(main_vb);

    list_vb = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width  (GTK_CONTAINER (list_vb), 5);
    gtk_widget_show (list_vb);
    gtk_box_pack_start (GTK_BOX (main_vb), list_vb, TRUE, TRUE, 0);

    list_lb = gtk_label_new (("[The first list entry will be displayed as the leftmost column]"));
    gtk_widget_show (list_lb);
    gtk_box_pack_start (GTK_BOX (list_vb), list_lb, FALSE, FALSE, 0);

    list_sc = scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(list_sc), GTK_SHADOW_IN);
    gtk_container_add(GTK_CONTAINER(list_vb), list_sc);
    gtk_widget_show(list_sc);

    store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
    column_row_deleted_handler_id = 
        g_signal_connect(GTK_TREE_MODEL(store), "row-deleted", G_CALLBACK(column_dnd_row_deleted_cb), NULL);

    column_l = tree_view_new(GTK_TREE_MODEL(store));
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(column_l), TRUE);
    gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(column_l), FALSE);
    gtk_tree_view_set_reorderable(GTK_TREE_VIEW(column_l), TRUE);
    gtk_tooltips_set_tip (tooltips, column_l, 
        "Click on a title to change its name.\nDrag an item to change its order.", NULL);

    renderer = gtk_cell_renderer_text_new();
    g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
    g_signal_connect (renderer, "edited", G_CALLBACK(column_title_changed_cb), GTK_TREE_MODEL(store));
    column = gtk_tree_view_column_new_with_attributes(column_titles[0], renderer, "text", 0, NULL);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
    gtk_tree_view_append_column(GTK_TREE_VIEW(column_l), column);

    renderer = gtk_cell_renderer_text_new();
    column = gtk_tree_view_column_new_with_attributes(column_titles[1], renderer, "text", 1, NULL);
    gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
    gtk_tree_view_append_column(GTK_TREE_VIEW(column_l), column);

    /* XXX - make this match the packet list prefs? */
    sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(column_l));
    gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
    g_signal_connect(sel, "changed", G_CALLBACK(column_list_select_cb), NULL);

    gtk_container_add(GTK_CONTAINER(list_sc), column_l);
    gtk_widget_show(column_l);

    clp = g_list_first(prefs.col_list);
    while (clp) {
        cfmt    = (fmt_data *) clp->data;
        cur_fmt = get_column_format_from_str(cfmt->fmt);
        if (cur_fmt == COL_CUSTOM) {
            fmt = g_strdup_printf("%s (%s)", col_format_desc(cur_fmt), cfmt->custom_field);
        } else {
            if (cfmt->custom_field) {
                /* Delete custom_field from previous changes */
                g_free (cfmt->custom_field);
                cfmt->custom_field = NULL;
            }
            fmt = g_strdup_printf("%s", col_format_desc(cur_fmt));
        }
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(store, &iter, 0, cfmt->title, 1, fmt, 2, clp, -1);
        if (first_row) {
            first_iter = iter;
            first_row = FALSE;
        }
        clp = clp->next;
        g_free (fmt);
    }
    g_object_unref(G_OBJECT(store));

    /* Bottom row: Add/remove buttons and properties */
    bottom_hb = gtk_hbox_new(FALSE, 5);
    gtk_box_pack_start (GTK_BOX (main_vb), bottom_hb, FALSE, TRUE, 0);
    gtk_widget_show(bottom_hb);

    /* Add / remove buttons */
    add_remove_vb = gtk_vbox_new (TRUE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (add_remove_vb), 5);
    gtk_box_pack_start (GTK_BOX (bottom_hb), add_remove_vb, FALSE, FALSE, 0);
    gtk_widget_show(add_remove_vb);

    add_bt = gtk_button_new_from_stock(GTK_STOCK_ADD);
    g_signal_connect(add_bt, "clicked", G_CALLBACK(column_list_new_cb), column_l);
    gtk_box_pack_start (GTK_BOX (add_remove_vb), add_bt, FALSE, FALSE, 0);
    gtk_tooltips_set_tip (tooltips, add_bt,
                          "Add a new column at the end of the list.", NULL);
    gtk_widget_show(add_bt);

    remove_bt = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
    gtk_widget_set_sensitive(remove_bt, FALSE);
    g_signal_connect(remove_bt, "clicked", G_CALLBACK(column_list_delete_cb), column_l);
    gtk_box_pack_start (GTK_BOX (add_remove_vb), remove_bt, FALSE, FALSE, 0);
    gtk_tooltips_set_tip (tooltips, remove_bt,
                          "Remove the selected column.", NULL);
    gtk_widget_show(remove_bt);
  
    /* properties frame */
    props_fr = gtk_frame_new("Properties");
    gtk_box_pack_start (GTK_BOX (bottom_hb), props_fr, TRUE, TRUE, 0);
    gtk_widget_show(props_fr);

    /* Column name entry and format selection */
    tb = gtk_table_new(2, 2, FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(tb), 5);
    gtk_container_add(GTK_CONTAINER(props_fr), tb);
    gtk_table_set_row_spacings(GTK_TABLE(tb), 10);
    gtk_table_set_col_spacings(GTK_TABLE(tb), 15);
    gtk_widget_show(tb);

    lb = gtk_label_new("Field type:");
    gtk_misc_set_alignment(GTK_MISC(lb), 1.0f, 0.5f);
    gtk_table_attach_defaults(GTK_TABLE(tb), lb, 0, 1, 0, 1);
    gtk_tooltips_set_tip (tooltips, lb,
                          "Select which packet information to present in the column.", NULL);
    gtk_widget_show(lb);

    props_hb = gtk_hbox_new(FALSE, 5);
    gtk_table_attach(GTK_TABLE(tb), props_hb, 1, 2, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0);
    gtk_tooltips_set_tip (tooltips, props_hb,
                          "Select which packet information to present in the column.", NULL);
    gtk_widget_show(props_hb);

    field_lb = gtk_label_new("Field name:");
    gtk_misc_set_alignment(GTK_MISC(field_lb), 1.0f, 0.5f);
    gtk_table_attach_defaults(GTK_TABLE(tb), field_lb, 0, 1, 1, 2);
    gtk_widget_set_sensitive(field_lb, FALSE);
    gtk_tooltips_set_tip (tooltips, field_lb,
                          "Field name used when field type is \"Custom\". "
                          "This string has the same syntax as a display filter string.", NULL);
    gtk_widget_show(field_lb);

    field_te = gtk_entry_new();
    g_object_set_data (G_OBJECT(field_te), E_FILT_FIELD_NAME_ONLY_KEY, "");
    g_signal_connect(field_te, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);

    /* XXX: column_field_changed_cb will be called for every character entered in the entry box.      */
    /*       Consider Changing logic so that the field is "accepted" only when a return is entered ?? */
    /*       Also: entry shouldn't be accepted if it's not a valid filter ?                           */
    column_field_changed_handler_id = 
        g_signal_connect(field_te, "changed", G_CALLBACK(column_field_changed_cb), column_l);

    g_object_set_data(G_OBJECT(main_vb), E_FILT_AUTOCOMP_PTR_KEY, NULL);
    g_signal_connect(field_te, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
    g_signal_connect(prefs_window, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
    colorize_filter_te_as_empty(field_te);
    gtk_table_attach_defaults(GTK_TABLE(tb), field_te, 1, 2, 1, 2);
    gtk_widget_set_sensitive(field_te, FALSE);
    gtk_tooltips_set_tip (tooltips, field_te,
                          "Field name used when field type is \"Custom\". "
                          "This string has the same syntax as a display filter string.", NULL);
    gtk_widget_show(field_te);

    fmt_cmb = gtk_combo_box_new_text();

    for (i = 0; i < NUM_COL_FMTS; i++)
        gtk_combo_box_append_text(GTK_COMBO_BOX(fmt_cmb), col_format_desc(i));

    column_menu_changed_handler_id = g_signal_connect(fmt_cmb, "changed", G_CALLBACK(column_menu_changed_cb), column_l);

    gtk_widget_set_sensitive(fmt_cmb, FALSE);
    gtk_box_pack_start(GTK_BOX(props_hb), fmt_cmb, FALSE, FALSE, 0);
    gtk_widget_show(fmt_cmb);

    /* select the first menu list row.             */
    /*  Triggers call to column_list_select_cb().  */
    gtk_tree_selection_select_iter(sel, &first_iter);

    return(main_vb);
}
Example #11
0
GtkWidget*
listview__new()
{
	//the main pane. A treeview with a list of samples.

	LibraryView* lv = app->libraryview = g_new0(LibraryView, 1);

	lv->scroll = scrolled_window_new();

	GtkWidget* view = app->libraryview->widget = gtk_tree_view_new_with_model(GTK_TREE_MODEL(samplecat.store));
	gtk_container_add(GTK_CONTAINER(lv->scroll), view);
	g_signal_connect(view, "realize", G_CALLBACK(listview__on_realise), NULL);
	g_signal_connect(view, "motion-notify-event", (GCallback)listview__on_motion, NULL);
	g_signal_connect(view, "drag-data-received", G_CALLBACK(listview__drag_received), NULL); //currently the window traps this before we get here.
	g_signal_connect(view, "drag-motion", G_CALLBACK(drag_motion), NULL);
#if 0 // TODO why does this not work?
	gtk_tree_view_set_fixed_height_mode(GTK_TREE_VIEW(view), TRUE);
#endif

	//set up as dnd source:
	gtk_drag_source_set(view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
	                    dnd_file_drag_types, dnd_file_drag_types_count,
	                    GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
	g_signal_connect(G_OBJECT(view), "drag_data_get", G_CALLBACK(listview__dnd_get), NULL);

	//icon:
	GtkCellRenderer* cell9 = gtk_cell_renderer_pixbuf_new();
	GtkTreeViewColumn* col9 /*= app->col_icon*/ = gtk_tree_view_column_new_with_attributes("", cell9, "pixbuf", COL_ICON, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col9);
	//g_object_set(cell4,   "cell-background", "Orange",     "cell-background-set", TRUE,  NULL);
	g_object_set(G_OBJECT(cell9), "xalign", 0.0, NULL);
	gtk_tree_view_column_set_resizable(col9, TRUE);
	gtk_tree_view_column_set_min_width(col9, 0);
	gtk_tree_view_column_set_cell_data_func(col9, cell9, listview__cell_data_bg, NULL, NULL);

#ifdef SHOW_INDEX
	GtkCellRenderer* cell0 = gtk_cell_renderer_text_new();
	GtkTreeViewColumn* col0 = gtk_tree_view_column_new_with_attributes("Id", cell0, "text", COL_IDX, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col0);
#endif

	GtkCellRenderer* cell1 = lv->cells.name = gtk_cell_renderer_text_new();
	GtkTreeViewColumn* col1 = lv->col_name = gtk_tree_view_column_new_with_attributes("Sample Name", cell1, "text", COL_NAME, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col1);
	gtk_tree_view_column_set_sort_column_id(col1, COL_NAME);
	gtk_tree_view_column_set_reorderable(col1, TRUE);
	gtk_tree_view_column_set_min_width(col1, 0);
	//gtk_tree_view_column_set_spacing(col1, 10);
	//g_object_set(cell1, "ypad", 0, NULL);
	gtk_tree_view_column_set_cell_data_func(col1, cell1, (gpointer)listview__cell_data_bg, NULL, NULL);
	//gtk_tree_view_column_set_cell_data_func(col1, cell1, (gpointer)cell_bg_lighter, NULL, NULL);

	gtk_tree_view_column_set_sizing(col1, GTK_TREE_VIEW_COLUMN_FIXED);
	int width = atoi(app->config.column_widths[0]);
	if(width > 0) gtk_tree_view_column_set_fixed_width(col1, MAX(width, 30)); //FIXME set range in config section instead.
	else gtk_tree_view_column_set_fixed_width(col1, 130);

	GtkCellRenderer* cell2 = gtk_cell_renderer_text_new();
	GtkTreeViewColumn* col2 = lv->col_path = gtk_tree_view_column_new_with_attributes("Path", cell2, "text", COL_FNAME, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col2);
	gtk_tree_view_column_set_sort_column_id(col2, COL_FNAME);
	//gtk_tree_view_column_set_resizable(col2, FALSE);
	gtk_tree_view_column_set_reorderable(col2, TRUE);
	gtk_tree_view_column_set_min_width(col2, 0);
	//g_object_set(cell2, "ypad", 0, NULL);
	gtk_tree_view_column_set_cell_data_func(col2, cell2, listview__path_cell_data, NULL, NULL);
#ifdef USE_AYYI
	//icon that shows when file is in current active song.
	GtkCellRenderer* ayyi_renderer = gtk_cell_renderer_pixbuf_new();
	gtk_tree_view_column_pack_start(col2, ayyi_renderer, FALSE);
	gtk_tree_view_column_add_attribute(col2, ayyi_renderer, "pixbuf", COL_AYYI_ICON);
	//gtk_tree_view_column_set_cell_data_func(col2, ayyi_renderer, vdtree_color_cb, vdt, NULL);
#endif

	gtk_tree_view_column_set_sizing(col2, GTK_TREE_VIEW_COLUMN_FIXED);
	width = atoi(app->config.column_widths[1]);
	if(width > 0) gtk_tree_view_column_set_fixed_width(col2, MAX(width, 30));
	else gtk_tree_view_column_set_fixed_width(col2, 130);

	//GtkCellRenderer *cell3 /*= app->cell_tags*/ = gtk_cell_renderer_text_new();
	GtkCellRenderer* cell3 = lv->cells.tags = gtk_cell_renderer_hyper_text_new();
	GtkTreeViewColumn* column3 = lv->col_tags = gtk_tree_view_column_new_with_attributes("Tags", cell3, "text", COL_KEYWORDS, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), column3);
	gtk_tree_view_column_set_sort_column_id(column3, COL_KEYWORDS);
	gtk_tree_view_column_set_resizable(column3, TRUE);
	gtk_tree_view_column_set_reorderable(column3, TRUE);
	gtk_tree_view_column_set_min_width(column3, 0);
	g_object_set(cell3, "editable", TRUE, NULL);
	g_signal_connect(cell3, "edited", (GCallback)listview__on_keywords_edited, NULL);
	gtk_tree_view_column_add_attribute(column3, cell3, "markup", COL_KEYWORDS);
	gtk_tree_view_column_set_cell_data_func(column3, cell3, listview__tag_cell_data, NULL, NULL);

	GtkCellRenderer* cell4 = gtk_cell_renderer_pixbuf_new();
	GtkTreeViewColumn* col4 = lv->col_pixbuf = gtk_tree_view_column_new_with_attributes("Overview", cell4, "pixbuf", COL_OVERVIEW, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col4);
	//g_object_set(cell4,   "cell-background", "Orange",     "cell-background-set", TRUE,  NULL);
	g_object_set(G_OBJECT(cell4), "xalign", 0.0, NULL);
	gtk_tree_view_column_set_resizable(col4, TRUE);
	gtk_tree_view_column_set_min_width(col4, 0);
	//g_object_set(cell4, "ypad", 0, NULL);
	gtk_tree_view_column_set_cell_data_func(col4, cell4, listview__cell_data_bg, NULL, NULL);

	GtkCellRenderer* cell5 = gtk_cell_renderer_text_new();
	GtkTreeViewColumn* col5 = gtk_tree_view_column_new_with_attributes("Length", cell5, "text", COL_LENGTH, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col5);
	gtk_tree_view_column_set_sort_column_id(col5, COL_LEN);
	gtk_tree_view_column_set_resizable(col5, TRUE);
	gtk_tree_view_column_set_reorderable(col5, TRUE);
	gtk_tree_view_column_set_min_width(col5, 0);
	g_object_set(G_OBJECT(cell5), "xalign", 1.0, NULL);
	//g_object_set(cell5, "ypad", 0, NULL);
	gtk_tree_view_column_set_cell_data_func(col5, cell5, listview__cell_data_bg, NULL, NULL);

	GtkCellRenderer* cell6 = gtk_cell_renderer_text_new();
	GtkTreeViewColumn* col6 = gtk_tree_view_column_new_with_attributes("Srate", cell6, "text", COL_SAMPLERATE, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col6);
	gtk_tree_view_column_set_resizable(col6, TRUE);
	gtk_tree_view_column_set_reorderable(col6, TRUE);
	gtk_tree_view_column_set_min_width(col6, 0);
	g_object_set(G_OBJECT(cell6), "xalign", 1.0, NULL);
	//g_object_set(cell6, "ypad", 0, NULL);
	gtk_tree_view_column_set_cell_data_func(col6, cell6, listview__cell_data_bg, NULL, NULL);

	GtkCellRenderer* cell7 = gtk_cell_renderer_text_new();
	GtkTreeViewColumn* col7 = gtk_tree_view_column_new_with_attributes("Chs", cell7, "text", COL_CHANNELS, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col7);
	gtk_tree_view_column_set_resizable(col7, TRUE);
	gtk_tree_view_column_set_reorderable(col7, TRUE);
	gtk_tree_view_column_set_min_width(col7, 0);
	g_object_set(G_OBJECT(cell7), "xalign", 1.0, NULL);
	gtk_tree_view_column_set_cell_data_func(col7, cell7, listview__cell_data_bg, NULL, NULL);

	GtkCellRenderer* cell8 = gtk_cell_renderer_text_new();
	GtkTreeViewColumn* col8 = gtk_tree_view_column_new_with_attributes("Mimetype", cell8, "text", COL_MIMETYPE, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), col8);
	gtk_tree_view_column_set_resizable(col8, TRUE);
	gtk_tree_view_column_set_reorderable(col8, TRUE);
	gtk_tree_view_column_set_min_width(col8, 0);
	//g_object_set(G_OBJECT(cell8), "xalign", 1.0, NULL);
	gtk_tree_view_column_set_cell_data_func(col8, cell8, listview__cell_data_bg, NULL, NULL);

	GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
	gtk_tree_view_set_search_column(GTK_TREE_VIEW(view), COL_NAME);

	g_signal_connect((gpointer)view, "button-press-event", G_CALLBACK(listview__on_row_clicked), NULL);
	g_signal_connect((gpointer)view, "cursor-changed", G_CALLBACK(listview__on_cursor_change), NULL);
	g_signal_connect(G_OBJECT(samplecat.store), "content-changed", G_CALLBACK(listview__on_store_changed), NULL);

#if 0
	void on_unrealize(GtkWidget* widget, gpointer user_data)
	{
		PF0;
	}
	g_signal_connect((gpointer)view, "unrealize", G_CALLBACK(on_unrealize), NULL);
#endif

	void listview_on_play(GObject* _app, gpointer _)
	{
		if(app->play.sample->row_ref){
			listview__highlight_playing_by_ref(app->play.sample->row_ref);
		}
	}

	g_signal_connect(app, "play-start", (GCallback)listview_on_play, NULL);

	void on_sort_order_changed(GtkTreeSortable* sortable, gpointer user_data)
	{
		gint sort_column_id;
		GtkSortType order;
		if(gtk_tree_sortable_get_sort_column_id(sortable, &sort_column_id, &order)){
			if(sort_column_id == COL_LEN){
				int n_rows = ((SamplecatListStore*)samplecat.store)->row_count;
				if(n_rows >= LIST_STORE_MAX_ROWS){
					dbg(0, "TODO need to requery database ordered by length...");
				}
			}
		}
	}