Exemplo n.º 1
0
static void
phase_cmd_insert_undo (PlannerCmd *cmd_base)
{
	PhaseCmdInsert *cmd;
	GList          *list, *l;
	gboolean        found = FALSE;

	cmd = (PhaseCmdInsert*) cmd_base;

	g_object_get (cmd->project, "phases", &list, NULL);

	for (l = list; l; l = l->next) {
		if (!strcmp (cmd->phase, l->data)) {
			g_free (l->data);
			cmd->position = g_list_position (list, l);
			list = g_list_remove_link (list, l);
			found = TRUE;
			break;
		}
	}

	if (found) {
		g_object_set (cmd->project, "phases", list, NULL);
	}

	mrp_string_list_free (list);
}
Exemplo n.º 2
0
static gboolean
phase_cmd_insert_do (PlannerCmd *cmd_base)
{
	PhaseCmdInsert *cmd;
	GList          *list, *l;
	gboolean	found;

	cmd = (PhaseCmdInsert*) cmd_base;

	if (cmd->phase == NULL) {
		return FALSE;
	}

	g_object_get (cmd->project, "phases", &list, NULL);

	found = FALSE;

	for (l = list; l ; l = l->next) {
		if (strcmp (cmd->phase, (char *) l->data) == 0 ) {
			found = TRUE;
		}
	}

	if (!found) {
		list = g_list_insert (list, g_strdup (cmd->phase), cmd->position);
		g_object_set (cmd->project, "phases", list, NULL);
	}

	mrp_string_list_free (list);

	return !found;
}
Exemplo n.º 3
0
static void
phase_dialog_setup_tree_view (DialogData *data)
{
	GtkListStore      *store;
	GtkCellRenderer   *cell;
	GtkTreeViewColumn *col;
	GList             *list;

	store = gtk_list_store_new (NUM_COLS,
				    G_TYPE_STRING);

	g_signal_connect_object (data->project,
				 "notify::phases",
				 G_CALLBACK (phase_dialog_notify_phases),
				 data->dialog,
				 0);

	gtk_tree_view_set_model (GTK_TREE_VIEW (data->tree_view),
				 GTK_TREE_MODEL (store));

	cell = gtk_cell_renderer_text_new ();
	col = gtk_tree_view_column_new_with_attributes (
		NULL,
		cell,
		"text", COL_PHASE,
		NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (data->tree_view), col);

	g_object_get (data->project, "phases", &list, NULL);
	phase_dialog_rebuild_model (data, list);
	mrp_string_list_free (list);

	gtk_tree_view_expand_all (GTK_TREE_VIEW (data->tree_view));
}
Exemplo n.º 4
0
static void
phase_dialog_notify_phases (MrpProject  *project,
			    GParamSpec  *pspec,
			    GtkWidget   *dialog)
{
	DialogData *data = DIALOG_GET_DATA (dialog);
	GList      *list;

	g_return_if_fail (MRP_IS_PROJECT (project));

	g_object_get (project, "phases", &list, NULL);
	phase_dialog_rebuild_model (data, list);
	mrp_string_list_free (list);
}
Exemplo n.º 5
0
static void
mpp_write_phases (MrpParser *parser, xmlNodePtr node)
{
	GList      *phases, *l;
	xmlNodePtr  child;

	g_object_get (parser->project, "phases", &phases, NULL);

	node = xmlNewChild (node, NULL, "phases", NULL);

	for (l = phases; l; l = l->next) {
		child = xmlNewChild (node, NULL, "phase", NULL);

		xmlSetProp (child, "name", l->data);
	}

	mrp_string_list_free (phases);
}
Exemplo n.º 6
0
static void
phase_cmd_remove_undo (PlannerCmd *cmd_base)
{
	PhaseCmdRemove *cmd;
	GList          *list;

	cmd = (PhaseCmdRemove*) cmd_base;

	g_assert (cmd->phase);

	g_object_get (cmd->project, "phases", &list, NULL);
	list = g_list_insert (list, g_strdup (cmd->phase), cmd->position);

	g_object_set (cmd->project, "phases", list, NULL);
	mrp_string_list_free (list);

	if (cmd->is_assigned) {
		mrp_object_set (cmd->project, "phase", cmd->phase, NULL);
	}
}
Exemplo n.º 7
0
static gboolean
phase_cmd_remove_do (PlannerCmd *cmd_base)
{
	PhaseCmdRemove *cmd;
	GList          *list, *l;
	gchar          *assigned_phase;
	gboolean        found;

	cmd = (PhaseCmdRemove*) cmd_base;

	mrp_object_get (cmd->project, "phase", &assigned_phase, NULL);
	if (assigned_phase == cmd->phase) {
		cmd->is_assigned = TRUE;
	}

	g_object_get (cmd->project, "phases", &list, NULL);

	found = FALSE;
	for (l = list; l; l = l->next) {
		if (!strcmp (cmd->phase, l->data)) {
			g_free (l->data);
			cmd->position = g_list_position (list, l);
			list = g_list_remove_link (list, l);
			found = TRUE;
			break;
		}
	}

	if (found) {
		g_object_set (cmd->project, "phases", list, NULL);
	}

	mrp_string_list_free (list);

	return !found;
}