예제 #1
0
static void
phase_dialog_new_dialog_run (DialogData *data)
{
	GladeXML    *glade;
	GtkWidget   *dialog;
	GtkWidget   *entry;
	const gchar *name;
	gchar       *filename;

	filename = mrp_paths_get_glade_dir ("project-properties.glade");
	glade = glade_xml_new (filename,
			       "new_phase_dialog",
			       GETTEXT_PACKAGE);
	g_free (filename);

	dialog = glade_xml_get_widget (glade, "new_phase_dialog");

	data->new_ok_button = glade_xml_get_widget (glade, "ok_button");

	entry = glade_xml_get_widget (glade, "name_entry");
	g_signal_connect (entry,
			  "changed",
			  G_CALLBACK (phase_dialog_new_name_changed_cb),
			  data);

	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
		name = gtk_entry_get_text (GTK_ENTRY (entry));
		phase_cmd_insert (data->main_window, (gchar *) name ,-1);
	}

	g_object_unref (glade);
	gtk_widget_destroy (dialog);
}
예제 #2
0
GtkWidget *
planner_prob_event_dialog_new (PlannerWindow *window)
{
	DialogData   *data;
	GladeXML     *glade;
	GtkWidget    *dialog;
	GtkWidget    *w;
	gchar        *filename;

	filename = mrp_paths_get_glade_dir ("prob-event-dialog.glade");
	glade = glade_xml_new (filename, NULL, NULL);
	g_free (filename);

	if (!glade) {
		g_warning ("Could not create probability event dialog.");
		return NULL;
	}

	dialog = glade_xml_get_widget (glade, "prob_event_dialog");

	data = g_new0 (DialogData, 1);

	data->main_window = window;
	data->dialog = dialog;

	g_signal_connect_object (window,
				 "destroy",
				 G_CALLBACK (prob_event_dialog_parent_destroy_cb),
				 dialog,
				 0);

	g_object_set_data_full (G_OBJECT (dialog),
				"data", data,
				g_free);

	prob_event_dialog_setup_widgets (data, glade);

	return dialog;
}
예제 #3
0
GtkWidget *
planner_property_dialog_new (PlannerWindow *main_window,
			     MrpProject    *project,
			     GType          owner,
			     const gchar   *title)
{
	GladeXML                  *glade;
	GtkWidget                 *dialog;
	PlannerPropertyDialogPriv *priv;
	gchar                     *filename;

	g_return_val_if_fail (MRP_IS_PROJECT (project), NULL);

	priv = g_new0 (PlannerPropertyDialogPriv, 1);

	filename = mrp_paths_get_glade_dir ("property-dialog.glade");
	glade = glade_xml_new (filename,
			       NULL, NULL);
	g_free (filename);

	dialog = glade_xml_get_widget (glade, "dialog");

	gtk_window_set_title (GTK_WINDOW (dialog), title);

	g_object_set_data (G_OBJECT (dialog), "priv", priv);

	priv->main_window = main_window;
	priv->project = project;
	priv->owner = owner;

	property_dialog_setup_widgets (dialog, glade);

	g_object_unref (glade);

	return dialog;
}
예제 #4
0
static void
eds_plugin_import (GtkAction   *action,
		   gpointer     user_data,
		   const gchar *cname)
{
	PlannerPlugin     *plugin;
	PlannerPluginPriv *priv;
	GtkCellRenderer   *renderer;
	GConfClient       *gconf_client;
	ESourceList       *source_list;
	GSList            *groups;
	gchar             *filename;

	plugin = PLANNER_PLUGIN (user_data);
	priv = plugin->priv;

	filename = mrp_paths_get_glade_dir ("/eds.glade");
	priv->glade = glade_xml_new (filename, NULL, NULL);
	g_free (filename);

	priv->dialog_get_resources = glade_xml_get_widget (priv->glade, "resources_get");

	gtk_window_set_transient_for (GTK_WINDOW (priv->dialog_get_resources),
				      GTK_WINDOW (plugin->main_window));
	priv->select_group = GTK_COMBO_BOX (glade_xml_get_widget (priv->glade,
								  "select_group"));
	g_signal_connect (priv->select_group, "changed",
			  G_CALLBACK (eds_group_selected),
			  user_data);

	priv->resources_tree_view = GTK_TREE_VIEW (glade_xml_get_widget (priv->glade,
									 "resources"));

	g_signal_connect (glade_xml_get_widget (priv->glade, "ok_button"),
			  "clicked",
			  G_CALLBACK (eds_ok_button_clicked),
			  plugin);
	g_signal_connect (glade_xml_get_widget (priv->glade, "cancel_button"),
			  "clicked",
			  G_CALLBACK (eds_cancel_button_clicked),
			  plugin);
	g_signal_connect (glade_xml_get_widget (priv->glade, "search_button"),
			  "clicked",
			  G_CALLBACK (eds_search_button_clicked),
			  plugin);
	g_signal_connect (glade_xml_get_widget (priv->glade, "all_button"),
			  "clicked",
			  G_CALLBACK (eds_all_button_clicked),
			  plugin);
	g_signal_connect (glade_xml_get_widget (priv->glade, "none_button"),
			  "clicked",
			  G_CALLBACK (eds_none_button_clicked),
			  plugin);
	g_signal_connect (glade_xml_get_widget (priv->glade, "stop_button"),
			  "clicked",
			  G_CALLBACK (eds_stop_button_clicked),
			  plugin);
	g_signal_connect (glade_xml_get_widget (priv->glade, "search_entry"),
			  "key-press-event",
			  G_CALLBACK (eds_search_key_pressed),
			  plugin);

	gtk_widget_show (priv->dialog_get_resources);


	gconf_client = gconf_client_get_default ();
	source_list = e_source_list_new_for_gconf (gconf_client,
						   "/apps/evolution/addressbook/sources");
	/* List with addressbook groups */
	groups = e_source_list_peek_groups (source_list);
	eds_create_groups_model (groups, plugin);
	gtk_combo_box_set_model (priv->select_group, priv->groups_model);
	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->select_group),
				    renderer, TRUE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (priv->select_group),
					renderer, "text", 0, NULL);
	/* g_object_unref (source_list); */
}
예제 #5
0
static gboolean
sql_plugin_retrieve_db_values (PlannerPlugin  *plugin,
			       const gchar    *title,
			       gchar         **server,
			       gchar         **port,
			       gchar         **database,
			       gchar         **login,
			       gchar         **password)
{
	PlannerApplication *application;
	gchar              *filename;
	GladeXML           *gui;
	GtkWidget          *dialog;
	gchar              *str;
	gint                response;
	GtkWidget          *server_entry;
	GtkWidget          *db_entry;
	GtkWidget          *user_entry;
	GtkWidget          *password_entry;
	gboolean            ret;

	application = planner_window_get_application (plugin->main_window);

	filename = mrp_paths_get_glade_dir ("sql.glade");
	gui = glade_xml_new (filename, "open_dialog" , NULL);
	g_free (filename);

	dialog = glade_xml_get_widget (gui, "open_dialog");

	gtk_window_set_title (GTK_WINDOW (dialog), title);

	server_entry   = glade_xml_get_widget (gui, "server_entry");
	db_entry       = glade_xml_get_widget (gui, "db_entry");
	user_entry     = glade_xml_get_widget (gui, "user_entry");
	password_entry = glade_xml_get_widget (gui, "password_entry");

	str = planner_conf_get_string (CONF_SERVER, NULL);
	if (str) {
		gtk_entry_set_text (GTK_ENTRY (server_entry), str);
		g_free (str);
	}

	str = planner_conf_get_string (CONF_DATABASE, NULL);
	if (str) {
		gtk_entry_set_text (GTK_ENTRY (db_entry), str);
		g_free (str);
	}

	str = planner_conf_get_string (CONF_USERNAME, NULL);
	if (str) {
		gtk_entry_set_text (GTK_ENTRY (user_entry), str);
		g_free (str);
	}

	g_object_unref (gui);

	response = gtk_dialog_run (GTK_DIALOG (dialog));

	switch (response) {
	case GTK_RESPONSE_OK:
		*server = strdup_null_if_empty (gtk_entry_get_text (GTK_ENTRY (server_entry)));
		*port = NULL;
		*database = strdup_null_if_empty (gtk_entry_get_text (GTK_ENTRY (db_entry)));
		*login = strdup_null_if_empty (gtk_entry_get_text (GTK_ENTRY (user_entry)));
		*password = strdup_null_if_empty (gtk_entry_get_text (GTK_ENTRY (password_entry)));

		planner_conf_set_string (CONF_SERVER,
					 *server ? *server : "",
					 NULL);

		planner_conf_set_string (CONF_DATABASE,
					 *database ? *database : "",
					 NULL);

		planner_conf_set_string (CONF_USERNAME,
					 *login ? *login : "",
					 NULL);
		ret = TRUE;
		break;

	default:
		ret = FALSE;
		break;
	}

	gtk_widget_destroy (dialog);

	return ret;
}
예제 #6
0
/**
 * Display a list with projects and let the user select one. Returns the project
 * id of the selected one.
 */
