Example #1
0
static GtkTreeViewColumn *divelist_column(struct DiveList *dl, int index, const char *title,
					data_func_t data_func, PangoAlignment align)
{
	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, NULL, 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_append_column(GTK_TREE_VIEW(dl->tree_view), col);
	return col;
}
Example #2
0
static GtkTreeViewColumn *new_column(int type, int width, const char *title, ...){
    GtkTreeViewColumn *col;
    GtkCellRenderer *render=NULL;
    col=gtk_tree_view_column_new();
    switch(type){
    case 0:
	render=gtk_cell_renderer_text_new();
#if GTK_MAJOR_VERSION>=3 || GTK_MINOR_VERSION >= 18
	gtk_cell_renderer_set_padding(render, 1, 1);
	gtk_cell_renderer_set_alignment(render, 1, 0.5);
#endif
	break;
    case 1:
	render=gtk_cell_renderer_progress_new();
	break;
    case 2:
	render=gtk_cell_renderer_pixbuf_new();
	break;
    default:
	error("Invalid\n");
    }
    gtk_tree_view_column_set_title(col, title);
    gtk_tree_view_column_set_spacing(col, 2);
    gtk_tree_view_column_set_alignment(col, 1);
    gtk_tree_view_column_set_resizable(col, TRUE);
    //gtk_tree_view_column_set_clickable(col, TRUE);
    //gtk_tree_view_column_set_expand(col,FALSE);
    if(width>0){//Adjustable columns
	//Do not set min_width if set resizable.
	//gtk_tree_view_column_set_min_width(col, width);
	gtk_tree_view_column_set_expand(col,TRUE);
	//resizable is not good if expand
	gtk_tree_view_column_set_resizable(col, FALSE);
	if(type==0){
	    g_object_set(G_OBJECT(render),"ellipsize",PANGO_ELLIPSIZE_START,NULL);
	}
    }else if(width<0){/*max width*/
	gtk_tree_view_column_set_min_width(col,-width/10);
	gtk_tree_view_column_set_max_width(col,-width);
    }
    gtk_tree_view_column_pack_start(col,render,TRUE);
    va_list ap;
    va_start(ap, title);
    const char *att=NULL;
    while((att=va_arg(ap, const char *))){
	gtk_tree_view_column_add_attribute(col, render, att, va_arg(ap,int));
    }
    va_end(ap);
    return col;
}
Example #3
0
GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char *title,
				data_func_t data_func, unsigned int flags)
{
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *col;
	double xalign = 0.0; /* left as default */
	PangoAlignment align;
	gboolean visible;

	align = (flags & ALIGN_LEFT) ? PANGO_ALIGN_LEFT :
		(flags & ALIGN_RIGHT) ? PANGO_ALIGN_RIGHT :
		PANGO_ALIGN_CENTER;
	visible = !(flags & INVISIBLE);

	renderer = gtk_cell_renderer_text_new();
	col = gtk_tree_view_column_new();

	gtk_tree_view_column_set_title(col, title);
	if (!(flags & UNSORTABLE))
		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;
}
Example #4
0
void plugin_init(GeanyData *data)
{
	conf = g_build_path(G_DIR_SEPARATOR_S, geany_data->app->configdir, "plugins", "quick-find.conf", NULL);
	config = g_key_file_new();
	g_key_file_load_from_file(config, conf, G_KEY_FILE_NONE, NULL);
	executable = utils_get_setting_string(config, "main", "executable", DEFAULT_EXECUTABLE);

	trim_file = g_regex_new(g_strconcat("^.*", G_DIR_SEPARATOR_S, NULL), G_REGEX_OPTIMIZE | G_REGEX_CASELESS, 0, NULL);
	trim_regex = g_regex_new("\n$", G_REGEX_OPTIMIZE | G_REGEX_CASELESS, 0, NULL);
	
	label = gtk_label_new(_("Find"));
	panel = gtk_vbox_new(FALSE, 6);
	scrollable_table = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollable_table), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

	gtk_box_pack_start(GTK_BOX(panel), scrollable_table, TRUE, TRUE, 0);
	gtk_notebook_append_page(GTK_NOTEBOOK(geany->main_widgets->sidebar_notebook), panel, label);
	
	entry = gtk_entry_new();
	gtk_entry_set_icon_from_stock(GTK_ENTRY(entry), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_FIND);
	g_signal_connect(entry, "activate", G_CALLBACK(on_activate), NULL);
	
	GtkWidget *button_box = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(button_box), entry, TRUE, TRUE, 0);
	
	GtkWidget *button = gtk_button_new_with_label(_("Find"));
	g_signal_connect(button, "clicked", G_CALLBACK(on_click), NULL);
	gtk_box_pack_end(GTK_BOX(button_box), button, FALSE, TRUE, 0);
	
	check_case = gtk_check_button_new_with_label(_("Case Sensitive"));
	ui_widget_set_tooltip_text(check_case, _("Perform a case-sensitive search."));
	
	gtk_box_pack_end(GTK_BOX(panel), check_case, FALSE, TRUE, 0);
	gtk_box_pack_end(GTK_BOX(panel), button_box, FALSE, TRUE, 0);
	gtk_container_set_focus_child(GTK_CONTAINER(panel), entry);

	GtkTreeViewColumn *number_column, *line_column, *file_column, *text_column;
	GtkCellRenderer *render;
	
	list = gtk_tree_store_new(4, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
	tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list));

	render = gtk_cell_renderer_text_new();
	number_column = gtk_tree_view_column_new_with_attributes("#", render, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), number_column);
	gtk_tree_view_column_set_alignment(number_column, 1.0);
	gtk_cell_renderer_set_alignment(render, 1.0, 0.0);
	gtk_tree_view_column_add_attribute(number_column, render, "text", 0);
	
	render = gtk_cell_renderer_text_new();
	line_column = gtk_tree_view_column_new_with_attributes("Line", render, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), line_column);
	gtk_tree_view_column_set_alignment(line_column, 1.0);
	gtk_cell_renderer_set_alignment(render, 1.0, 0.0);
	gtk_tree_view_column_add_attribute(line_column, render, "text", 1);
	
	render = gtk_cell_renderer_text_new();
	file_column = gtk_tree_view_column_new_with_attributes("File", render, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), file_column);
	gtk_tree_view_column_add_attribute(file_column, render, "text", 2);
	gtk_tree_view_column_set_cell_data_func(file_column, render, (GtkTreeCellDataFunc)cell_data, NULL, NULL);
	
	render = gtk_cell_renderer_text_new();
	text_column = gtk_tree_view_column_new_with_attributes("Text", render, NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), text_column);
	gtk_tree_view_column_add_attribute(text_column, render, "text", 3);

	g_object_unref(GTK_TREE_MODEL(list));
	GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
	g_signal_connect(select, "changed", G_CALLBACK(selected_row), NULL);
	
	gtk_container_add(GTK_CONTAINER(scrollable_table), tree);
	gtk_widget_show(label);
	gtk_widget_show_all(panel);
	
	g_signal_connect(geany->main_widgets->window, "key-release-event", G_CALLBACK(panel_focus_tab), NULL);

	GeanyKeyGroup *key_group;
	key_group = plugin_set_key_group(geany_plugin, "quick_find_keyboard_shortcut", KB_GROUP, NULL);
	keybindings_set_item(key_group, KB_QUICK_FIND, entry_focus, 0, 0, "quick_find", _("Quick Find..."), NULL);
}
bool change_restrictions(int vars)
{
    /* Clear model */
    clear_liststore(restrictions_view);

    /* Create the dynamic types array */
    int size = vars + 2;
    GType* types = (GType*) malloc(3 * size * sizeof(GType));
    if(types == NULL) {
        return false;
    }

    /* Set type in the dynamic types array */
    for(int i = 0; i < size; i++) {
        types[i] = G_TYPE_INT;               /* Coeffs */
        types[size + i] = G_TYPE_STRING;     /* Text   */
        types[2 * size + i] = G_TYPE_STRING; /* Signs  */
    }

    /* Create the new model */
    GtkListStore* restrictions = gtk_list_store_newv(3 * size, types);

    /* Clear the previous columns */
    for(int i = gtk_tree_view_get_n_columns(restrictions_view) - 1; i >= 0; i--) {
        gtk_tree_view_remove_column(
                                restrictions_view,
                                gtk_tree_view_get_column(restrictions_view, i)
                            );
    }

    /* Create the new columns */
    for(int i = 0; i < size; i++) {

        /* Especial column for type */
        if(i == (size - 2)) {
            GtkCellRenderer* type = gtk_cell_renderer_text_new();
            GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes(
                                        "", type,  /* Title, renderer */
                                        "markup", size + i,
                                        NULL);
            gtk_tree_view_append_column(restrictions_view, column);
            continue;
        }

        /* Create sign column */
        if((i != 0) && (i != size - 1)) {
            GtkCellRenderer* sign = gtk_cell_renderer_text_new();
            GtkTreeViewColumn* sign_c =
                gtk_tree_view_column_new_with_attributes(
                                            "", sign,  /* Title, renderer */
                                            "markup", 2 * size + i,
                                            NULL);
            gtk_tree_view_append_column(restrictions_view, sign_c);
        }

        /* Create text column */
        /* Create and configure cell */
        GtkCellRenderer* cell = gtk_cell_renderer_spin_new();

        gtk_cell_renderer_set_alignment(cell, 1.0, 0.5);
        g_object_set(cell, "editable", true, NULL);

        /* Configure callbacks */
        g_signal_connect(G_OBJECT(cell),
                    "editing-started", G_CALLBACK(restrictions_edit_started_cb),
                    GINT_TO_POINTER(i));
        restrictions_edit_started_cb(cell, NULL, NULL, GINT_TO_POINTER(i));

        if(i < size - 2) {
            g_signal_connect(G_OBJECT(cell),
                         "edited", G_CALLBACK(restrictions_edited_cb),
                         GINT_TO_POINTER(i));
        } else {
            g_signal_connect(G_OBJECT(cell),
                         "edited", G_CALLBACK(num_edited_cb),
                         GINT_TO_POINTER(i));
        }

        /* Configure column */
        GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes(
                                        "", cell,  /* Title, renderer */
                                        "markup", size + i,
                                        NULL);
        gtk_tree_view_column_set_min_width(column, 100);
        gtk_tree_view_append_column(restrictions_view, column);
    }
    gtk_tree_view_append_column(restrictions_view, gtk_tree_view_column_new());

    /* Set the new model */
    gtk_tree_view_set_model(restrictions_view, GTK_TREE_MODEL(restrictions));

    /* Free resources */
    g_object_unref(G_OBJECT(restrictions));
    free(types);

    return true;
}
bool change_function(int vars)
{
    /* Clear model */
    clear_liststore(function_view);

    /* Create the dynamic types array */
    GType* types = (GType*) malloc(3 * vars * sizeof(GType));
    if(types == NULL) {
        return false;
    }

    /* Set type in the dynamic types array */
    for(int i = 0; i < vars; i++) {
        types[i] = G_TYPE_INT;               /* Coeffs */
        types[vars + i] = G_TYPE_STRING;     /* Text   */
        types[2 * vars + i] = G_TYPE_STRING; /* Signs  */
    }

    /* Create and fill the new model */
    GtkListStore* function = gtk_list_store_newv(3 * vars, types);
    GtkTreeIter iter;

    GValue initi = G_VALUE_INIT;
    g_value_init(&initi, G_TYPE_INT);

    GValue inits = G_VALUE_INIT;
    g_value_init(&inits, G_TYPE_STRING);

    gtk_list_store_append(function, &iter);
    for(int i = 0; i < vars; i++) {

        g_value_set_int(&initi, 1);
        gtk_list_store_set_value(function, &iter, i, &initi);

        char* text = var_name(1, i, false);
        g_value_set_string(&inits, text);
        gtk_list_store_set_value(function, &iter, vars + i, &inits);
        free(text);

        g_value_set_string(&inits, PLUS);
        gtk_list_store_set_value(function, &iter, 2 * vars + i, &inits);
    }

    /* Clear the previous columns */
    for(int i = gtk_tree_view_get_n_columns(function_view) - 1; i >= 0; i--) {
        gtk_tree_view_remove_column(
                                function_view,
                                gtk_tree_view_get_column(function_view, i)
                            );
    }

    /* Create the new columns */
    for(int i = 0; i < vars; i++) {

        /* Create sign column */
        if(i > 0) {
            GtkCellRenderer* sign = gtk_cell_renderer_text_new();
            GtkTreeViewColumn* sign_c =
                gtk_tree_view_column_new_with_attributes(
                                            "", sign,  /* Title, renderer */
                                            "markup", 2 * vars + i,
                                            NULL);
            gtk_tree_view_append_column(function_view, sign_c);
        }

        /* Create text column */
        /* Create and configure cell */
        GtkCellRenderer* cell = gtk_cell_renderer_spin_new();

        gtk_cell_renderer_set_alignment(cell, 1.0, 0.5);
        g_object_set(cell, "editable", true, NULL);

        /* Configure callbacks */
        g_signal_connect(G_OBJECT(cell),
                    "editing-started", G_CALLBACK(function_edit_started_cb),
                    GINT_TO_POINTER(i));
        function_edit_started_cb(cell, NULL, NULL, GINT_TO_POINTER(i));

        g_signal_connect(G_OBJECT(cell),
                         "edited", G_CALLBACK(function_edited_cb),
                         GINT_TO_POINTER(i));

        /* Configure column */
        GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes(
                                        "", cell,  /* Title, renderer */
                                        "markup", vars + i,
                                        NULL);
        gtk_tree_view_column_set_min_width(column, 100);
        gtk_tree_view_append_column(function_view, column);
    }
    gtk_tree_view_append_column(function_view, gtk_tree_view_column_new());

    /* Set the new model */
    gtk_tree_view_set_model(function_view, GTK_TREE_MODEL(function));

    /* Free resources */
    g_object_unref(G_OBJECT(function));
    free(types);

    return true;
}
Example #7
0
static ddb_gtkui_widget_t *
w_pltbrowser_create (void) {
    w_pltbrowser_t *w = malloc (sizeof (w_pltbrowser_t));
    memset (w, 0, sizeof (w_pltbrowser_t));

    w->base.widget = gtk_event_box_new ();
    w->base.init = w_pltbrowser_init;
    w->base.message = pltbrowser_message;
    w->base.initmenu = w_pltbrowser_initmenu;

    gtk_widget_set_can_focus (w->base.widget, FALSE);

    GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL);
    gtk_widget_set_can_focus (scroll, FALSE);
    gtk_widget_show (scroll);
    gtk_container_add (GTK_CONTAINER (w->base.widget), scroll);

    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_ETCHED_IN);
    w->tree = gtk_tree_view_new ();
    gtk_tree_view_set_reorderable (GTK_TREE_VIEW (w->tree), TRUE);
    gtk_tree_view_set_enable_search (GTK_TREE_VIEW (w->tree), TRUE);
    GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (w->tree));
    gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
    gtk_widget_show (w->tree);

    gtk_container_add (GTK_CONTAINER (scroll), w->tree);

    GtkListStore *store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
    gtk_tree_view_set_model (GTK_TREE_VIEW (w->tree), GTK_TREE_MODEL (store));

    w->ri_id = g_signal_connect ((gpointer) store, "row_inserted", G_CALLBACK (on_pltbrowser_row_inserted), w);

    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (w->tree), TRUE);

    GtkCellRenderer *rend1 = gtk_cell_renderer_text_new ();
    GtkCellRenderer *rend2 = gtk_cell_renderer_text_new ();

    GtkTreeViewColumn *col1 = gtk_tree_view_column_new_with_attributes (_("Name"), rend1, "text", 0, NULL);
    GtkTreeViewColumn *col2 = gtk_tree_view_column_new_with_attributes (_("Items"), rend2, "text", 1, NULL);
    gtk_tree_view_append_column (GTK_TREE_VIEW (w->tree), col1);
    gtk_tree_view_append_column (GTK_TREE_VIEW (w->tree), col2);

    gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (w->tree), TRUE);

    int showheaders = deadbeef->conf_get_int ("gtkui.pltbrowser.show_headers", 1);
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (w->tree), showheaders);

    gtk_cell_renderer_set_alignment (GTK_CELL_RENDERER (rend2), 1.0, 0.0);

    w->cc_id = g_signal_connect ((gpointer) w->tree, "cursor_changed",
            G_CALLBACK (on_pltbrowser_cursor_changed),
            w);
    g_signal_connect ((gpointer) w->tree, "event_after",
            G_CALLBACK (on_pltbrowser_button_press_event),
            w);
    g_signal_connect ((gpointer) w->tree, "row_activated",
            G_CALLBACK (on_pltbrowser_row_activated),
            w);

    gtkui_plugin->w_override_signals (w->base.widget, w);

    return (ddb_gtkui_widget_t *)w;
}
void Operator_manage(GtkWidget * UNUSED(widget), GtkWindow * parent) {
    GtkWidget * dialog;
    GtkWidget *hbox;
    GtkWidget * bbox;
    GtkWidget * sw;
    GtkTreeModel * model;
    GtkWidget *treeview;
    GtkWidget * button;
    GtkCellRenderer * renderer;
    GtkTreeViewColumn *column;

    /** Creation de la fenêtre principale */
    dialog = gtk_dialog_new_with_buttons("Gestion des opérateurs", parent, GTK_DIALOG_MODAL
            | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);

    gtk_container_set_border_width(GTK_CONTAINER (dialog), 5);

    hbox = gtk_hbox_new(FALSE, 5);
    gtk_box_pack_start(GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, TRUE, TRUE, 0);

    sw = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC,
            GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(GTK_BOX (hbox), sw, TRUE, TRUE, 0);

    model = gtk_tree_model_sort_new_with_model(Operator_loadModel());

    /* create tree view */
    treeview = gtk_tree_view_new_with_model(model);
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW (treeview), TRUE);
    gtk_tree_view_set_search_column(GTK_TREE_VIEW (treeview), 0);

    renderer = gtk_cell_renderer_text_new();

    column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title(column, "Opérateur");
    gtk_tree_view_column_pack_start(column, renderer, TRUE);
    gtk_tree_view_column_add_attribute(column, renderer, "text", 0);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_column_set_min_width(column, 300);
    gtk_tree_view_column_set_sort_column_id(column, 0);
    gtk_tree_view_column_set_alignment(column, 0.5);
    gtk_cell_renderer_set_alignment(renderer, 0, 0.5);
    gtk_tree_view_append_column(GTK_TREE_VIEW (treeview), column);

    gtk_widget_set_size_request(sw, 350, 400);
    gtk_widget_show(treeview);

    g_object_unref(model);

    gtk_container_add(GTK_CONTAINER (sw), treeview);

    bbox = gtk_vbutton_box_new();
    gtk_button_box_set_layout(GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START);
    gtk_box_set_spacing(GTK_BOX (bbox), 5);
    gtk_box_pack_start(GTK_BOX (hbox), bbox, TRUE, TRUE, 0);
    gtk_widget_show(bbox);

    button = gtk_button_new_with_label("Ajouter");
    g_signal_connect (button, "clicked", G_CALLBACK (Operator_add), treeview);
    gtk_container_add(GTK_CONTAINER (bbox), button);
    gtk_widget_show(button);

    button = gtk_button_new_with_label("Supprimer");
    g_signal_connect (button, "clicked", G_CALLBACK (Operator_delete), treeview);
    gtk_container_add(GTK_CONTAINER (bbox), button);
    gtk_widget_show(button);

    button = gtk_button_new_with_label("Modifier");
    g_signal_connect (button, "clicked", G_CALLBACK (Operator_modify), treeview);
    gtk_container_add(GTK_CONTAINER (bbox), button);

    gtk_widget_show_all(hbox);

    gtk_dialog_run(GTK_DIALOG (dialog));
    gtk_widget_destroy(dialog);

}
static void xmi_msim_gui_layer_dialog_init(XmiMsimGuiLayerDialog *dialog) {
  gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
  gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
  gtk_dialog_add_buttons(GTK_DIALOG(dialog), "_Ok", GTK_RESPONSE_ACCEPT, "_Cancel", GTK_RESPONSE_REJECT, NULL);
  gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
  gtk_window_set_default_size(GTK_WINDOW(dialog), 200, 200);

  GtkWidget *contentArea = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
  GtkWidget *mainVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_box_set_homogeneous(GTK_BOX(mainVBox), FALSE);
  gtk_container_set_border_width(GTK_CONTAINER(mainVBox),5);
  gtk_container_add(GTK_CONTAINER(contentArea), mainVBox);

  GtkListStore *store = gtk_list_store_new(N_COLUMNS_LAYER, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INT);
  //construct tree
  GtkWidget *HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
  gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE);
  GtkWidget *compositionTreeView = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
  GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
  gtk_cell_renderer_set_alignment(renderer, 0.5, 0.5);
  GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes("Element", renderer, "text", SYMBOL_COLUMN, NULL);
  gtk_tree_view_column_set_resizable(column, TRUE);
  gtk_tree_view_column_set_alignment(column, 0.5);
  gtk_tree_view_append_column(GTK_TREE_VIEW(compositionTreeView), column);

  renderer = gtk_cell_renderer_text_new();
  gtk_cell_renderer_set_alignment(renderer, 0.5, 0.5);
  column = gtk_tree_view_column_new_with_attributes("Weight fraction (%)", renderer, "text", WEIGHT_COLUMN, NULL);
  gtk_tree_view_column_set_resizable(column, TRUE);
  gtk_tree_view_column_set_alignment(column, 0.5);
  gtk_tree_view_append_column(GTK_TREE_VIEW(compositionTreeView), column);

  GtkWidget *scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_widget_set_size_request(scrolledWindow, 220, 150);
  gtk_container_add(GTK_CONTAINER(scrolledWindow), compositionTreeView);
  GtkWidget *frame = gtk_frame_new(NULL);
  gtk_container_add(GTK_CONTAINER(frame), scrolledWindow);
  gtk_box_pack_start(GTK_BOX(HBox), frame, FALSE, FALSE, 3);

  //selections
  GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(compositionTreeView));
  gtk_tree_selection_set_mode(select, GTK_SELECTION_MULTIPLE);
  g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(element_selection_changed), (gpointer) dialog);


  //add/edit/remove
  GtkWidget *VBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_box_set_homogeneous(GTK_BOX(VBox), FALSE);
  GtkWidget *addButton = gtk_button_new_with_mnemonic("_Add");
  GtkWidget *editButton = gtk_button_new_with_mnemonic("_Edit");
  GtkWidget *removeButton = gtk_button_new_with_mnemonic("_Remove");
  GtkWidget *predefButton = gtk_button_new_with_label("Load from catalog");
  GtkWidget *addToCatalogButton = gtk_button_new_with_label("Add to catalog");

  gtk_widget_set_sensitive(addButton, TRUE);
  gtk_widget_set_sensitive(editButton, FALSE);
  gtk_widget_set_sensitive(removeButton, FALSE);
  gtk_widget_set_sensitive(predefButton, TRUE);
  gtk_widget_set_sensitive(addToCatalogButton, FALSE);

  gtk_box_pack_start(GTK_BOX(VBox), addButton, TRUE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(VBox), editButton, TRUE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(VBox), removeButton, TRUE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(VBox), predefButton, TRUE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(VBox), addToCatalogButton, TRUE, FALSE, 3);

  gtk_box_pack_start(GTK_BOX(HBox),VBox, FALSE, FALSE, 3);
  gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3);

  g_signal_connect(G_OBJECT(addButton), "clicked", G_CALLBACK(add_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(editButton), "clicked", G_CALLBACK(edit_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(removeButton), "clicked", G_CALLBACK(remove_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(predefButton), "clicked", G_CALLBACK(predef_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(addToCatalogButton), "clicked", G_CALLBACK(add_to_catalog_button_clicked), (gpointer) dialog);
  g_signal_connect(G_OBJECT(compositionTreeView), "row-activated", G_CALLBACK(element_row_activated), (gpointer) dialog);

  //Sum and normalize
  HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE);
  GtkWidget *label = gtk_label_new("Weights sum (%)");
  GtkWidget *sumLabel = gtk_label_new("");
  gtk_label_set_justify(GTK_LABEL(sumLabel), GTK_JUSTIFY_CENTER);
  GtkWidget *normalizeButton = gtk_button_new_with_label("Normalize");
  gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(HBox), sumLabel, TRUE, TRUE, 2);
  gtk_box_pack_start(GTK_BOX(HBox), normalizeButton, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3);
  g_signal_connect(G_OBJECT(normalizeButton), "clicked", G_CALLBACK(normalize_button_clicked), (gpointer) dialog);

  //separator
  GtkWidget *separator = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start(GTK_BOX(mainVBox), separator, FALSE, FALSE, 3);

  //Density and thickness
  HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE);
  label = gtk_label_new(NULL);
  gtk_label_set_markup(GTK_LABEL(label),"Density (g/cm<sup>3</sup>)");
  GtkWidget *densityEntry = gtk_entry_new();
  gtk_widget_set_name(densityEntry, "color_entry");
  gtk_entry_set_activates_default(GTK_ENTRY(densityEntry), TRUE);
  gulong density_changed = g_signal_connect(G_OBJECT(densityEntry), "changed", G_CALLBACK(density_thickness_changed), (gpointer) dialog);
  gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2);
  gtk_box_pack_end(GTK_BOX(HBox), densityEntry, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3);
  HBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_box_set_homogeneous(GTK_BOX(HBox), FALSE);
  label = gtk_label_new("Thickness (cm)");
  GtkWidget *thicknessEntry = gtk_entry_new();
  gtk_widget_set_name(thicknessEntry, "color_entry");
  gtk_entry_set_activates_default(GTK_ENTRY(thicknessEntry), TRUE);
  gulong thickness_changed = g_signal_connect(G_OBJECT(thicknessEntry), "changed", G_CALLBACK(density_thickness_changed), (gpointer) dialog);
  gtk_box_pack_start(GTK_BOX(HBox), label, FALSE, FALSE, 2);
  gtk_box_pack_end(GTK_BOX(HBox), thicknessEntry, FALSE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(mainVBox), HBox, FALSE, FALSE, 3);

  dialog->addButton = addButton;
  dialog->editButton = editButton;
  dialog->removeButton = removeButton;
  dialog->predefButton = predefButton;
  dialog->addToCatalogButton = addToCatalogButton;
  dialog->normalizeButton = normalizeButton;
  dialog->sumLabel = sumLabel;
  dialog->densityEntry = densityEntry;
  dialog->thicknessEntry = thicknessEntry;
  dialog->compositionTreeView = compositionTreeView;
  dialog->density_changed = density_changed;
  dialog->thickness_changed = thickness_changed;

  g_signal_connect(G_OBJECT(compositionTreeView), "key-press-event", G_CALLBACK(backspace_key_clicked), (gpointer) dialog);

  gtk_widget_show_all(contentArea);

}
Example #10
0
static void quick_opener()
{
	GtkWidget *entry, *label, *hbox;
	GtkTreeViewColumn *path_column, *name_column;
	GtkCellRenderer *renderLeft, *renderRight;

	dialog = gtk_dialog_new_with_buttons(_("Quick Open:"),
		GTK_WINDOW(geany->main_widgets->window),
		GTK_DIALOG_DESTROY_WITH_PARENT,NULL);
	gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 250);

	gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Open"), GTK_RESPONSE_APPLY);
	gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Cancel"), GTK_RESPONSE_CANCEL);
	
	hbox=gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),hbox, FALSE, FALSE, 0);

	label=gtk_label_new(_("File:"));
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);

	entry = gtk_entry_new();
	g_signal_connect(entry, "key-press-event", G_CALLBACK(onkeypress), NULL);
	g_signal_connect(entry, "key-release-event", G_CALLBACK(onkeyrelease), NULL);

	gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 2);
	
	//Table:
	
	list = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
	tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list));
	GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);

	path_column = gtk_tree_view_column_new();
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), path_column);
	name_column = gtk_tree_view_column_new();
	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), name_column);
	
	renderRight = gtk_cell_renderer_text_new();
	gtk_cell_renderer_set_alignment(renderRight, 1.0, 0.0);
	gtk_cell_renderer_set_padding(renderRight, 0, 1);
	g_object_set(renderRight, "foreground", "#777", "foreground-set", TRUE, NULL);
	
	renderLeft = gtk_cell_renderer_text_new();
	gtk_cell_renderer_set_padding(renderLeft, 0, 1);
	
	gtk_tree_view_column_pack_start(path_column, renderRight, TRUE);
	gtk_tree_view_column_add_attribute(path_column, renderRight, "text", 0);
	gtk_tree_view_column_pack_start(name_column, renderLeft, TRUE);
	gtk_tree_view_column_add_attribute(name_column, renderLeft, "text", 1);

	g_object_unref(list);
	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);

	//Scrollable:
	scrollable = gtk_scrolled_window_new(NULL, NULL);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollable), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(scrollable), tree);
	g_signal_connect(tree, "key-press-event", G_CALLBACK(tree_keypress), entry);

	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), scrollable, TRUE, TRUE, 10);
	gtk_widget_show_all(dialog);
	
	adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrollable));
	first = gtk_tree_path_new_from_string("0");
	second = gtk_tree_path_new_from_string("1");

	gint response = gtk_dialog_run(GTK_DIALOG(dialog));
	if(response == GTK_RESPONSE_APPLY) {
		submit();
	}
	gtk_widget_destroy(dialog);
}
Example #11
0
void create_commodity_register(gchar *guid, gchar *fullname) {
    struct commodity_register *commodity_register = g_malloc(sizeof(struct commodity_register));

    /* Record information in the descriptor */
    commodity_register->guid = guid;
    commodity_register->fullname = fullname;
    COMMODITY_REGISTER_CORE.window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
    COMMODITY_REGISTER_CORE.scrolled_window = gtk_scrolled_window_new (NULL,NULL);
    COMMODITY_REGISTER_CORE.view = GTK_TREE_VIEW(gtk_tree_view_new ());
    COMMODITY_REGISTER_CORE.selection = gtk_tree_view_get_selection(COMMODITY_REGISTER_CORE.view);

    /* Create the model/store */
    create_commodity_register_model(commodity_register);

    /* Column setup */
    /* Timestamp */
    {
        GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
        g_signal_connect(renderer,
                         "edited",
                         G_CALLBACK(timestamp_edited),
                         commodity_register);
        g_object_set(renderer, "editable", TRUE, NULL);
        /* Add timestamp column to the view */
        gtk_tree_view_insert_column_with_attributes (COMMODITY_REGISTER_CORE.view,
                                                     -1,
                                                     "Time-stamp",
                                                     renderer,
                                                     "text",
                                                     STORE_TIMESTAMP,
                                                     NULL);
        commodity_register->timestamp_renderer = renderer;
    }
    /* Price */
    {
        GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
        GtkTreeViewColumn *column;
        g_signal_connect(renderer,
                         "edited",
                         G_CALLBACK(price_edited),
                         commodity_register);
        g_object_set(renderer, "editable", TRUE, NULL);
        gtk_tree_view_insert_column_with_attributes (COMMODITY_REGISTER_CORE.view,
                                                     -1,
                                                     "Price",
                                                     renderer,
                                                     "text",
                                                     STORE_PRICE,
                                                     NULL);
        column = gtk_tree_view_get_column(COMMODITY_REGISTER_CORE.view, VIEW_PRICE);
        /* Right-justify the value column header */
        gtk_tree_view_column_set_alignment(column, 1.0);
        /* Set up the data formatter */
        gtk_tree_view_column_set_cell_data_func(column, renderer, price_formatter, NULL, NULL);
        /* Make renderer right-justify the data */
        gtk_cell_renderer_set_alignment(renderer, 1.0, .5);
    }

    /* Grid lines for readability */
    g_object_set (COMMODITY_REGISTER_CORE.view, "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH,
                  NULL);

    /* Set geometry hints */
    set_geometry_hints(GTK_WINDOW(COMMODITY_REGISTER_CORE.window), COMMODITY_WINDOW_WIDTH, COMMODITY_WINDOW_HEIGHT);

    gtk_container_add (GTK_CONTAINER (COMMODITY_REGISTER_CORE.scrolled_window), GTK_WIDGET(COMMODITY_REGISTER_CORE.view));
    gtk_container_add (GTK_CONTAINER (COMMODITY_REGISTER_CORE.window), GTK_WIDGET(COMMODITY_REGISTER_CORE.scrolled_window));

    /* Set window title to commodity name */
    gtk_window_set_title(COMMODITY_REGISTER_CORE.window, commodity_register->fullname);

    /* Clean up memory allocations if window is destroyed */
    g_signal_connect (COMMODITY_REGISTER_CORE.window, "destroy", G_CALLBACK (cleanup), commodity_register);

    /* Signal button press event */
    g_signal_connect(COMMODITY_REGISTER_CORE.view, "button-press-event", (GCallback) mouse_button_pressed, commodity_register);

    /* Signal key press event */
    g_signal_connect(COMMODITY_REGISTER_CORE.view, "key-press-event", (GCallback) key_pressed, commodity_register);

    /* Set the view's selection mode */
    gtk_tree_selection_set_mode(COMMODITY_REGISTER_CORE.selection, GTK_SELECTION_BROWSE);

    gtk_widget_show_all (GTK_WIDGET(COMMODITY_REGISTER_CORE.window));
}
Example #12
0
FeedListView *
feed_list_view_create (GtkTreeView *treeview)
{
	GtkCellRenderer		*titleRenderer, *countRenderer;
	GtkCellRenderer		*iconRenderer;
	GtkTreeViewColumn 	*column, *column2;
	GtkTreeSelection	*select;

	debug_enter ("feed_list_view_create");

	/* Set up store */
	g_assert (NULL == flv);
	flv = FEED_LIST_VIEW (g_object_new (FEED_LIST_VIEW_TYPE, NULL));

	flv->treeview = treeview;
	flv->feedstore = gtk_tree_store_new (FS_LEN,
	                                     G_TYPE_STRING,
   	                                     G_TYPE_ICON,
	                                     G_TYPE_POINTER,
	                                     G_TYPE_UINT,
	                                     G_TYPE_STRING);

	gtk_tree_view_set_model (GTK_TREE_VIEW (flv->treeview), GTK_TREE_MODEL (flv->feedstore));

	/* Prepare filter */
	flv->filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (flv->feedstore), NULL);
	gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (flv->filter),
	                                        feed_list_view_filter_visible_function,
	                                        NULL,
	                                        NULL);

	g_signal_connect (G_OBJECT (flv->feedstore), "row-changed",
                      G_CALLBACK (feed_list_view_row_changed_cb), flv);

	/* we render the icon/state, the feed title and the unread count */
	iconRenderer  = gtk_cell_renderer_pixbuf_new ();
	titleRenderer = gtk_cell_renderer_text_new ();
	countRenderer = gtk_cell_renderer_text_new ();

	gtk_cell_renderer_set_alignment (countRenderer, 1.0, 0);

	column  = gtk_tree_view_column_new ();
	column2 = gtk_tree_view_column_new ();

	gtk_tree_view_column_pack_start (column, iconRenderer, FALSE);
	gtk_tree_view_column_pack_start (column, titleRenderer, TRUE);
	gtk_tree_view_column_pack_end   (column2, countRenderer, FALSE);

	gtk_tree_view_column_add_attribute (column, iconRenderer, "gicon", FS_ICON);
	gtk_tree_view_column_add_attribute (column, titleRenderer, "markup", FS_LABEL);
	gtk_tree_view_column_add_attribute (column2, countRenderer, "markup", FS_COUNT);

	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
	gtk_tree_view_column_set_sizing (column2, GTK_TREE_VIEW_COLUMN_GROW_ONLY);
	gtk_tree_view_append_column (flv->treeview, column);
	gtk_tree_view_append_column (flv->treeview, column2);

	g_object_set (titleRenderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);

	g_signal_connect (G_OBJECT (flv->treeview), "row-activated",   G_CALLBACK (feed_list_view_row_activated_cb), flv);
	g_signal_connect (G_OBJECT (flv->treeview), "key-press-event", G_CALLBACK (feed_list_view_key_press_cb), flv);

	select = gtk_tree_view_get_selection (flv->treeview);
	gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE);

	g_signal_connect (G_OBJECT (select), "changed",
	                  G_CALLBACK (feed_list_view_selection_changed_cb),
                	  flv);

	conf_get_bool_value (REDUCED_FEEDLIST, &flv->feedlist_reduced_unread);
	if (flv->feedlist_reduced_unread)
		feed_list_view_reduce_mode_changed ();	/* before menu setup for reduced mode check box to be correct */

	ui_dnd_setup_feedlist (flv->feedstore);
	liferea_shell_update_feed_menu (TRUE, FALSE, FALSE);
	liferea_shell_update_allitems_actions (FALSE, FALSE);

	debug_exit ("feed_list_view_create");

	return flv;
}
Example #13
0
static void
gnc_find_account_dialog_create (GtkWidget *parent, FindAccountDialog *facc_dialog)
{
    GtkWidget         *dialog;
    GtkBuilder        *builder;
    GtkTreeSelection  *selection;

    GtkTreeViewColumn *tree_column;
    GtkCellRenderer   *cr;

    ENTER(" ");
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-find-account.glade", "list-store");
    gnc_builder_add_from_file (builder, "dialog-find-account.glade", "Find Account Dialog");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Find Account Dialog"));
    facc_dialog->dialog = dialog;

    facc_dialog->session = gnc_get_current_session();

    /* parent */
    if (parent != NULL)
    {
        facc_dialog->parent = parent;
        gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(parent));
    }
    else
        facc_dialog->parent = NULL;

    /* Connect the radio buttons...*/
    facc_dialog->radio_root = GTK_WIDGET(gtk_builder_get_object (builder, "radio-root"));
    facc_dialog->radio_subroot = GTK_WIDGET(gtk_builder_get_object (builder, "radio-subroot"));

    facc_dialog->filter_text_entry = GTK_WIDGET(gtk_builder_get_object (builder, "filter-text-entry"));
    facc_dialog->sub_label = GTK_WIDGET(gtk_builder_get_object (builder, "sub-label"));
    facc_dialog->radio_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "hbox-radio"));
    facc_dialog->filter_button = GTK_WIDGET(gtk_builder_get_object (builder, "filter-button"));
    g_signal_connect (facc_dialog->filter_button, "clicked",
                      G_CALLBACK(filter_button_cb), (gpointer)facc_dialog);

    facc_dialog->view = GTK_WIDGET(gtk_builder_get_object (builder, "treeview"));
    g_signal_connect (facc_dialog->view, "row-activated",
                     G_CALLBACK(row_double_clicked), (gpointer)facc_dialog);

    /* Enable alternative line colors */
    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(facc_dialog->view), TRUE);

    /* default to 'close' button */
    gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE);

    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(facc_dialog->view));
    gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

    /* Need to add pixbuf renderers here to get the xalign to work. */
    tree_column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title (tree_column, _("Place Holder"));
    gtk_tree_view_append_column (GTK_TREE_VIEW(facc_dialog->view), tree_column);
    gtk_tree_view_column_set_alignment (tree_column, 0.5);
    gtk_tree_view_column_set_expand (tree_column, TRUE);
    cr = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_column_pack_start (tree_column, cr, TRUE);
    // connect 'active' and set 'xalign' property of the cell renderer
    gtk_tree_view_column_set_attributes (tree_column, cr, "stock-id", PLACE_HOLDER, NULL);
    gtk_cell_renderer_set_alignment (cr, 0.5, 0.5);

    tree_column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title (tree_column, _("Hidden"));
    gtk_tree_view_append_column (GTK_TREE_VIEW(facc_dialog->view), tree_column);
    gtk_tree_view_column_set_alignment (tree_column, 0.5);
    gtk_tree_view_column_set_expand (tree_column, TRUE);
    cr = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_column_pack_start (tree_column, cr, TRUE);
    // connect 'active' and set 'xalign' property of the cell renderer
    gtk_tree_view_column_set_attributes (tree_column, cr, "stock-id", HIDDEN, NULL);
    gtk_cell_renderer_set_alignment (cr, 0.5, 0.5);

    tree_column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title (tree_column, _("Not Used"));
    gtk_tree_view_append_column (GTK_TREE_VIEW(facc_dialog->view), tree_column);
    gtk_tree_view_column_set_alignment (tree_column, 0.5);
    gtk_tree_view_column_set_expand (tree_column, TRUE);
    cr = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_column_pack_start (tree_column, cr, TRUE);
    // connect 'active' and set 'xalign' property of the cell renderer
    gtk_tree_view_column_set_attributes (tree_column, cr, "stock-id", NOT_USED, NULL);
    gtk_cell_renderer_set_alignment (cr, 0.5, 0.5);

    tree_column = gtk_tree_view_column_new();
    gtk_tree_view_column_set_title (tree_column, _("Balance Zero"));
    gtk_tree_view_append_column (GTK_TREE_VIEW(facc_dialog->view), tree_column);
    gtk_tree_view_column_set_alignment (tree_column, 0.5);
    gtk_tree_view_column_set_expand (tree_column, TRUE);
    cr = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_column_pack_start (tree_column, cr, TRUE);
    // connect 'active' and set 'xalign' property of the cell renderer
    gtk_tree_view_column_set_attributes (tree_column, cr, "stock-id", BAL_ZERO, NULL);
    gtk_cell_renderer_set_alignment (cr, 0.5, 0.5);

    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, facc_dialog);

    g_object_unref (G_OBJECT(builder));

    gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(facc_dialog->dialog));

    if (facc_dialog->account != NULL)
    {
        const gchar *sub_label_start = _("Search from ");
        gchar *sub_full_name = gnc_account_get_full_name (facc_dialog->account);
        gchar *sub_label;

        sub_label = g_strconcat (sub_label_start, sub_full_name, NULL);
        gtk_button_set_label (GTK_BUTTON(facc_dialog->radio_subroot), sub_label);
        g_free (sub_full_name);
        g_free (sub_label);

        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(facc_dialog->radio_subroot), TRUE);
        gtk_widget_show_all (facc_dialog->radio_hbox);
    }
    else
        gtk_widget_hide_all (facc_dialog->radio_hbox);

    // Set the filter to Wildcard
    gtk_entry_set_text (GTK_ENTRY(facc_dialog->filter_text_entry), "");

    get_account_info (facc_dialog);

    LEAVE(" ");
}
static void
gpinstruct_analyzer_examinee_view_init (GPInstructAnalyzerExamineeView *object)
{
	object->priv = GPINSTRUCT_ANALYZER_EXAMINEE_VIEW_GET_PRIVATE (object);
	GPInstructAnalyzerExamineeViewPrivate *priv = object->priv;

	GtkTreeSelection *selection;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;

	gtk_paned_set_position (GTK_PANED (object), 200);

	GtkWidget *examinee_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (examinee_scrolledwindow),
	                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_paned_pack1 (GTK_PANED (object), examinee_scrolledwindow, FALSE, TRUE);
	priv->examinee_scrolledwindow = examinee_scrolledwindow;

	priv->examinee_store = gtk_list_store_new (EXAMINEE_N_COLUMNS,
	                                                   G_TYPE_STRING,
	                                                   G_TYPE_POINTER);

	GtkWidget *examinee_treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->examinee_store));
	gtk_container_add (GTK_CONTAINER (examinee_scrolledwindow), examinee_treeview);
	priv->examinee_treeview = examinee_treeview;

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (examinee_treeview));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	g_signal_connect (selection, "changed",
	                  G_CALLBACK (examinee_tree_selection_changed_cb),
	                  object);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Examinees"),
	                                                   renderer,
	                                                   "text", EXAMINEE_NAME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (examinee_treeview), column);

	GtkWidget *vpaned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
	gtk_paned_pack2 (GTK_PANED (object), vpaned, TRUE, TRUE);

	GtkWidget *project_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (project_scrolledwindow),
	                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_paned_pack1 (GTK_PANED (vpaned), project_scrolledwindow, TRUE, TRUE);
	priv->project_scrolledwindow = project_scrolledwindow;

	priv->project_store = gtk_tree_store_new (PROJECT_N_COLUMNS,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_STRING,
	                                                  G_TYPE_UINT,
	                                                  G_TYPE_POINTER);

	GtkWidget *project_treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->project_store));
	gtk_container_add (GTK_CONTAINER (project_scrolledwindow), project_treeview);
	priv->project_treeview = project_treeview;

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (project_treeview));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
	g_signal_connect (selection, "changed",
	                  G_CALLBACK (project_tree_selection_changed_cb),
	                  object);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Project View"),
	                                                   renderer,
	                                                   "text", PROJECT_TITLE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Total Items"),
	                                                   renderer,
	                                                   "text", PROJECT_ITEMS_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Frequency"),
	                                                   renderer,
	                                                   "text", PROJECT_FREQUENCY_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Total Score"),
	                                                   renderer,
	                                                   "text", PROJECT_SCORE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Average Score"),
	                                                   renderer,
	                                                   "text", PROJECT_AVE_SCORE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Percentage"),
	                                                   renderer,
	                                                   "text", PROJECT_PERCENTAGE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Time Spent"),
	                                                   renderer,
	                                                   "text", PROJECT_TIME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Average Time Spent"),
	                                                   renderer,
	                                                   "text", PROJECT_AVE_TIME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (project_treeview), column);

	GtkWidget *test_scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (test_scrolledwindow),
	                                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_paned_pack2 (GTK_PANED (vpaned), test_scrolledwindow, TRUE, TRUE);
	priv->test_scrolledwindow = test_scrolledwindow;

	priv->test_store = gtk_tree_store_new (TEST_N_COLUMNS,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_STRING,
	                                               G_TYPE_UINT,
	                                               G_TYPE_POINTER);

	GtkWidget *test_treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->test_store));
	gtk_container_add (GTK_CONTAINER (test_scrolledwindow), test_treeview);
	priv->test_treeview = test_treeview;

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Test View"),
	                                                   renderer,
	                                                   "text", TEST_TITLE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_expand (column, TRUE);
	gtk_tree_view_column_set_resizable (column, TRUE);
	g_object_set (renderer,
	              "ellipsize", PANGO_ELLIPSIZE_END,
	              "ellipsize-set", TRUE,
	              NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Number of Choices"),
	                                                   renderer,
	                                                   "text", TEST_ITEMS_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Frequency"),
	                                                   renderer,
	                                                   "text", TEST_FREQUENCY_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Total Score"),
	                                                   renderer,
	                                                   "text", TEST_SCORE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Percentage"),
	                                                   renderer,
	                                                   "text", TEST_PERCENTAGE_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Time Spent"),
	                                                   renderer,
	                                                   "text", TEST_TIME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);

	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_renderer_set_alignment (renderer, 1.0, 0.5);
	column = gtk_tree_view_column_new_with_attributes (_("Average Time Spent"),
	                                                   renderer,
	                                                   "text", TEST_AVE_TIME_COLUMN,
	                                                   NULL);
	gtk_tree_view_column_set_resizable (column, TRUE);
	gtk_tree_view_append_column (GTK_TREE_VIEW (test_treeview), column);
}