[gnome-color-manager] trivial: add the required working_path fixes to make GCM_CALIBRATE_PRINT_KIND_ANALYSE actually work
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: add the required working_path fixes to make GCM_CALIBRATE_PRINT_KIND_ANALYSE actually work
- Date: Tue, 23 Feb 2010 17:06:57 +0000 (UTC)
commit ebead7bf167c36ef0530e66ad06d711c071d7cb3
Author: Richard Hughes <richard hughsie com>
Date: Tue Feb 23 15:11:57 2010 +0000
trivial: add the required working_path fixes to make GCM_CALIBRATE_PRINT_KIND_ANALYSE actually work
src/gcm-calibrate-argyll.c | 33 +++++++++-------
src/gcm-calibrate.c | 89 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+), 14 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index fa2febb..90590e1 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -350,6 +350,7 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
"output-name", &output_name,
NULL);
@@ -461,6 +462,7 @@ gcm_calibrate_argyll_display_read_chart (GcmCalibrateArgyll *calibrate_argyll, G
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
NULL);
/* get correct name of the command */
@@ -547,6 +549,7 @@ gcm_calibrate_argyll_display_generate_patches (GcmCalibrateArgyll *calibrate_arg
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
"device-type", &device_type,
NULL);
@@ -644,6 +647,7 @@ gcm_calibrate_argyll_display_draw_and_measure (GcmCalibrateArgyll *calibrate_arg
/* get shared data */
g_object_get (calibrate_argyll,
+ "working-path", &working_path,
"basename", &basename,
NULL);
@@ -744,6 +748,7 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
"device", &device,
NULL);
@@ -899,6 +904,7 @@ gcm_calibrate_argyll_device_copy (GcmCalibrateArgyll *calibrate_argyll, GError *
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
"reference-kind", &reference_kind,
"filename-source", &filename_source,
"filename-reference", &filename_reference,
@@ -981,6 +987,7 @@ gcm_calibrate_argyll_device_measure (GcmCalibrateArgyll *calibrate_argyll, GErro
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
NULL);
/* TRANSLATORS: title, drawing means painting to the screen */
@@ -1080,6 +1087,7 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
"reference-kind", &reference_kind,
"device", &device,
NULL);
@@ -1197,6 +1205,7 @@ gcm_calibrate_argyll_finish (GcmCalibrateArgyll *calibrate_argyll, GError **erro
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
NULL);
/* remove all the temp files */
@@ -1362,6 +1371,7 @@ gcm_calibrate_argyll_display_generate_targets (GcmCalibrateArgyll *calibrate_arg
/* get shared data */
g_object_get (calibrate_argyll,
"basename", &basename,
+ "working-path", &working_path,
"colorimeter-kind", &colorimeter_kind,
NULL);
@@ -1465,6 +1475,7 @@ gcm_calibrate_argyll_render_cb (GcmPrint *print, GtkPageSetup *page_setup, GcmCa
/* get shared data */
g_object_get (calibrate,
"basename", &basename,
+ "working-path", &working_path,
NULL);
paper_size = gtk_page_setup_get_paper_size (page_setup);
@@ -1476,8 +1487,6 @@ gcm_calibrate_argyll_render_cb (GcmPrint *print, GtkPageSetup *page_setup, GcmCa
if (!ret)
goto out;
- //FIXME: we need a temp directory, not just the root of tmp
-
/* list files */
dir = g_dir_open (working_path, 0, error);
if (dir == NULL)
@@ -1510,6 +1519,8 @@ static gboolean
gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, GtkWindow *window, GError **error)
{
gboolean ret;
+ gchar *cmdline = NULL;
+ gchar *working_path = NULL;
const gchar *title;
const gchar *message;
GtkResponseType response;
@@ -1520,6 +1531,7 @@ gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, GtkWindow *window, GError
/* need to ask if we are printing now, or using old data */
g_object_get (calibrate,
"print-kind", &print_kind,
+ "working-path", &working_path,
NULL);
/* set modal windows up correctly */
@@ -1538,7 +1550,6 @@ gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, GtkWindow *window, GError
if (print_kind == GCM_CALIBRATE_PRINT_KIND_LOCAL ||
print_kind == GCM_CALIBRATE_PRINT_KIND_GENERATE) {
window = gcm_calibrate_dialog_get_window (priv->calibrate_dialog);
- //TODO: we need to send a temp directory
ret = gcm_print_with_render_callback (priv->print, window, (GcmPrintRenderCb) gcm_calibrate_argyll_render_cb, calibrate, error);
if (!ret)
goto out;
@@ -1546,17 +1557,9 @@ gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, GtkWindow *window, GError
/* we're done */
if (print_kind == GCM_CALIBRATE_PRINT_KIND_GENERATE) {
- egg_warning ("we need to open the directory we're using");
- goto out;
- }
-
- /* we're done */
- if (print_kind == GCM_CALIBRATE_PRINT_KIND_ANALYSE) {
- g_set_error_literal (error,
- GCM_CALIBRATE_ERROR,
- GCM_CALIBRATE_ERROR_USER_ABORT,
- "FIXME: need to show file chooser");
- ret = FALSE;
+ cmdline = g_strdup_printf ("nautilus \"%s\"", working_path);
+ egg_debug ("we need to open the directory we're using: %s", cmdline);
+ ret = g_spawn_command_line_async (cmdline, error);
goto out;
}
@@ -1595,6 +1598,8 @@ gcm_calibrate_argyll_printer (GcmCalibrate *calibrate, GtkWindow *window, GError
if (!ret)
goto out;
out:
+ g_free (cmdline);
+ g_free (working_path);
return ret;
}
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index e85d603..aee5b72 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -379,6 +379,24 @@ out:
}
/**
+ * gcm_calibrate_set_working_path:
+ **/
+static gboolean
+gcm_calibrate_set_working_path (GcmCalibrate *calibrate, GError **error)
+{
+ gboolean ret = FALSE;
+ GcmCalibratePrivate *priv = calibrate->priv;
+
+ /* remove old value */
+ g_free (priv->working_path);
+
+ /* use the basename */
+ priv->working_path = g_build_filename (g_get_user_config_dir (), "gnome-color-manager", "calibration", priv->basename, NULL);
+ ret = gcm_utils_mkdir_with_parents (priv->working_path, error);
+ return ret;
+}
+
+/**
* gcm_calibrate_display:
**/
gboolean
@@ -405,6 +423,11 @@ gcm_calibrate_display (GcmCalibrate *calibrate, GtkWindow *window, GError **erro
goto out;
}
+ /* set the per-profile filename */
+ ret = gcm_calibrate_set_working_path (calibrate, error);
+ if (!ret)
+ goto out;
+
/* coldplug source */
if (klass->calibrate_display == NULL) {
ret = FALSE;
@@ -666,6 +689,42 @@ out:
}
/**
+ * gcm_calibrate_file_chooser_get_working_path:
+ **/
+static gchar *
+gcm_calibrate_file_chooser_get_working_path (GcmCalibrate *calibrate, GtkWindow *window)
+{
+ GtkWidget *dialog;
+ gchar *current_folder;
+ gchar *working_path = NULL;
+
+ /* start in the correct place */
+ current_folder = g_build_filename (g_get_user_config_dir (), "gnome-color-manager", "calibration", NULL);
+
+ /* TRANSLATORS: dialog for file->open dialog */
+ dialog = gtk_file_chooser_dialog_new (_("Select ICC Profile File"), window,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ _("Open"), GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_window_set_icon_name (GTK_WINDOW (dialog), GCM_STOCK_ICON);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(dialog), current_folder);
+ gtk_file_chooser_set_create_folders (GTK_FILE_CHOOSER(dialog), FALSE);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER(dialog), FALSE);
+
+ /* did user choose file */
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ working_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog));
+
+ /* we're done */
+ gtk_widget_destroy (dialog);
+
+ /* or NULL for missing */
+ g_free (current_folder);
+ return working_path;
+}
+
+/**
* gcm_calibrate_printer:
**/
gboolean
@@ -674,6 +733,7 @@ gcm_calibrate_printer (GcmCalibrate *calibrate, GtkWindow *window, GError **erro
gboolean ret = FALSE;
const gchar *title;
const gchar *message;
+ GtkWindow *window_tmp;
GtkResponseType response;
GcmCalibrateClass *klass = GCM_CALIBRATE_GET_CLASS (calibrate);
GcmCalibratePrivate *priv = calibrate->priv;
@@ -702,6 +762,30 @@ gcm_calibrate_printer (GcmCalibrate *calibrate, GtkWindow *window, GError **erro
/* copy */
g_object_get (priv->calibrate_dialog, "print-kind", &priv->print_kind, NULL);
+ if (priv->print_kind != GCM_CALIBRATE_PRINT_KIND_ANALYSE) {
+ /* set the per-profile filename */
+ ret = gcm_calibrate_set_working_path (calibrate, error);
+ if (!ret)
+ goto out;
+ } else {
+
+ /* remove previously set value (if any) */
+ g_free (priv->working_path);
+ priv->working_path = NULL;
+
+ /* get from the user */
+ window_tmp = gcm_calibrate_dialog_get_window (priv->calibrate_dialog);
+ priv->working_path = gcm_calibrate_file_chooser_get_working_path (calibrate, window_tmp);
+ if (priv->working_path == NULL) {
+ g_set_error_literal (error,
+ GCM_CALIBRATE_ERROR,
+ GCM_CALIBRATE_ERROR_USER_ABORT,
+ "user did not choose folder");
+ ret = FALSE;
+ goto out;
+ }
+ }
+
/* coldplug source */
if (klass->calibrate_printer == NULL) {
g_set_error_literal (error,
@@ -864,6 +948,11 @@ gcm_calibrate_device (GcmCalibrate *calibrate, GtkWindow *window, GError **error
"device", device,
NULL);
+ /* set the per-profile filename */
+ ret = gcm_calibrate_set_working_path (calibrate, error);
+ if (!ret)
+ goto out;
+
/* coldplug source */
if (klass->calibrate_device == NULL) {
g_set_error_literal (error,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]