[asterisk-commits] russell: branch russell/gmenuselect r58920 - /team/russell/gmenuselect/menuse...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Mar 15 06:50:04 MST 2007


Author: russell
Date: Thu Mar 15 08:50:03 2007
New Revision: 58920

URL: http://svn.digium.com/view/asterisk?view=rev&rev=58920
Log:
- Only do the dialog box asking if we should save before quit if changes were made
- Show the dependencies and conflicts in the gui

Modified:
    team/russell/gmenuselect/menuselect/menuselect_gtk.c

Modified: team/russell/gmenuselect/menuselect/menuselect_gtk.c
URL: http://svn.digium.com/view/asterisk/team/russell/gmenuselect/menuselect/menuselect_gtk.c?view=diff&rev=58920&r1=58919&r2=58920
==============================================================================
--- team/russell/gmenuselect/menuselect/menuselect_gtk.c (original)
+++ team/russell/gmenuselect/menuselect/menuselect_gtk.c Thu Mar 15 08:50:03 2007
@@ -6,8 +6,17 @@
 #include "menuselect.h"
 
 enum {
+	/*! The row name */
 	COLUMN_NAME,
+	/*! Whether this row is enabled */
 	COLUMN_SELECTED,
+	/*! Dependencies */
+	COLUMN_DEPS,
+	/*! Optional dependencies */
+	COLUMN_USES,
+	/*! Conflicts */
+	COLUMN_CNFS,
+	/*! Number of columns, must be the last element in the enum */
 	NUM_COLUMNS,
 };
 
@@ -17,9 +26,7 @@
 
 static GtkItemFactoryEntry menu_items[] = {
   { "/_File",               NULL,         NULL,           0, "<Branch>" },
-/*{ "/File/_Open",          "<control>O", print_hello,    0, "<StockItem>", GTK_STOCK_OPEN },*/
   { "/File/_Save And Quit", "<control>S", handle_save, 0, "<StockItem>", GTK_STOCK_SAVE },
-/*{ "/File/Save _As",       NULL,         NULL,           0, "<Item>" },*/
   { "/File/sep1",           NULL,         NULL,           0, "<Separator>" },
   { "/File/_Quit",          "<CTRL>Q",    handle_quit,  0, "<StockItem>", GTK_STOCK_QUIT },
   { "/_Help",               NULL,         NULL,           0, "<LastBranch>" },
@@ -33,6 +40,7 @@
 
 /* 0, save ... non-zero, don't save */
 static int main_res = 1;
+static int change_made = 0;
 
 static void handle_save(GtkWidget *w, gpointer data)
 {
@@ -69,7 +77,7 @@
 	GtkWidget *dialog;
 	gint response;
 
-	if (!main_res) {
+	if (!main_res || !change_made) {
 		gtk_main_quit();
 		return;
 	}
@@ -146,6 +154,8 @@
 		return;
 
 	gtk_tree_store_set(store, &mem_iter, COLUMN_SELECTED, mem->enabled, -1);
+
+	change_made = 1;
 }
 
 static void row_activated_handler(GtkTreeView *treeview, GtkTreePath *path,
@@ -172,6 +182,7 @@
 
 			toggle_enabled(mem);
 			gtk_tree_store_set(store, &iter, COLUMN_SELECTED, mem->enabled, -1);
+			change_made = 1;
 			break;
 		}
 		if (mem)
@@ -221,7 +232,7 @@
 	gtk_init(&argc, &argv);
    
    	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-	gtk_widget_set_size_request(window, 350, 500);
+	gtk_widget_set_size_request(window, 640, 480);
 	gtk_window_set_title(GTK_WINDOW(window), "GMenuselect");
 
 	main_vbox = gtk_vbox_new(FALSE, 1);
@@ -240,7 +251,10 @@
 
 	store = gtk_tree_store_new(NUM_COLUMNS,
 		G_TYPE_STRING,   /* COLUMN_NAME */
-		G_TYPE_BOOLEAN); /* COLUMN_SELECTED */
+		G_TYPE_BOOLEAN,  /* COLUMN_SELECTED */
+		G_TYPE_STRING,   /* COLUMN_DEPS */
+		G_TYPE_STRING,   /* COLUMN_USES */
+		G_TYPE_STRING);  /* COLUMN_CNFS */
 
 	AST_LIST_TRAVERSE(&categories, cat, list) {
 		GtkTreeIter iter, iter2;
@@ -250,10 +264,38 @@
 			COLUMN_SELECTED, TRUE,
 			-1);
 		AST_LIST_TRAVERSE(&cat->members, mem, list) {
+			char dep_buf[64] = "";
+			char use_buf[64] = "";
+			char cnf_buf[64] = "";
+			struct depend *dep;
+			struct use *use;
+			struct conflict *cnf;
+
+			AST_LIST_TRAVERSE(&mem->deps, dep, list) {
+				strncat(dep_buf, dep->name, sizeof(dep_buf) - strlen(dep_buf) - 1);
+				strncat(dep_buf, dep->member ? "(M)" : "(E)", sizeof(dep_buf) - strlen(dep_buf) - 1);
+				if (AST_LIST_NEXT(dep, list))
+					strncat(dep_buf, ", ", sizeof(dep_buf) - strlen(dep_buf) - 1);
+			}
+			AST_LIST_TRAVERSE(&mem->uses, use, list) {
+				strncat(use_buf, use->name, sizeof(use_buf) - strlen(use_buf) - 1);
+				if (AST_LIST_NEXT(use, list))
+					strncat(use_buf, ", ", sizeof(use_buf) - strlen(use_buf) - 1);
+			}
+			AST_LIST_TRAVERSE(&mem->conflicts, cnf, list) {
+				strncat(cnf_buf, cnf->name, sizeof(cnf_buf) - strlen(cnf_buf) - 1);
+				strncat(cnf_buf, cnf->member ? "(M)" : "(E)", sizeof(cnf_buf) - strlen(cnf_buf) - 1);
+				if (AST_LIST_NEXT(cnf, list))
+					strncat(cnf_buf, ", ", sizeof(cnf_buf) - strlen(cnf_buf) - 1);
+			}
+
 			gtk_tree_store_append(store, &iter2, &iter);
 			gtk_tree_store_set(store, &iter2,
 				COLUMN_NAME, mem->name,
 				COLUMN_SELECTED, mem->enabled,
+				COLUMN_DEPS, dep_buf,
+				COLUMN_USES, use_buf,
+				COLUMN_CNFS, cnf_buf,
 				-1);
 		}
 	}
@@ -270,6 +312,21 @@
 	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
 	g_signal_connect(renderer, "toggled", (GCallback) toggled_handler, store);
 
+	renderer = gtk_cell_renderer_text_new();
+	column = gtk_tree_view_column_new_with_attributes("Depends On",
+				renderer, "text", COLUMN_DEPS, NULL);
+	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+	renderer = gtk_cell_renderer_text_new();
+	column = gtk_tree_view_column_new_with_attributes("Can Use",
+				renderer, "text", COLUMN_USES, NULL);
+	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+
+	renderer = gtk_cell_renderer_text_new();
+	column = gtk_tree_view_column_new_with_attributes("Conflicts With",
+				renderer, "text", COLUMN_CNFS, NULL);
+	gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
+	
 	g_signal_connect(tree, "row-activated", (GCallback) row_activated_handler, store);
 
 	gtk_container_add(GTK_CONTAINER(s_window), GTK_WIDGET(tree));
@@ -280,5 +337,5 @@
    
 	gtk_main();
 
-		return main_res;
-}
+	return main_res;
+}



More information about the asterisk-commits mailing list