[Planner Dev] Patch to fix NULLs in database short-name and cleanup SQL Open Project display.




Richard,
	ideally this should make 0.12 as it fixes an issue
with NULLs in older databases for the short-name making a mess
of peoples resources and gantt display. (Its a workaround so
it has a FIXME: as we will eventually have to have a proper
database upgrade procedure when we change our schema/DTD).

The Select Project dialog is also cleaned up to show the
project ID, phase and revision number plus its sorted on the
project ID thats in the database (see screen grab). Without
this - the Select Project display is a mess if you have lots
of projects saved.

The open and select dialog also take 'return' as a hotkey
for the OK buttons.

Translators will have to tweak what they say as the
Select dialog will in future be used for more database
operations other than "Open" e.g. upgrades and delete
project operations.

Rgds,
Lincoln.

JPEG image

Index: data/glade/sql.glade
===================================================================
RCS file: /cvs/gnome/planner/data/glade/sql.glade,v
retrieving revision 1.2
diff -u -b -B -p -r1.2 sql.glade
--- data/glade/sql.glade	16 Dec 2003 18:31:20 -0000	1.2
+++ data/glade/sql.glade	17 Apr 2004 08:10:45 -0000
@@ -46,6 +46,7 @@
 	      <property name="use_stock">True</property>
 	      <property name="relief">GTK_RELIEF_NORMAL</property>
 	      <property name="response_id">-5</property>
+	      <accelerator key="Return" modifiers="0" signal="clicked"/>
 	    </widget>
 	  </child>
 	</widget>
@@ -287,6 +288,7 @@
 
 <widget class="GtkDialog" id="select_dialog">
   <property name="border_width">5</property>
+  <property name="width_request">400</property>
   <property name="title" translatable="yes">Select a Project</property>
   <property name="type">GTK_WINDOW_TOPLEVEL</property>
   <property name="window_position">GTK_WIN_POS_NONE</property>
@@ -297,6 +299,7 @@
 
   <child internal-child="vbox">
     <widget class="GtkVBox" id="vbox130">
+      <property name="width_request">300</property>
       <property name="visible">True</property>
       <property name="homogeneous">False</property>
       <property name="spacing">2</property>
@@ -322,17 +325,19 @@
 	    <widget class="GtkButton" id="ok_button">
 	      <property name="visible">True</property>
 	      <property name="can_default">True</property>
+	      <property name="has_default">True</property>
 	      <property name="can_focus">True</property>
 	      <property name="label">gtk-ok</property>
 	      <property name="use_stock">True</property>
 	      <property name="relief">GTK_RELIEF_NORMAL</property>
 	      <property name="response_id">-5</property>
+	      <accelerator key="Return" modifiers="0" signal="clicked"/>
 	    </widget>
 	  </child>
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
-	  <property name="expand">False</property>
+	  <property name="expand">True</property>
 	  <property name="fill">True</property>
 	  <property name="pack_type">GTK_PACK_END</property>
 	</packing>
@@ -348,7 +353,7 @@
 	  <child>
 	    <widget class="GtkLabel" id="label259">
 	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">The database contains the following projects. Select a project to open:</property>
+	      <property name="label" translatable="yes">The database contains the following projects. Please select a project:</property>
 	      <property name="use_underline">False</property>
 	      <property name="use_markup">True</property>
 	      <property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -361,7 +366,7 @@
 	    </widget>
 	    <packing>
 	      <property name="padding">0</property>
-	      <property name="expand">False</property>
+	      <property name="expand">True</property>
 	      <property name="fill">False</property>
 	    </packing>
 	  </child>
@@ -380,8 +385,8 @@
 		<widget class="GtkTreeView" id="project_treeview">
 		  <property name="visible">True</property>
 		  <property name="can_focus">True</property>
-		  <property name="headers_visible">False</property>
-		  <property name="rules_hint">False</property>
+		  <property name="headers_visible">True</property>
+		  <property name="rules_hint">True</property>
 		  <property name="reorderable">False</property>
 		  <property name="enable_search">True</property>
 		</widget>
