Page 1 of 1

Setting the wallpaper mode on the command line

Posted: Sun Jan 03, 2010 3:03 am
by KDulcimer
I've been looking to add in functionality to set the wallpaper mode via the CLI. So far I've come up with the below diff. This diff is very raw and is totally untested. I really am not a coder and so I would appreciate help/pointers on this.

Why won't the forum won't accept .diff, .patch or .txt files?

Code: Select all

diff -uNr pcmanfm-0.5.2-old/src/main.c pcmanfm-0.5.2/src/main.c
--- pcmanfm-0.5.2-old/src/main.c	2009-06-03 09:12:46.000000000 -0400
+++ pcmanfm-0.5.2/src/main.c	2010-01-01 21:43:37.000000000 -0500
@@ -56,6 +56,7 @@
     CMD_DAEMON_MODE,
     CMD_PREF,
     CMD_WALLPAPER,
+    CMD_WALLPAPER_MODE,
     CMD_FIND_FILES
 }SocketEvent;
 
@@ -76,6 +77,7 @@
 
 static int show_pref = 0;
 static gboolean set_wallpaper = FALSE;
+static int set_wallpaper_mode = 0;
 
 static gboolean find_files = FALSE;
 
@@ -101,6 +103,7 @@
 */
 #ifdef DESKTOP_INTEGRATION
     { "set-wallpaper", '\0', 0, G_OPTION_ARG_NONE, &set_wallpaper, N_("Set desktop wallpaper"), NULL },
+    { "set-wallpaper-mode", '\0', 0, G_OPTION_ARG_INT, &set_wallpaper_mode, N_("Set wallpaper mode (0=Fill, 1=Fit, 2=Center, 3=Tiled)")}
 #endif
 
 #ifdef HAVE_HAL
@@ -170,6 +173,9 @@
             case CMD_WALLPAPER:
                 set_wallpaper = TRUE;
                 break;
+            case CMD_WALLPAPER_MODE:
+                set_wallpaper_mode = TRUE;
+                break;
             case CMD_FIND_FILES:
                 find_files = TRUE;
                 break;
@@ -244,6 +250,8 @@
             cmd = CMD_PREF;
         else if( set_wallpaper )
             cmd = CMD_WALLPAPER;
+	else if (set_wallpaper_mode )
+	    cmd = CMD_WALLPAPER_MODE;
         else if( find_files )
             cmd = CMD_FIND_FILES;
 
@@ -584,6 +592,14 @@
         ret = ( daemon_mode || (app_settings.show_desktop && desktop_or_deamon_initialized)  );
         goto out;
     }
+    else if ( set_wallpaper_mode > -1 )
+    {
+        if( app_settings.show_desktop && app_settings.show_wallpaper )
+        {
+            if( desktop_or_deamon_initialized )
+                fm_desktop_update_wallpaper();
+        }
+    }
 #endif
     else /* open files/folders */
     {
diff -uNr pcmanfm-0.5.2-old/src/pref-dialog.c pcmanfm-0.5.2/src/pref-dialog.c
--- pcmanfm-0.5.2-old/src/pref-dialog.c	2009-04-20 13:57:13.000000000 -0400
+++ pcmanfm-0.5.2/src/pref-dialog.c	2010-01-01 20:36:40.000000000 -0500
@@ -98,7 +98,7 @@
 static void set_preview_image( GtkImage* img, const char* file )
 {
     GdkPixbuf* pix = NULL;
-    pix = gdk_pixbuf_new_from_file_at_scale( file, 128, 128, TRUE, NULL );
+    pix = gdk_pixbuf_new_from_file_at_scale( file, 192, 192, TRUE, NULL );
     if( pix )
     {
         gtk_image_set_from_pixbuf( img, pix );

Re: Setting the wallpaper mode on the command line

Posted: Mon Jan 04, 2010 5:33 pm
by maces
Hi

because the forum isn't the right place, have a look at this. It's much more easy for the developers if you would put it into the tracker :)

maces

Re: Setting the wallpaper mode on the command line

Posted: Tue Jan 05, 2010 11:00 pm
by KDulcimer
Well, yeah, I saw that, but I figured that since this patch is untested, I should get some input on it before submitting it to the tracker.