[Goodies-commits] r6235 - in xfce4-screenshooter-plugin/trunk: . lib panel-plugin src
Jerome Guelfucci
jeromeg at xfce.org
Sun Nov 30 09:43:23 CET 2008
Author: jeromeg
Date: 2008-11-30 08:43:23 +0000 (Sun, 30 Nov 2008)
New Revision: 6235
Modified:
xfce4-screenshooter-plugin/trunk/ChangeLog
xfce4-screenshooter-plugin/trunk/lib/screenshooter-actions.c
xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h
xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h
xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c
xfce4-screenshooter-plugin/trunk/src/main.c
Log:
* src/main.c:
- remove preferences CLI option , the application can set the
default save folder now.
- fix the rc file mess. Use xfce_resource_lookup and
xfce_resource_save_location so that folders get created if they
don't exist. Thanks to Nick Schermer for helping.
* lib/screenshooter-utils.{c,h}:
- remove the dir_only option in (screenshooter_read_rc_file).
* lib/screenshooter-dialogs.{c,h}:
- remove (screenshooter_preferences_dialog).
*lib/screenshooter-actions.c:
- don't hardcode "/tmp", use g_get_tmp_dir () instead.
* panel-plugin/screenshooter-plugin.c:
- use new syntax for screenshooter_read_rc_file.
Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog 2008-11-30 06:44:54 UTC (rev 6234)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog 2008-11-30 08:43:23 UTC (rev 6235)
@@ -1,3 +1,20 @@
+2008-11-30 jeromeg
+
+ * src/main.c:
+ - remove preferences CLI option , the application can set the
+ default save folder now.
+ - fix the rc file mess. Use xfce_resource_lookup and
+ xfce_resource_save_location so that folders get created if they
+ don't exist. Thanks to Nick Schermer for helping.
+ * lib/screenshooter-utils.{c,h}:
+ - remove the dir_only option in (screenshooter_read_rc_file).
+ * lib/screenshooter-dialogs.{c,h}:
+ - remove (screenshooter_preferences_dialog).
+ *lib/screenshooter-actions.c:
+ - don't hardcode "/tmp", use g_get_tmp_dir () instead.
+ * panel-plugin/screenshooter-plugin.c:
+ - use new syntax for screenshooter_read_rc_file.
+
2008-11-28 jeromeg
* lib/screenshooter-dialogs.c:
Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-actions.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-actions.c 2008-11-30 06:44:54 UTC (rev 6234)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-actions.c 2008-11-30 08:43:23 UTC (rev 6235)
@@ -40,7 +40,7 @@
gchar *screenshot_path =
screenshooter_save_screenshot (screenshot,
FALSE,
- "/tmp");
+ g_strdup (g_get_tmp_dir ()));
if (screenshot_path != NULL)
{
screenshooter_open_screenshot (screenshot_path, sd->app);
Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c 2008-11-30 06:44:54 UTC (rev 6234)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c 2008-11-30 08:43:23 UTC (rev 6235)
@@ -861,50 +861,6 @@
-/* Dialog to set the screenshot_dir when using the main executable
- at rc_file: file where the option will be saved.
- at current_default_dir: the current default dir to set the file chooser.
-*/
-void screenshooter_preferences_dialog (gchar *rc_file,
- gchar *current_default_dir)
-{
- GtkWidget * chooser;
- gint dialog_response;
- gchar * dir;
- XfceRc *rc;
-
- /* The preferences dialog is a plain gtk_file_chooser, we just get the
- folder the user selected and write it in the conf file*/
-
- chooser =
- gtk_file_chooser_dialog_new (_("Default save location"),
- NULL,
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
- gtk_window_set_icon_name (GTK_WINDOW (chooser), "applets-screenshooter");
- gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT);
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
- current_default_dir);
-
- dialog_response = gtk_dialog_run(GTK_DIALOG (chooser));
-
- if (dialog_response == GTK_RESPONSE_ACCEPT)
- {
- dir = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
-
- rc = xfce_rc_simple_open (rc_file, FALSE);
- xfce_rc_write_entry (rc, "screenshot_dir", dir);
- xfce_rc_close (rc);
-
- g_free (dir);
- }
- gtk_widget_destroy (GTK_WIDGET (chooser));
-}
-
-
-
/* Saves the screenshot according to the options in sd.
* @screenshot: a GdkPixbuf containing our screenshot
* show_save_dialog: whether the save dialog should be shown.
Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h 2008-11-30 06:44:54 UTC (rev 6234)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.h 2008-11-30 08:43:23 UTC (rev 6235)
@@ -36,9 +36,6 @@
GtkWidget
*screenshooter_dialog_new (ScreenshotData *sd,
gboolean plugin);
-void
-screenshooter_preferences_dialog (gchar *rc_file,
- gchar *current_default_dir);
gchar
*screenshooter_save_screenshot (GdkPixbuf *screenshot,
gboolean show_save_dialog,
Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c 2008-11-30 06:44:54 UTC (rev 6234)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.c 2008-11-30 08:43:23 UTC (rev 6235)
@@ -232,8 +232,7 @@
*/
void
screenshooter_read_rc_file (gchar *file,
- ScreenshotData *sd,
- gboolean dir_only)
+ ScreenshotData *sd)
{
XfceRc *rc;
gint delay = 0;
@@ -245,31 +244,28 @@
gchar *app = g_strdup ("none");
#endif
- if (g_file_test (file, G_FILE_TEST_EXISTS))
+ if (file != NULL)
{
rc = xfce_rc_simple_open (file, TRUE);
if (rc != NULL)
{
- if (!dir_only)
- {
- delay = xfce_rc_read_int_entry (rc, "delay", 0);
+ delay = xfce_rc_read_int_entry (rc, "delay", 0);
- mode = xfce_rc_read_int_entry (rc, "mode", FULLSCREEN);
+ mode = xfce_rc_read_int_entry (rc, "mode", FULLSCREEN);
- action = xfce_rc_read_int_entry (rc, "action", SAVE);
+ action = xfce_rc_read_int_entry (rc, "action", SAVE);
- show_save_dialog =
- xfce_rc_read_int_entry (rc, "show_save_dialog", 1);
+ show_save_dialog =
+ xfce_rc_read_int_entry (rc, "show_save_dialog", 1);
- #ifdef HAVE_GIO
- g_free (app);
+ #ifdef HAVE_GIO
+ g_free (app);
- app =
- g_strdup (xfce_rc_read_entry (rc, "app", "none"));
- #endif
- }
-
+ app =
+ g_strdup (xfce_rc_read_entry (rc, "app", "none"));
+ #endif
+
g_free (screenshot_dir);
screenshot_dir =
@@ -303,6 +299,8 @@
ScreenshotData *sd)
{
XfceRc *rc;
+
+ g_return_if_fail (file != NULL);
rc = xfce_rc_simple_open (file, FALSE);
@@ -317,6 +315,8 @@
#ifdef HAVE_GIO
xfce_rc_write_entry (rc, "app", sd->app);
#endif
+
+ xfce_rc_flush (rc);
xfce_rc_close (rc);
}
Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h 2008-11-30 06:44:54 UTC (rev 6234)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-utils.h 2008-11-30 08:43:23 UTC (rev 6235)
@@ -82,8 +82,7 @@
void
screenshooter_read_rc_file (gchar *file,
- ScreenshotData *sd,
- gboolean dir_only);
+ ScreenshotData *sd);
void
screenshooter_write_rc_file (gchar *file,
Modified: xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c 2008-11-30 06:44:54 UTC (rev 6234)
+++ xfce4-screenshooter-plugin/trunk/panel-plugin/screenshooter-plugin.c 2008-11-30 08:43:23 UTC (rev 6235)
@@ -187,8 +187,7 @@
screenshooter_plugin_read_rc_file (XfcePanelPlugin *plugin, PluginData *pd)
{
screenshooter_read_rc_file (xfce_panel_plugin_lookup_rc_file (plugin),
- pd->sd,
- FALSE);
+ pd->sd);
}
@@ -200,8 +199,8 @@
static void
screenshooter_plugin_write_rc_file (XfcePanelPlugin *plugin, PluginData *pd)
{
- screenshooter_write_rc_file (xfce_panel_plugin_save_location (plugin, TRUE),
- pd->sd);
+ screenshooter_write_rc_file (
+ xfce_panel_plugin_save_location (plugin, TRUE), pd->sd);
}
Modified: xfce4-screenshooter-plugin/trunk/src/main.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/src/main.c 2008-11-30 06:44:54 UTC (rev 6234)
+++ xfce4-screenshooter-plugin/trunk/src/main.c 2008-11-30 08:43:23 UTC (rev 6235)
@@ -30,7 +30,6 @@
gboolean window = FALSE;
gboolean fullscreen = FALSE;
gboolean no_save_dialog = FALSE;
-gboolean preferences = FALSE;
gchar *screenshot_dir;
gint delay = 0;
@@ -67,10 +66,6 @@
N_("Directory where the screenshot will be saved"),
NULL
},
- { "preferences", 'p', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &preferences,
- N_("Dialog to set the default save folder"),
- NULL
- },
{ NULL }
};
@@ -81,15 +76,18 @@
GError *cli_error = NULL;
GdkPixbuf *screenshot;
ScreenshotData *sd = g_new0 (ScreenshotData, 1);
- gchar *rc_file;
+ gchar *rc_file =
+ xfce_resource_lookup (XFCE_RESOURCE_CONFIG,
+ "xfce4/xfce4-screenshooter");
xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
- /* Get the path to the conf file */
- rc_file = g_build_filename (xfce_get_homedir(), ".config", "xfce4",
- "xfce4-screenshooter", NULL);
+ /* Read the preferences */
+
+ screenshooter_read_rc_file (rc_file, sd);
- screenshooter_read_rc_file (rc_file, sd, !(window || fullscreen));
+ if (rc_file != NULL)
+ g_free (rc_file);
/* Print a message to advise to use help when a non existing cli option is
passed to the executable. */
@@ -111,8 +109,8 @@
return 0;
}
- /* If -w is given to the executable, grab the active window, else just grab
- the desktop.*/
+ /* If -w is given to the executable, grab the active window, else just
+ * grab the desktop.*/
if (window)
{
sd->mode = ACTIVE_WINDOW;
@@ -175,11 +173,6 @@
g_object_unref (screenshot);
}
- /* If -p is given, show the preferences dialog */
- else if (preferences)
- {
- screenshooter_preferences_dialog (rc_file, sd->screenshot_dir);
- }
/* Else we just show up the main application */
else
{
@@ -187,17 +180,24 @@
gint response;
GdkDisplay *display = gdk_display_get_default ();
+ rc_file = xfce_resource_lookup (XFCE_RESOURCE_CONFIG,
+ "xfce4/xfce4-screenshooter");
+
/* Read the preferences */
- screenshooter_read_rc_file (rc_file, sd, FALSE);
+ screenshooter_read_rc_file (rc_file, sd);
+ if (rc_file != NULL)
+ g_free (rc_file);
+
/* Set the dialog up */
dialog = screenshooter_dialog_new (sd, FALSE);
gtk_window_set_type_hint(GTK_WINDOW (dialog),
GDK_WINDOW_TYPE_HINT_NORMAL);
- /* Run the dialog and destroy it, so that it's not grabbed in active
- window mode */
+ /* Run the dialog and destroy it, so that it's not grabbed in
+ * active window mode */
+
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
@@ -208,10 +208,21 @@
if (response == GTK_RESPONSE_OK)
{
+ rc_file =
+ xfce_resource_save_location (XFCE_RESOURCE_CONFIG,
+ "xfce4/xfce4-screenshooter",
+ TRUE);
+
screenshooter_take_and_output_screenshot (sd);
- /* Save preferences */
- screenshooter_write_rc_file (rc_file, sd);
+ /* Save preferences */
+
+ if (rc_file != NULL)
+ {
+ screenshooter_write_rc_file (rc_file, sd);
+
+ g_free (rc_file);
+ }
}
}
@@ -220,7 +231,6 @@
g_free (sd->app);
#endif
g_free (sd);
- g_free (rc_file);
return 0;
}
More information about the Goodies-commits
mailing list