Skip to content

Commit

Permalink
Add Nemo/Cinnamon desktop support (untested), updates #52
Browse files Browse the repository at this point in the history
  • Loading branch information
daf committed Mar 21, 2015
1 parent de647b9 commit 5de5020
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
57 changes: 55 additions & 2 deletions src/SetBG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ SetBG* SetBG::get_bg_setter()
case SetBG::NAUTILUS:
setter = new SetBGGnome();
break;
case SetBG::NEMO:
setter = new SetBGNemo();
break;
#ifdef USE_XINERAMA
case SetBG::XINERAMA:
XineramaScreenInfo *xinerama_info;
Expand Down Expand Up @@ -195,6 +198,7 @@ SetBG::RootWindowType SetBG::get_rootwindowtype(Glib::RefPtr<Gdk::Display> displ
std::string strclass = std::string(list[1]);
if (strclass == std::string("Xfdesktop")) retval = SetBG::XFCE; else
if (strclass == std::string("Nautilus")) retval = SetBG::NAUTILUS; else
if (strclass == std::string("Nemo")) retval = SetBG::NEMO; else
{
std::cerr << _("UNKNOWN ROOT WINDOW TYPE DETECTED, will attempt to set via normal X procedure") << "\n";
retval = SetBG::UNKNOWN;
Expand Down Expand Up @@ -1127,15 +1131,16 @@ bool SetBGGnome::set_bg(Glib::ustring &disp, Glib::ustring file, SetMode mode, G
default: strmode = "zoom"; break;
};

Glib::RefPtr<Gio::Settings> settings = Gio::Settings::create("org.gnome.desktop.background");
Glib::RefPtr<Gio::Settings> settings = Gio::Settings::create(get_gsettings_key());

Glib::RefPtr<Gio::File> iofile = Gio::File::create_for_commandline_arg(file);

settings->set_string("picture-uri", iofile->get_uri());
settings->set_string("picture-options", strmode);
settings->set_string("primary-color", bgcolor.to_string());
settings->set_string("secondary-color", bgcolor.to_string());
settings->set_boolean("draw-background", true);

set_show_desktop();

return true;
}
Expand Down Expand Up @@ -1172,3 +1177,51 @@ Glib::ustring SetBGGnome::make_display_key(gint head)
return Glib::ustring("");
}

/**
* Returns the schema key to be used for setting background settings.
*
* Can be overridden.
*/
Glib::ustring SetBGGnome::get_gsettings_key()
{
return Glib::ustring("org.gnome.desktop.background");
}

/**
* Sets the show_desktop flag in the appropriate spot.
*
* This varies depending on actual software used, so needs to be own function
* to be overridden.
*/
void SetBGGnome::set_show_desktop()
{
Glib::RefPtr<Gio::Settings> settings = Gio::Settings::create(get_gsettings_key());
settings->set_boolean("draw-background", true);
}

/*
* **************************************************************************
* SetBGNemo
* **************************************************************************
*/
/**
* Returns the schema key to be used for setting background settings.
*
* Can be overridden.
*/
Glib::ustring SetBGNemo::get_gsettings_key()
{
return Glib::ustring("org.cinnamon.desktop.background");
}

/**
* Sets the show_desktop flag in the appropriate spot.
*
* This varies depending on actual software used, so needs to be own function
* to be overridden.
*/
void SetBGNemo::set_show_desktop()
{
Glib::RefPtr<Gio::Settings> settings = Gio::Settings::create(Glib::ustring("org.nemo.desktop"));
settings->set_boolean("draw-background", true);
}
9 changes: 9 additions & 0 deletions src/SetBG.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class SetBG {
XFCE,
UNKNOWN,
XINERAMA,
NEMO,
};

virtual bool set_bg(Glib::ustring &disp,
Expand Down Expand Up @@ -155,6 +156,14 @@ class SetBGGnome : public SetBG {
protected:
virtual Glib::ustring get_prefix();
virtual Glib::ustring make_display_key(gint head);
virtual Glib::ustring get_gsettings_key();
virtual void set_show_desktop();
};

class SetBGNemo : public SetBGGnome {
protected:
virtual Glib::ustring get_gsettings_key();
virtual void set_show_desktop();
};

#endif

0 comments on commit 5de5020

Please sign in to comment.