static gint
sql_plugin_retrieve_project_id (PlannerPlugin *plugin,
				gchar         *server,
				gchar         *port,
				gchar         *database,
				gchar         *login,
				gchar         *password)
{
	GdaConnection     *conn;
	GdaDataModel      *model;
	gboolean           success;
	GdaClient         *client;
	GladeXML          *gui;
	GtkWidget         *dialog;
	GtkWidget         *treeview;
	GtkWidget         *ok_button;
	GtkListStore      *liststore;
	GtkCellRenderer   *cell;
	GtkTreeViewColumn *col;
	gint               i;
	gint               response;
	gint               project_id;
	GtkTreeSelection  *selection;
	GtkTreeIter        iter;
	gchar             *db_txt;
	const gchar       *dsn_name = "planner-auto";
	const gchar       *provider = "PostgreSQL";
	gchar             *filename;

	db_txt = g_strdup_printf (CONNECTION_FORMAT_STRING,server,database);
	gda_config_save_data_source (dsn_name,
                                     provider,
                                     db_txt,
                                     "planner project", login, password, FALSE);
	g_free (db_txt);

	client = gda_client_new ();
	conn = sql_get_tested_connection (dsn_name, server, database, client, plugin);

	if (conn == NULL) {
		return -1;
	}

	success = sql_execute_command (conn, "BEGIN");
	if (!success) {
		g_warning ("BEGIN command failed.");
		return -1;
	}

	success = sql_execute_command (conn,
				       "DECLARE mycursor CURSOR FOR SELECT proj_id, name,"
				       "phase, revision FROM project ORDER by proj_id ASC");

	if (!success) {
		g_warning ("DECLARE CURSOR command failed (project).");
		return -1;
	}

	model = sql_execute_query (conn, "FETCH ALL in mycursor");

	if (model == NULL) {
		g_warning ("FETCH ALL failed.");
		return -1;
	}

	filename = mrp_paths_get_glade_dir ("sql.glade");
	gui = glade_xml_new (filename, "select_dialog", NULL);
	g_free (filename);

	dialog = glade_xml_get_widget (gui, "select_dialog");
	treeview = glade_xml_get_widget (gui, "project_treeview");
	ok_button = glade_xml_get_widget (gui, "ok_button");

	g_object_unref (gui);

	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);

	g_signal_connect (selection,
			  "changed",
			  G_CALLBACK (selection_changed_cb),
			  ok_button);

	g_signal_connect (treeview,
			  "row_activated",
			  G_CALLBACK (row_activated_cb),
			  ok_button);

	for (i = 0; i < gda_data_model_get_n_rows (model); i++) {
		gint   id;
		gchar *name;
		gchar *phase;
		gint   revision;

		id = get_int (model, i, 0);
		name = get_string (model, i, 1);
		phase = get_string (model, i, 2);
		revision = get_int (model, i, 3);

		/* FIXME: needs fixing in the database backend. */
		if (strcmp (phase, "NULL") == 0) {
			g_free (phase);
			phase = g_strdup ("");
		}

		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 (model) == 0) {
		gtk_widget_set_sensitive (ok_button, FALSE);
	}

	g_object_unref (model);

	sql_execute_command (conn,"CLOSE mycursor");

	gtk_widget_show_all (dialog);
	response = gtk_dialog_run (GTK_DIALOG (dialog));

	project_id = -1;

	switch (response) {
	case GTK_RESPONSE_CANCEL:
	case GTK_RESPONSE_DELETE_EVENT:
		break;
	case GTK_RESPONSE_OK:
		if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
			break;
		}

		gtk_tree_model_get (GTK_TREE_MODEL (liststore),
				    &iter,
				    COL_ID, &project_id,
				    -1);

		break;
	};

	gtk_widget_destroy (dialog);

	return project_id;
}
예제 #7
0
GtkWidget *
planner_phase_dialog_new (PlannerWindow *window)
{
	DialogData       *data;
	GladeXML         *glade;
	GtkWidget        *dialog;
	GtkTreeSelection *selection;
	gchar            *filename;

	g_return_val_if_fail (PLANNER_IS_WINDOW (window), NULL);

	filename = mrp_paths_get_glade_dir ("project-properties.glade");
	glade = glade_xml_new (filename,
			       "phase_dialog",
			       GETTEXT_PACKAGE);
	g_free (filename);

	if (!glade) {
		g_warning ("Could not create phase dialog.");
		return NULL;
	}

	dialog = glade_xml_get_widget (glade, "phase_dialog");

	data = g_new0 (DialogData, 1);

	data->main_window = window;
	data->project = planner_window_get_project (window);
	data->dialog = dialog;

	g_signal_connect_object (window,
				 "destroy",
				 G_CALLBACK (phase_dialog_parent_destroy_cb),
				 dialog,
				 0);

	data->remove_button = glade_xml_get_widget (glade, "remove_button");

	data->tree_view = glade_xml_get_widget (glade, "phase_treeview");

	phase_dialog_setup_tree_view (data);

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->tree_view));
	gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);

	g_signal_connect (selection,
			  "changed",
			  G_CALLBACK (phase_dialog_selection_changed_cb),
			  data);

	g_signal_connect (dialog,
			  "response",
			  G_CALLBACK (phase_dialog_response_cb),
			  data);

	g_object_set_data_full (G_OBJECT (dialog),
				"data", data,
				g_free);

	return dialog;
}
예제 #8
0
void
planner_column_dialog_show (PlannerWindow *window,
			    const gchar   *title,
			    GtkTreeView   *edited_tree)
{
	DialogData *data;
	GladeXML   *glade;
	GtkWidget  *close_button;
	gchar      *filename;

	filename = mrp_paths_get_glade_dir ("column-dialog.glade");
	glade = glade_xml_new (filename, NULL, NULL);
	g_free (filename);

	if (!glade) {
		g_warning ("Could not create column dialog.");
		return;
	}

	data = g_new0 (DialogData, 1);

	data->main_window = window;
	data->edited_tree = edited_tree;

	data->dialog = glade_xml_get_widget (glade, "column_dialog");

	gtk_window_set_title (GTK_WINDOW (data->dialog), title);
	gtk_window_set_transient_for (GTK_WINDOW (data->dialog),
				      GTK_WINDOW (window));
	gtk_window_set_destroy_with_parent (GTK_WINDOW (data->dialog), TRUE);

	data->visible_tree = glade_xml_get_widget (glade, "visible_tree");
	data->hidden_tree = glade_xml_get_widget (glade, "hidden_tree");
	data->up_button = glade_xml_get_widget (glade, "up_button");
	data->down_button = glade_xml_get_widget (glade, "down_button");
	data->show_button = glade_xml_get_widget (glade, "show_button");
	data->hide_button = glade_xml_get_widget (glade, "hide_button");

	column_dialog_setup_tree (data, GTK_TREE_VIEW (data->hidden_tree));
	column_dialog_setup_tree (data, GTK_TREE_VIEW (data->visible_tree));

	column_dialog_fill_trees (data);

	g_signal_connect (data->hidden_tree,
			  "focus-in-event",
			  G_CALLBACK (column_dialog_focus_in_event_cb),
			  data);
	g_signal_connect (data->visible_tree,
			  "focus-in-event",
			  G_CALLBACK (column_dialog_focus_in_event_cb),
			  data);

	g_signal_connect (data->up_button,
			  "clicked",
			  G_CALLBACK (column_dialog_up_button_clicked_cb),
			  data);
	g_signal_connect (data->down_button,
			  "clicked",
			  G_CALLBACK (column_dialog_down_button_clicked_cb),
			  data);
	g_signal_connect (data->hide_button,
			  "clicked",
			  G_CALLBACK (column_dialog_hide_button_clicked_cb),
			  data);
	g_signal_connect (data->show_button,
			  "clicked",
			  G_CALLBACK (column_dialog_show_button_clicked_cb),
			  data);

	close_button = glade_xml_get_widget (glade, "close_button");
	g_signal_connect (close_button,
			  "clicked",
			  G_CALLBACK (column_dialog_close_button_clicked_cb),
			  data);

	g_object_set_data_full (G_OBJECT (data->dialog),
				"data", data,
				g_free);

	column_dialog_update_sensitivity (data);

	gtk_widget_show (data->dialog);

	g_object_unref (glade);
}
예제 #9
0
static void
property_dialog_add_cb (GtkWidget *button,
			GtkWidget *dialog)
{
	PlannerPropertyDialogPriv *priv;
	MrpPropertyType            type;
	const gchar               *label;
	const gchar               *name;
	const gchar               *description;
	GladeXML                  *glade;
	GtkWidget                 *label_entry;
	GtkWidget                 *name_entry;
	GtkWidget                 *add_dialog;
	GtkWidget                 *w;
	gint                       response;
	gboolean                   finished = FALSE;
	gunichar                   c;
	gchar                     *filename;

	priv = GET_PRIV (dialog);

	filename = mrp_paths_get_glade_dir ("new-property.glade");
	glade = glade_xml_new (filename,
			       NULL,
			       NULL);
	g_free (filename);

	add_dialog = glade_xml_get_widget (glade, "add_dialog");

	label_entry = glade_xml_get_widget (glade, "label_entry");
	name_entry = glade_xml_get_widget (glade, "name_entry");

	g_signal_connect (label_entry,
			  "focus_out_event",
			  G_CALLBACK (property_dialog_label_changed_cb),
			  name_entry);

	property_dialog_setup_option_menu (
		glade_xml_get_widget (glade, "type_menu"),
		G_CALLBACK (property_dialog_type_selected_cb),
		add_dialog,
		mrp_property_type_as_string (MRP_PROPERTY_TYPE_STRING),
		MRP_PROPERTY_TYPE_STRING,
		mrp_property_type_as_string (MRP_PROPERTY_TYPE_INT),
		MRP_PROPERTY_TYPE_INT,
		mrp_property_type_as_string (MRP_PROPERTY_TYPE_FLOAT),
		MRP_PROPERTY_TYPE_FLOAT,
/*  		mrp_property_type_as_string (MRP_PROPERTY_TYPE_DATE), */
/*  		MRP_PROPERTY_TYPE_DATE, */
/*  		mrp_property_type_as_string (MRP_PROPERTY_TYPE_DURATION), */
/*  		MRP_PROPERTY_TYPE_DURATION, */
/* 		mrp_property_type_as_string (MRP_PROPERTY_TYPE_COST), */
/*  		MRP_PROPERTY_TYPE_COST, */
		NULL);

	while (!finished) {
		response = gtk_dialog_run (GTK_DIALOG (add_dialog));

		switch (response) {
		case GTK_RESPONSE_OK:
			label = gtk_entry_get_text (GTK_ENTRY (label_entry));
			if (label == NULL || label[0] == 0) {
				finished = FALSE;
				break;
			}

			name = gtk_entry_get_text (GTK_ENTRY (name_entry));
			if (name == NULL || name[0] == 0) {
				finished = FALSE;
				break;
			}

			c = g_utf8_get_char (name);
			if (!g_unichar_isalpha (c)) {
				GtkWidget *msg_dialog;

				msg_dialog = gtk_message_dialog_new (
					GTK_WINDOW (add_dialog),
					GTK_DIALOG_MODAL |
					GTK_DIALOG_DESTROY_WITH_PARENT,
					GTK_MESSAGE_WARNING,
					GTK_BUTTONS_OK,
					_("The name of the custom property needs to start with a letter."));

				gtk_dialog_run (GTK_DIALOG (msg_dialog));
				gtk_widget_destroy (msg_dialog);

				finished = FALSE;
				break;
			}

			w = glade_xml_get_widget (glade, "description_entry");
			description = gtk_entry_get_text (GTK_ENTRY (w));

			w = glade_xml_get_widget (glade, "type_menu");
			type = property_dialog_get_selected (w);

			if (type != MRP_PROPERTY_TYPE_NONE) {
				property_cmd_add (priv->main_window,
						  priv->project,
						  priv->owner,
						  name,
						  type,
						  label,
						  description,
						  TRUE);
			}

			finished = TRUE;
			break;

		case GTK_RESPONSE_DELETE_EVENT:
		case GTK_RESPONSE_CANCEL:
			finished = TRUE;
			break;

		default:
			break;
		}
	}

 	gtk_widget_destroy (add_dialog);
	g_object_unref (glade);
}