code 39 barcode generator asp.net Removing Multiple Rows in Font

Generator DataMatrix in Font Removing Multiple Rows

Removing Multiple Rows
DataMatrix Creator In None
Using Barcode creation for Font Control to generate, create DataMatrix image in Font applications.
www.OnBarcode.com
Make PDF417 In None
Using Barcode printer for Font Control to generate, create PDF 417 image in Font applications.
www.OnBarcode.com
The next step is to add the ability to remove products from the list. Since we have added the ability for multiple rows to be selected, the code must also be able to remove more than one row. Listing 8-7 implements two functions. The first function, remove_row(), is called for every selected row, removing the row if it is not a category. If the removed row was to be purchased, its quantity is removed from the category s running total. The second function, remove_products(), is the callback function that is run when the GTK_STOCK_REMOVE button is clicked.
Create GS1-128 In None
Using Barcode creation for Font Control to generate, create GS1-128 image in Font applications.
www.OnBarcode.com
Barcode Encoder In None
Using Barcode generator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
CHAPTER 8 THE TREE VIEW WIDGET
Encoding Code-128 In None
Using Barcode encoder for Font Control to generate, create Code 128A image in Font applications.
www.OnBarcode.com
Create Quick Response Code In None
Using Barcode drawer for Font Control to generate, create QR Code 2d barcode image in Font applications.
www.OnBarcode.com
Listing 8-7. Removing One or More Products (selections.c) static void remove_row (GtkTreeRowReference *ref, GtkTreeModel *model) { GtkTreeIter parent, iter; GtkTreePath *path; gboolean buy; gint quantity, pnum; /* Convert the tree row reference to a path and retrieve the iterator. */ path = gtk_tree_row_reference_get_path (ref); gtk_tree_model_get_iter (model, &iter, path); /* Only remove the row if it is not a root row. */ if (gtk_tree_model_iter_parent (model, &parent, &iter)) { gtk_tree_model_get (model, &iter, BUY_IT, &buy, QUANTITY, &quantity, -1); gtk_tree_model_get (model, &parent, QUANTITY, &pnum, -1); if (buy) { pnum -= quantity; gtk_tree_store_set (GTK_TREE_STORE (model), &parent, QUANTITY, pnum, -1); } gtk_tree_model_get_iter (model, &iter, path); gtk_tree_store_remove (GTK_TREE_STORE (model), &iter); } } static void remove_products (GtkButton *remove, GtkTreeView *treeview) { GtkTreeSelection *selection; GtkTreeRowReference *ref; GtkTreeModel *model; GList *rows, *ptr, *references = NULL; selection = gtk_tree_view_get_selection (treeview); model = gtk_tree_view_get_model (treeview); rows = gtk_tree_selection_get_selected_rows (selection, &model);
Data Matrix Creator In None
Using Barcode printer for Font Control to generate, create Data Matrix 2d barcode image in Font applications.
www.OnBarcode.com
ANSI/AIM Code 93 Generation In None
Using Barcode creation for Font Control to generate, create Code 93 Full ASCII image in Font applications.
www.OnBarcode.com
CHAPTER 8 THE TREE VIEW WIDGET
DataMatrix Maker In None
Using Barcode maker for Excel Control to generate, create ECC200 image in Office Excel applications.
www.OnBarcode.com
Draw Data Matrix ECC200 In Visual Basic .NET
Using Barcode generation for .NET Control to generate, create DataMatrix image in VS .NET applications.
www.OnBarcode.com
/* Create tree row references to all of the selected rows. */ ptr = rows; while (ptr != NULL) { ref = gtk_tree_row_reference_new (model, (GtkTreePath*) ptr->data); references = g_list_prepend (references, gtk_tree_row_reference_copy (ref)); gtk_tree_row_reference_free (ref); ptr = ptr->next; } /* Remove each of the selected rows pointed to by the row reference. */ g_list_foreach (references, (GFunc) remove_row, model); /* Free the tree paths, tree row references and lists. */ g_list_foreach (references, (GFunc) gtk_tree_row_reference_free, NULL); g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL); g_list_free (references); g_list_free (rows); } When the GTK_STOCK_REMOVE button is pressed, remove_products() will be called. This function begins by calling gtk_tree_selection_get_selected_rows() in order to retrieve a doubly linked list of tree paths that point to the selected rows. Since the application will be altering the rows, the list of paths is converted into a list of row references. This will make sure that all of the tree paths will remain valid.
Denso QR Bar Code Maker In Objective-C
Using Barcode creator for iPad Control to generate, create Denso QR Bar Code image in iPad applications.
www.OnBarcode.com
UPC Symbol Creator In None
Using Barcode creation for Software Control to generate, create GTIN - 12 image in Software applications.
www.OnBarcode.com
Note Remember that gtk_tree_selection_selected_foreach() cannot be used for this application,
Barcode Maker In .NET Framework
Using Barcode printer for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Barcode Printer In Java
Using Barcode maker for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
because it should not be used when rows will be altered! This is very important to remember, because it can cause many headaches if iterators are unexpectedly invalid because a tree model was changed.
Barcode Generator In VS .NET
Using Barcode printer for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
Decode PDF 417 In C#.NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
After the paths are converted to tree row references, g_list_foreach() is used to call remove_row() for every item. Within remove_row(), a new function is used to check whether the row is a category. If the selected row is a category, we know that it will be a root element and will have no parents. Therefore, the following gtk_tree_model_iter_parent() call performs two tasks. First, if the parent iterator is not set, this function will return FALSE, and the category row will not be removed. If the row has a parent, which means that it is a product, the parent iterator will be set and used later in the function. if (gtk_tree_model_iter_parent (model, &parent, &iter))
Creating QR-Code In Visual Basic .NET
Using Barcode creator for .NET framework Control to generate, create QR Code JIS X 0510 image in .NET framework applications.
www.OnBarcode.com
Code 3/9 Encoder In None
Using Barcode encoder for Software Control to generate, create Code 3 of 9 image in Software applications.
www.OnBarcode.com
CHAPTER 8 THE TREE VIEW WIDGET
Reading Denso QR Bar Code In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Drawing Code 39 In Java
Using Barcode generation for Java Control to generate, create Code 39 image in Java applications.
www.OnBarcode.com
Second, the function retrieves information about the selected product and its parent category. If the product was set to be purchased, its quantity is subtracted from the total product count displayed by the category. Since changing this data will invalidate the iterator, the path is converted into an iterator, and the row is removed from the tree model.
Handling Double-clicks
Double-clicks are handled with the row-activated signal of the GtkTreeView. The signal is emitted when the user double-clicks a row, when the user presses the spacebar, Shift+spacebar, Return, or Enter on a noneditable row, or when you call gtk_tree_view_row_activated(). Listing 8-8. Editing a Clicked Row static void row_activated (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, gpointer data) { GtkTreeModel *model; GtkTreeIter iter; model = gtk_tree_view_get_model (treeview); if (gtk_tree_model_get_iter (model, &iter, path)) { /* Handle the selection ... */ } } In Listing 8-8, the callback function row_activated() is called when the user activates a row within the tree view. The activated row is retrieved from the tree path object with gtk_tree_model_get_iter(). From there, you are free to use whatever functions you have learned thus far to retrieve or alter the content of the row.
Copyright © OnBarcode.com . All rights reserved.