Index: libplanner/mrp-sql.c
===================================================================
RCS file: /cvs/gnome/planner/libplanner/mrp-sql.c,v
retrieving revision 1.4
diff -u -b -B -p -r1.4 mrp-sql.c
--- libplanner/mrp-sql.c	6 Apr 2004 20:38:23 -0000	1.4
+++ libplanner/mrp-sql.c	17 Apr 2004 08:10:49 -0000
@@ -1623,6 +1623,15 @@ sql_read_resources (SQLData *data)
 			}
 			else if (is_field (res, j, "short_name")) {
 				short_name = get_string (res, i, j);
+				
+		/* FIXME: The next section detects the case if short_name is NULL. If a string field is null then get_string() seems to actually return the word NULL i.e. a string containing N U L L  The fix is
+		to correct the contents of the database at upgrade times so the following is a workaround until
+		we have a database upgrade process that fixes NULLs. */
+				
+				if (strncmp(short_name,"NULL",4) == 0) {  
+					short_name = g_strdup ("");
+					g_print ("Resource short name was reserved word of NULL so now set to blank.\n");
+				}
 			}
 			else if (is_field (res, j, "group_id")) {
 				group_id = get_id (res, i, j);
Index: src/planner-sql-plugin.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-sql-plugin.c,v
retrieving revision 1.8
diff -u -b -B -p -r1.8 planner-sql-plugin.c
--- src/planner-sql-plugin.c	15 Mar 2004 21:02:32 -0000	1.8
+++ src/planner-sql-plugin.c	17 Apr 2004 08:10:50 -0000
@@ -85,7 +85,9 @@ void            plugin_exit             
 
 enum {
 	COL_ID,
-	COL_NAME
+	COL_NAME,
+	COL_PHASE,
+	COL_REVISION
 };
 
 static BonoboUIVerb verbs[] = {
@@ -338,7 +340,7 @@ sql_plugin_retrieve_project_id (PlannerP
 	res = NULL;
 
 	res = sql_execute_query (conn,
-		      "DECLARE mycursor CURSOR FOR SELECT proj_id, name FROM project");
+		      "DECLARE mycursor CURSOR FOR SELECT proj_id, name , phase, revision FROM project ORDER by proj_id ASC");
 
 	if (res == NULL) {
 		g_warning ("DECLARE CURSOR command failed (project).");
@@ -361,15 +363,43 @@ sql_plugin_retrieve_project_id (PlannerP
 
 	g_object_unref (gui);
 	
-	liststore = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
+	liststore = gtk_list_store_new (4, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
 	gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (liststore));
 
 	cell = gtk_cell_renderer_text_new ();
+	col = gtk_tree_view_column_new_with_attributes (_("ID"),
+							cell,
+							"text", COL_ID,
+							NULL);
+	gtk_tree_view_column_set_resizable (col, TRUE);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
+	
+	cell = gtk_cell_renderer_text_new ();
 	col = gtk_tree_view_column_new_with_attributes (_("Project"),
 							cell,
 							"text", COL_NAME,
 							NULL);
+	gtk_tree_view_column_set_resizable (col, TRUE);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
+	
+	cell = gtk_cell_renderer_text_new ();
+	col = gtk_tree_view_column_new_with_attributes (_("Phase"),
+							cell,
+							"text", COL_PHASE,
+							NULL);
+	gtk_tree_view_column_set_resizable (col, TRUE);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
+	
+	cell = gtk_cell_renderer_text_new ();
+	col = gtk_tree_view_column_new_with_attributes (_("Revision"),
+							cell,
+							"text", COL_REVISION,
+							NULL);
+	gtk_tree_view_column_set_resizable (col, TRUE);
+	gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
+	
+	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (treeview));
+	
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
 	gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); 
 	
@@ -380,18 +410,25 @@ sql_plugin_retrieve_project_id (PlannerP
 	for (i = 0; i < gda_data_model_get_n_rows (res); i++) {
 		gint   id;
 		gchar *name;
+		gchar *phase;
+		gint  revision;
 		
 		id = get_int (res, i, 0);
 		name = get_string (res, i, 1);
+		phase = get_string (res, i, 2);
+		revision = get_int (res, i, 3);
 
 		gtk_list_store_append (GTK_LIST_STORE (liststore), &iter);
 		gtk_list_store_set (GTK_LIST_STORE (liststore), 
 				    &iter,
 				    COL_ID, id,
 				    COL_NAME, name,
+				    COL_PHASE, phase,
+			            COL_REVISION, revision,
 				    -1);
 
 		g_free (name);
+		g_free (phase);
 	}
 
 	if (gda_data_model_get_n_columns (res) == 0) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]