From 3b09f3d8839f8ca12de4ca0ac1542bd57c695e90 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sat, 22 May 2021 16:56:19 +0200 Subject: [PATCH] SetBG: add support for Caja Caja is a fork of Gnome 2 Nautilus and still behaves mostly the same. Only some gsettings keys differ. --- src/SetBG.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/SetBG.h | 11 +++++++++++ 2 files changed, 60 insertions(+) diff --git a/src/SetBG.cc b/src/SetBG.cc index 1f08d1c..93ba5fc 100644 --- a/src/SetBG.cc +++ b/src/SetBG.cc @@ -52,6 +52,9 @@ SetBG* SetBG::get_bg_setter() case SetBG::NEMO: setter = new SetBGNemo(); break; + case SetBG::CAJA: + setter = new SetBGCaja(); + break; #ifdef USE_XINERAMA case SetBG::XINERAMA: XineramaScreenInfo *xinerama_info; @@ -311,6 +314,7 @@ SetBG::RootWindowData SetBG::check_window_type(Display *display, Window window) if (strclass == std::string("Xfdesktop")) retval.type = SetBG::XFCE; else if (strclass == std::string("Nautilus")) retval.type = SetBG::NAUTILUS; else + if (strclass == std::string("Caja")) retval.type = SetBG::CAJA; else if (strclass == std::string("Nemo")) retval.type = SetBG::NEMO; else if (strclass == std::string("Pcmanfm")) retval.type = SetBG::PCMANFM; else if (strclass == std::string("Conky") || strclass == std::string("conky")) @@ -1367,6 +1371,51 @@ bool SetBGNemo::save_to_config() return false; } +/* + * ************************************************************************** + * SetBGCaja + * ************************************************************************** + */ + +/** + * Returns the schema key to be used for setting background settings. + * + * Can be overridden. + */ +Glib::ustring SetBGCaja::get_gsettings_key() +{ + return Glib::ustring("org.mate.background"); +} + +/** + * Sets the bg if caja is appearing to draw the desktop image. + */ +bool SetBGCaja::set_bg(Glib::ustring &disp, Glib::ustring file, SetMode mode, Gdk::Color bgcolor) +{ + Glib::ustring strmode; + switch(mode) { + case SetBG::SET_SCALE: strmode = "stretched"; break; + case SetBG::SET_TILE: strmode = "wallpaper"; break; + case SetBG::SET_CENTER: strmode = "centered"; break; + case SetBG::SET_ZOOM: strmode = "scaled"; break; + case SetBG::SET_ZOOM_FILL: strmode = "spanned"; break; + default: strmode = "zoom"; break; + }; + + Glib::RefPtr settings = Gio::Settings::create(get_gsettings_key()); + + Glib::RefPtr iofile = Gio::File::create_for_commandline_arg(file); + + settings->set_string("picture-filename", iofile->get_path()); + settings->set_string("picture-options", strmode); + settings->set_string("primary-color", bgcolor.to_string()); + settings->set_string("secondary-color", bgcolor.to_string()); + + set_show_desktop(); + + return true; +} + /* * ************************************************************************** * SetBGPcmanfm diff --git a/src/SetBG.h b/src/SetBG.h index 1f57d63..28e1ab2 100644 --- a/src/SetBG.h +++ b/src/SetBG.h @@ -58,6 +58,7 @@ class SetBG { XINERAMA, NEMO, PCMANFM, + CAJA, IGNORE // Conky, etc }; @@ -184,6 +185,16 @@ class SetBGNemo : public SetBGGnome { virtual void set_show_desktop(); }; +class SetBGCaja : public SetBGGnome { + public: + virtual bool set_bg(Glib::ustring &disp, + Glib::ustring file, + SetMode mode, + Gdk::Color bgcolor); + protected: + virtual Glib::ustring get_gsettings_key(); +}; + class SetBGPcmanfm : public SetBGGnome { public: virtual Glib::ustring get_fullscreen_key();