[Goodies-commits] r7367 - in xfce4-screenshooter/trunk: . lib
Jerome Guelfucci
jeromeg at xfce.org
Mon May 18 23:24:32 CEST 2009
Author: jeromeg
Date: 2009-05-18 21:24:31 +0000 (Mon, 18 May 2009)
New Revision: 7367
Modified:
xfce4-screenshooter/trunk/ChangeLog
xfce4-screenshooter/trunk/lib/screenshooter-actions.c
xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c
xfce4-screenshooter/trunk/lib/screenshooter-global.h
xfce4-screenshooter/trunk/lib/screenshooter-utils.c
xfce4-screenshooter/trunk/lib/screenshooter-zimagez.c
xfce4-screenshooter/trunk/lib/screenshooter-zimagez.h
Log:
* Improve the status dialog of the upload to ZimageZ.
* Remember the last ZimageZ user name and put it in the user field
when displaying the dialog for the first time.
Modified: xfce4-screenshooter/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter/trunk/ChangeLog 2009-05-18 18:34:30 UTC (rev 7366)
+++ xfce4-screenshooter/trunk/ChangeLog 2009-05-18 21:24:31 UTC (rev 7367)
@@ -1,5 +1,11 @@
2009-05-18 jeromeg
+ * Improve the status dialog of the upload to ZimageZ.
+ * Remember the last ZimageZ user name and put it in the user field
+ when displaying the dialog for the first time.
+
+2009-05-18 jeromeg
+
* lib/screenshooter-dialogs.c:
- (screenshooter_dialog_new) add a radio button for uploading in the
actions. Indent some comments correctly.
Modified: xfce4-screenshooter/trunk/lib/screenshooter-actions.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-actions.c 2009-05-18 18:34:30 UTC (rev 7366)
+++ xfce4-screenshooter/trunk/lib/screenshooter-actions.c 2009-05-18 21:24:31 UTC (rev 7367)
@@ -117,7 +117,7 @@
}
else
{
- screenshooter_upload_to_zimagez (screenshot_path);
+ screenshooter_upload_to_zimagez (screenshot_path, sd->last_user);
}
}
Modified: xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c 2009-05-18 18:34:30 UTC (rev 7366)
+++ xfce4-screenshooter/trunk/lib/screenshooter-dialogs.c 2009-05-18 21:24:31 UTC (rev 7367)
@@ -773,7 +773,6 @@
gtk_table_attach_defaults (GTK_TABLE (capture_table), area_main_box, 0, 1, 0, 2);
/* Create area label */
-
area_label = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL (area_label),
Modified: xfce4-screenshooter/trunk/lib/screenshooter-global.h
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-global.h 2009-05-18 18:34:30 UTC (rev 7366)
+++ xfce4-screenshooter/trunk/lib/screenshooter-global.h 2009-05-18 21:24:31 UTC (rev 7367)
@@ -48,6 +48,7 @@
gint close;
gchar *screenshot_dir;
gchar *app;
+ gchar *last_user;
gboolean cli;
}
ScreenshotData;
Modified: xfce4-screenshooter/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-utils.c 2009-05-18 18:34:30 UTC (rev 7366)
+++ xfce4-screenshooter/trunk/lib/screenshooter-utils.c 2009-05-18 21:24:31 UTC (rev 7367)
@@ -65,6 +65,7 @@
gint close_app = 1;
gchar *screenshot_dir = g_strdup (home_uri);
gchar *app = g_strdup ("none");
+ gchar *last_user = g_strdup ("");
if (G_LIKELY (file != NULL))
{
@@ -86,6 +87,9 @@
g_free (app);
app = g_strdup (xfce_rc_read_entry (rc, "app", "none"));
+ g_free (last_user);
+ last_user = g_strdup (xfce_rc_read_entry (rc, "last_user", ""));
+
g_free (screenshot_dir);
screenshot_dir =
g_strdup (xfce_rc_read_entry (rc, "screenshot_dir", home_uri));
@@ -107,6 +111,7 @@
sd->close = close_app;
sd->screenshot_dir = screenshot_dir;
sd->app = app;
+ sd->last_user = last_user;
}
@@ -138,6 +143,7 @@
xfce_rc_write_int_entry (rc, "close", sd->close);
xfce_rc_write_entry (rc, "screenshot_dir", sd->screenshot_dir);
xfce_rc_write_entry (rc, "app", sd->app);
+ xfce_rc_write_entry (rc, "last_user", sd->last_user);
TRACE ("Flush and close the rc file");
Modified: xfce4-screenshooter/trunk/lib/screenshooter-zimagez.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-zimagez.c 2009-05-18 18:34:30 UTC (rev 7366)
+++ xfce4-screenshooter/trunk/lib/screenshooter-zimagez.c 2009-05-18 21:24:31 UTC (rev 7367)
@@ -49,7 +49,8 @@
const gchar *link,
gpointer user_data);
static void open_zimagez_link (gpointer unused);
-static ScreenshooterJob *zimagez_upload_to_zimagez (const gchar *file_name);
+static ScreenshooterJob *zimagez_upload_to_zimagez (const gchar *file_name,
+ gchar *last_user);
static gboolean zimagez_upload_job (ScreenshooterJob *job,
GValueArray *param_values,
GError **error);
@@ -112,7 +113,8 @@
gchar *online_file_name = NULL;
gchar *password = g_strdup ("");
gchar *title = g_strdup ("");
- gchar *user = g_strdup ("");
+ gchar *user;
+ gchar **last_user;
gsize data_length;
@@ -130,13 +132,18 @@
g_return_val_if_fail (SCREENSHOOTER_IS_JOB (job), FALSE);
g_return_val_if_fail (param_values != NULL, FALSE);
- g_return_val_if_fail (param_values->n_values == 1, FALSE);
+ g_return_val_if_fail (param_values->n_values == 2, FALSE);
g_return_val_if_fail (G_VALUE_HOLDS_STRING (¶m_values->values[0]), FALSE);
+ g_return_val_if_fail (G_VALUE_HOLDS_POINTER (¶m_values->values[1]), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (exo_job_set_error_if_cancelled (EXO_JOB (job), error))
return FALSE;
+ /* Get the last user */
+ last_user = g_value_get_pointer (g_value_array_get_nth (param_values, 1));
+ user = g_strdup (*last_user);
+
/* Get the path of the image that is to be uploaded */
image_path = g_value_get_string (g_value_array_get_nth (param_values, 0));
@@ -456,6 +463,9 @@
xmlrpc_DECREF (resultP);
+ g_free (*last_user);
+ *last_user = g_strdup (user);
+
g_free (user);
g_free (password);
g_free (encoded_password);
@@ -580,12 +590,13 @@
static ScreenshooterJob
-*zimagez_upload_to_zimagez (const gchar *file_path)
+*zimagez_upload_to_zimagez (const gchar *file_path, gchar *last_user)
{
g_return_val_if_fail (file_path != NULL, NULL);
- return screenshooter_simple_job_launch (zimagez_upload_job, 1,
- G_TYPE_STRING, file_path);
+ return screenshooter_simple_job_launch (zimagez_upload_job, 2,
+ G_TYPE_STRING, file_path,
+ G_TYPE_POINTER, &last_user);
}
@@ -977,6 +988,7 @@
* screenshooter_upload_to_zimagez:
* @image_path: the local path of the image that should be uploaded to
* ZimageZ.com.
+ * @last_user: the last user name used, to pre-fill the user field.
*
* Uploads the image whose path is @image_path: a dialog asks for the user
* login, password, a title for the image and a comment; then the image is
@@ -985,11 +997,12 @@
*
**/
-void screenshooter_upload_to_zimagez (const gchar *image_path)
+void screenshooter_upload_to_zimagez (const gchar *image_path, gchar *last_user)
{
ScreenshooterJob *job;
- GtkWidget *dialog = NULL;
- GtkWidget *label;
+ GtkWidget *dialog;
+ GtkWidget *label, *status_label;
+ GtkWidget *main_box, *main_alignment;
g_return_if_fail (image_path != NULL);
@@ -1000,17 +1013,40 @@
NULL);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
- gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), 20);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG(dialog)->vbox), 12);
gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "gtk-info");
+ /* Create the main alignment for the dialog */
+ main_alignment = gtk_alignment_new (0, 0, 1, 1);
+
+ gtk_alignment_set_padding (GTK_ALIGNMENT (main_alignment), 6, 0, 6, 6);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), main_alignment, TRUE, TRUE, 0);
+
+ /* Create the main box for the dialog */
+ main_box = gtk_vbox_new (FALSE, 10);
+
+ gtk_container_set_border_width (GTK_CONTAINER (main_box), 12);
+ gtk_container_add (GTK_CONTAINER (main_alignment), main_box);
+
+ /* Status label*/
+ status_label = gtk_label_new ("");
+
+ gtk_label_set_markup (GTK_LABEL (status_label),
+ _("<span weight=\"bold\" stretch=\"semiexpanded\">"
+ "Status</span>"));
+
+ gtk_misc_set_alignment (GTK_MISC (status_label), 0, 0);
+ gtk_container_add (GTK_CONTAINER (main_box), status_label);
+
+ /* Information label */
label = gtk_label_new ("");
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), label);
- gtk_widget_show (label);
+ gtk_container_add (GTK_CONTAINER (main_box), label);
- job = zimagez_upload_to_zimagez (image_path);
+ gtk_widget_show_all (GTK_DIALOG(dialog)->vbox);
+ job = zimagez_upload_to_zimagez (image_path, last_user);
+
g_signal_connect (job, "ask", (GCallback) cb_ask_for_information, NULL);
g_signal_connect (job, "image-uploaded", (GCallback) cb_image_uploaded, NULL);
g_signal_connect (job, "error", (GCallback) cb_error, NULL);
Modified: xfce4-screenshooter/trunk/lib/screenshooter-zimagez.h
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-zimagez.h 2009-05-18 18:34:30 UTC (rev 7366)
+++ xfce4-screenshooter/trunk/lib/screenshooter-zimagez.h 2009-05-18 21:24:31 UTC (rev 7367)
@@ -35,7 +35,8 @@
#include "sexy-url-label.h"
-void screenshooter_upload_to_zimagez (const gchar *image_path);
+void screenshooter_upload_to_zimagez (const gchar *image_path,
+ gchar *last_user);
#endif
More information about the Goodies-commits
mailing list