示例#1
0
static void
mv_finalize (GObject *object)
{
	PlannerPlugin *plugin = PLANNER_PLUGIN (object);

	if (plugin->exit) {
		plugin->exit (plugin);
	}

	/* Don't unload modules when running in valgrind to make sure
	 * stack traces won't have missing symbols.
	 */
	if (!RUNNING_ON_VALGRIND) {
		g_module_close (plugin->handle);
	}
}
示例#2
0
static void
html_plugin_export (GtkAction *action,
		    gpointer   user_data)
{
	PlannerPlugin     *plugin;
	MrpProject        *project;
	const gchar       *uri;
	gchar             *filename;
	gchar             *basename;
	gint               res;
	GtkWidget         *filechooser;
	GtkWidget         *dialog;
	GtkWidget         *show_button;
	gboolean           show;

	plugin = PLANNER_PLUGIN (user_data);

	filechooser = gtk_file_chooser_dialog_new (_("Export to HTML"),
						   GTK_WINDOW (plugin->main_window),
						   GTK_FILE_CHOOSER_ACTION_SAVE,
						   GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
						   GTK_STOCK_SAVE, GTK_RESPONSE_OK,
						   NULL);

	gtk_dialog_set_default_response (GTK_DIALOG (filechooser), GTK_RESPONSE_OK);

	project = planner_window_get_project (plugin->main_window);
	uri = mrp_project_get_uri (project);
	if (!uri) {
		gchar *cwd, *tmp;

		cwd = g_get_current_dir ();
		tmp = g_strconcat (_("Unnamed"), ".html", NULL);

		filename = g_build_filename (cwd, tmp, NULL);

		g_free (cwd);
		g_free (tmp);
	} else {
		gchar *tmp;

		if (g_str_has_suffix (uri, ".planner")) {
			tmp = g_strndup (uri,  strlen (uri) - strlen (".planner"));
		}
		else if (g_str_has_suffix (uri, ".mrproject")) {
			tmp = g_strndup (uri,  strlen (uri) - strlen (".mrproject"));
		} else {
			tmp = g_strdup (uri);
		}

		filename = g_strconcat (tmp, ".html", NULL);
		g_free (tmp);
	}

	gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooser),
				       filename);

	basename = g_path_get_basename (filename);

	gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filechooser), basename);

	show_button = gtk_check_button_new_with_label (_("Show result in browser"));
	gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (filechooser), show_button);

	g_free (basename);
	g_free (filename);

 try_again:

	res = gtk_dialog_run (GTK_DIALOG (filechooser));
	switch (res) {
	case GTK_RESPONSE_OK:
		filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));

		if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
			dialog = gtk_message_dialog_new (GTK_WINDOW (filechooser),
							 GTK_DIALOG_MODAL |
							 GTK_DIALOG_DESTROY_WITH_PARENT,
							 GTK_MESSAGE_WARNING,
							 GTK_BUTTONS_YES_NO,
							 _("File \"%s\" exists, do you want to overwrite it?"),
							 filename);
			gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
			res = gtk_dialog_run (GTK_DIALOG (dialog));
			gtk_widget_destroy (dialog);

			switch (res) {
			case GTK_RESPONSE_YES:
				break;

			case GTK_RESPONSE_NO:
			case GTK_RESPONSE_DELETE_EVENT:
				g_free (filename);
				goto try_again;

			default:
				g_assert_not_reached ();
			}
		}

		show = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_button));
		gtk_widget_destroy (filechooser);

		html_plugin_export_do (plugin, filename, show);
		g_free (filename);

		break;
	case GTK_RESPONSE_CANCEL:
		gtk_widget_destroy (filechooser);
		break;
	}
}
static void
xml_planner_plugin_export (GtkAction *action,
			   gpointer   user_data)
{
	PlannerPlugin     *plugin;
	MrpProject        *project;
	GError            *error = NULL;
	GtkWidget         *file_chooser;
	GtkWidget         *dialog;
	gint               response;
	gchar             *filename = NULL;
	gchar             *real_filename;
	gchar             *last_dir;

	plugin = PLANNER_PLUGIN (user_data);

 try_again:

	file_chooser = gtk_file_chooser_dialog_new (_("Export"),
						    GTK_WINDOW (plugin->main_window),
						    GTK_FILE_CHOOSER_ACTION_SAVE,
						    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
						    GTK_STOCK_SAVE, GTK_RESPONSE_OK,
						    NULL);
	gtk_window_set_modal (GTK_WINDOW (file_chooser), TRUE);

	last_dir = get_last_dir ();
	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_chooser), last_dir);
	g_free (last_dir);

	response = gtk_dialog_run (GTK_DIALOG (file_chooser));
	if (response == GTK_RESPONSE_OK) {
		filename = gtk_file_chooser_get_filename (
			GTK_FILE_CHOOSER (file_chooser));
	}

	gtk_widget_destroy (file_chooser);

	if (filename) {
		if (!g_str_has_suffix (filename, ".mrproject") && !g_str_has_suffix (filename, ".planner")) {
			/* Add the old extension for old format files. */
			real_filename = g_strconcat (filename, ".mrproject", NULL);
		} else {
			real_filename = g_strdup (filename);
		}

		if (g_file_test (real_filename, G_FILE_TEST_EXISTS)) {
			dialog = gtk_message_dialog_new (GTK_WINDOW (plugin->main_window),
							 GTK_DIALOG_MODAL |
							 GTK_DIALOG_DESTROY_WITH_PARENT,
							 GTK_MESSAGE_WARNING,
							 GTK_BUTTONS_YES_NO,
							 _("File \"%s\" exists, "
							   "do you want to overwrite it?"),
							 real_filename);

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

			switch (response) {
			case GTK_RESPONSE_YES:
				break;
			default:
				g_free (real_filename);
				goto try_again;
			}
		}
	}

	if (!filename) {
		return;
	}

	project = planner_window_get_project (plugin->main_window);

	if (!mrp_project_export (project, real_filename,
				 "Planner XML pre-0.12",
				 TRUE,
				 &error)) {
		g_warning ("Error while export to Planner XML: %s", error->message);
	}

	last_dir = g_path_get_dirname (real_filename);
	planner_conf_set_string (CONF_MAIN_LAST_XML_EXPORT_DIR, last_dir, NULL);
	g_free (last_dir);

	g_free (real_filename);
	g_free (filename);
}
示例#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); */
}