a patch for planner



hi,
        I just :
        1.Add a "Notes" column in Task view .
        2.With multiple line print.
        3.Fixed can't save custom paper size with Page Setup dialog.

        i like planner!


thanks,
luqi

This email (including any attachments) is confidential and may be legally privileged. If you received this email in error, please delete it immediately and do not copy it or use it for any purpose or disclose its contents to any other person. Thank you.

本电邮(包括任何附件)可能含有机密资料并受法律保护。如您不是正确的收件人,请您立即删除本邮件。请不要将本电邮进行复制并用作任何其他用途、或透露本邮件之内容。谢谢。
diff -ur orig/planner-0.14.4/libplanner/mrp-task.c planner-0.14.4/libplanner/mrp-task.c
--- orig/planner-0.14.4/libplanner/mrp-task.c	2008-07-22 21:41:46.000000000 +0800
+++ planner-0.14.4/libplanner/mrp-task.c	2010-11-03 14:13:14.000000000 +0800
@@ -920,6 +920,14 @@
 	return task->priv->name;
 }
 
+const gchar *
+mrp_task_get_note (MrpTask *task)
+{
+	g_return_val_if_fail (MRP_IS_TASK (task), NULL);
+
+	return task->priv->note;
+}
+
 /**
  * mrp_task_set_name:
  * @task: an #MrpResource
diff -ur orig/planner-0.14.4/src/planner-gantt-model.c planner-0.14.4/src/planner-gantt-model.c
--- orig/planner-0.14.4/src/planner-gantt-model.c	2008-07-22 21:41:47.000000000 +0800
+++ planner-0.14.4/src/planner-gantt-model.c	2010-11-03 14:13:06.000000000 +0800
@@ -897,7 +897,15 @@
 		g_value_set_int (value, mrp_task_get_percent_complete (task));
 
 		break;
-
+	case COL_NOTES:		
+		name = mrp_task_get_note (task);
+		if (name == NULL) {
+			name = "";
+		}
+		
+		g_value_init (value, G_TYPE_STRING);
+		g_value_set_string (value, name);
+		break;
 	default:
 		g_warning ("Bad column %d requested", column);
 	}
diff -ur orig/planner-0.14.4/src/planner-gantt-model.h planner-0.14.4/src/planner-gantt-model.h
--- orig/planner-0.14.4/src/planner-gantt-model.h	2008-07-22 21:41:47.000000000 +0800
+++ planner-0.14.4/src/planner-gantt-model.h	2010-11-03 13:58:29.000000000 +0800
@@ -61,6 +61,7 @@
 	COL_COST,
 	COL_ASSIGNED_TO,
 	COL_COMPLETE,
+	COL_NOTES,
 	NUM_COLS
 };
 
Only in orig/planner-0.14.4/src: planner-marshal.c
Only in orig/planner-0.14.4/src: planner-marshal.h
diff -ur orig/planner-0.14.4/src/planner-print-dialog.c planner-0.14.4/src/planner-print-dialog.c
--- orig/planner-0.14.4/src/planner-print-dialog.c	2008-08-04 00:28:35.000000000 +0800
+++ planner-0.14.4/src/planner-print-dialog.c	2010-11-03 17:12:23.000000000 +0800
@@ -81,6 +81,38 @@
 				 NULL);
 }
 
+static GtkPaperSize *
+load_paper_size_from_key_file (GKeyFile *key_file)
+{
+	const gchar *name;
+	const gchar *ppd_name;
+	const gchar *display_name;
+	gdouble      width;
+	gdouble      height;
+
+	name         = g_key_file_get_string (key_file, "Page Setup", "Name",
+					      NULL);
+	ppd_name     = g_key_file_get_string (key_file, "Page Setup", "PPDName",
+					      NULL);
+	display_name = g_key_file_get_string (key_file, "Page Setup", "DisplayName",
+					      NULL);
+	width        = g_key_file_get_double (key_file, "Page Setup", "Width",  NULL);
+	height       = g_key_file_get_double (key_file, "Page Setup", "Height", NULL);
+
+	if (name && display_name) {
+		return gtk_paper_size_new_custom (name,
+						  display_name, width, height,
+						  GTK_UNIT_MM);
+	}
+	
+	if (ppd_name && display_name) {
+		return gtk_paper_size_new_from_ppd (ppd_name,
+						    display_name, width, height);
+	}
+
+	return gtk_paper_size_new (name);
+}
+
 
 GtkPageSetup *
 planner_print_dialog_load_page_setup (void)
@@ -101,7 +133,15 @@
 		g_free (filename);
 
 		if (success) {
+			GtkPaperSize *paper_size = NULL;
+			
 			page_setup = gtk_page_setup_new_from_key_file (key_file, NULL, NULL);
+			
+			paper_size = load_paper_size_from_key_file (key_file);
+			
+			gtk_page_setup_set_paper_size_and_default_margins (page_setup,
+									   paper_size);
+
 		}
 
 		if (page_setup == NULL) {
@@ -132,6 +172,7 @@
 					   filename,
 					   G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
 					   NULL);
+
 		gtk_page_setup_to_key_file (page_setup, key_file, NULL);
 		str = g_key_file_to_data (key_file, NULL, NULL);
 		g_key_file_free (key_file);
diff -ur orig/planner-0.14.4/src/planner-table-print-sheet.c planner-0.14.4/src/planner-table-print-sheet.c
--- orig/planner-0.14.4/src/planner-table-print-sheet.c	2008-08-03 23:58:49.000000000 +0800
+++ planner-0.14.4/src/planner-table-print-sheet.c	2010-11-03 15:04:38.000000000 +0800
@@ -183,7 +183,7 @@
 	d(g_print ("Writing: [%s]\n", str));
 
 	text_x = x + sheet->x_pad + INDENT_FACTOR * depth;
-	text_y = y + TEXT_IN_CELL_MULTI * row->height;
+	text_y = y + TEXT_IN_CELL_MULTI * sheet->row_height;
 	
 	planner_print_job_text (sheet->job, text_x, text_y, str);
 	g_free (str);
@@ -292,6 +292,9 @@
 		for (l = sheet->columns; l; l = l->next) {
 			PrintColumn *column = PRINT_COL (l->data);
 			gchar       *str;
+			gchar       *c_str;
+			int         line_count = 1;
+
 			gdouble      extra = 3 * sheet->x_pad;
 			
 			(* column->data_func) (column->tree_column,
@@ -302,6 +305,18 @@
 			g_object_get (cell,
 				      "text", &str,
 				      NULL);
+			
+			c_str = str;
+
+			while(c_str && *c_str ++){
+				if (*c_str == '\n') {
+					line_count ++;
+				}
+			}			
+
+			if (line_count > 1) {
+				row->height = MAX(row->height, sheet->row_height * line_count);
+			}
 
  			if (column->expander_column) {
 				extra += depth * INDENT_FACTOR * sheet->x_pad;
diff -ur orig/planner-0.14.4/src/planner-task-tree.c planner-0.14.4/src/planner-task-tree.c
--- orig/planner-0.14.4/src/planner-task-tree.c	2009-04-08 02:06:37.000000000 +0800
+++ planner-0.14.4/src/planner-task-tree.c	2010-11-03 14:15:40.000000000 +0800
@@ -1564,6 +1564,30 @@
 
 
 static void
+task_tree_notes_data_func (GtkTreeViewColumn *tree_column,
+			  GtkCellRenderer   *cell,
+			  GtkTreeModel      *tree_model,
+			  GtkTreeIter       *iter,
+			  gpointer           data)
+{
+	PlannerTaskTree *tree;
+	gchar           *str;
+	
+	tree = PLANNER_TASK_TREE (data);
+	
+	gtk_tree_model_get (tree_model,
+			    iter,
+			    COL_NOTES, &str,
+			    -1);
+	g_object_set (cell,
+		      "text", str,
+		      NULL);
+	
+	g_free (str);
+}
+
+
+static void
 task_tree_assigned_to_data_func (GtkTreeViewColumn *tree_column,
 			  GtkCellRenderer   *cell,
 			  GtkTreeModel      *tree_model,
@@ -2562,6 +2586,22 @@
 		g_object_set_data (G_OBJECT (col), "id", "assigned_to");
 		break;
 
+	case COL_NOTES:
+		cell = gtk_cell_renderer_text_new ();
+		col = gtk_tree_view_column_new_with_attributes (title,
+								cell,
+								NULL);
+		gtk_tree_view_column_set_resizable (col, TRUE);
+		gtk_tree_view_column_set_min_width (col, 150);
+		gtk_tree_view_column_set_cell_data_func (col,
+							 cell,
+							 task_tree_notes_data_func,
+							 GTK_TREE_VIEW (tree),
+							 NULL);
+		g_object_set_data (G_OBJECT (col),
+				   "data-func", task_tree_notes_data_func);
+		g_object_set_data (G_OBJECT (col), "id", "notes");
+		break;
 	default:
 		g_assert_not_reached ();
 	}
diff -ur orig/planner-0.14.4/src/planner-task-view.c planner-0.14.4/src/planner-task-view.c
--- orig/planner-0.14.4/src/planner-task-view.c	2008-08-03 20:45:16.000000000 +0800
+++ planner-0.14.4/src/planner-task-view.c	2010-11-03 13:58:34.000000000 +0800
@@ -348,6 +348,7 @@
 						     * xgettext:no-c-format
 						     */
 						    COL_COMPLETE, _("% Complete"),
+						    COL_NOTES, _("Notes"),
 						    -1);
 
 		g_object_unref (model);
diff -ur orig/planner-0.14.4/src/planner-window.c planner-0.14.4/src/planner-window.c
--- orig/planner-0.14.4/src/planner-window.c	2008-08-04 00:23:34.000000000 +0800
+++ planner-0.14.4/src/planner-window.c	2010-11-03 16:08:08.000000000 +0800
@@ -922,7 +922,8 @@
 	PlannerWindowPriv *priv;
 	GtkPageSetup      *old_page_setup, *new_page_setup;
 	GtkPrintSettings  *settings;
-	
+
+
 	window = PLANNER_WINDOW (data);
 	priv = window->priv;
 
@@ -966,6 +967,7 @@
 	settings = NULL;
 
 	page_setup = planner_print_dialog_load_page_setup ();
+
 	gtk_print_operation_set_default_page_setup (print, page_setup);
 	g_object_unref (page_setup);
 	page_setup = NULL;


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