Back to index

unity  6.0.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
unity::DevicesSettings Class Reference

#include <DevicesSettings.h>

Inheritance diagram for unity::DevicesSettings:
Inheritance graph
[legend]
Collaboration diagram for unity::DevicesSettings:
Collaboration graph
[legend]

List of all members.

Public Types

enum  DevicesOption { NEVER = 0, ONLY_MOUNTED, ALWAYS }

Public Member Functions

 DevicesSettings ()
void SetDevicesOption (DevicesOption devices_option)
DevicesOption GetDevicesOption ()
DeviceList const & GetFavorites ()
void AddFavorite (std::string const &uuid)
void RemoveFavorite (std::string const &uuid)
void Changed (std::string const &key)

Static Public Member Functions

static DevicesSettingsGetDefault ()

Public Attributes

sigc::signal< void > changed

Private Member Functions

void Refresh ()
void SaveFavorites (DeviceList const &favorites)

Private Attributes

glib::Object< GSettings > settings_
DeviceList favorites_
bool ignore_signals_
DevicesOption devices_option_

Detailed Description

Definition at line 35 of file DevicesSettings.h.


Member Enumeration Documentation

Enumerator:
NEVER 
ONLY_MOUNTED 
ALWAYS 

Definition at line 38 of file DevicesSettings.h.


Constructor & Destructor Documentation

Definition at line 42 of file DevicesSettings.cpp.

  : settings_(g_settings_new(SETTINGS_NAME))
  , ignore_signals_(false)
  , devices_option_(ONLY_MOUNTED)
{

  g_signal_connect(settings_, "changed", G_CALLBACK(on_settings_updated), this);

  Refresh();
}

Here is the call graph for this function:


Member Function Documentation

void unity::DevicesSettings::AddFavorite ( std::string const &  uuid)

Definition at line 65 of file DevicesSettings.cpp.

{
  if (uuid.empty())
    return;
  
  favorites_.push_back(uuid);

  SaveFavorites(favorites_);
  Refresh();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::DevicesSettings::Changed ( std::string const &  key)

Definition at line 110 of file DevicesSettings.cpp.

{
  if (ignore_signals_)
    return;
  
  Refresh();
  
  changed.emit();
}

Here is the call graph for this function:

Definition at line 36 of file DevicesSettings.cpp.

{
  static DevicesSettings instance;
  return instance;
}

Here is the caller graph for this function:

Definition at line 51 of file DevicesSettings.h.

{ return devices_option_; };

Definition at line 53 of file DevicesSettings.h.

{ return favorites_; };

Here is the caller graph for this function:

void unity::DevicesSettings::Refresh ( ) [private]

Definition at line 53 of file DevicesSettings.cpp.

{
  gchar** favs = g_settings_get_strv(settings_, "favorites");

  favorites_.clear();

  for (int i = 0; favs[i] != NULL; i++)
    favorites_.push_back(favs[i]);

  g_strfreev(favs);
}

Here is the caller graph for this function:

void unity::DevicesSettings::RemoveFavorite ( std::string const &  uuid)

Definition at line 76 of file DevicesSettings.cpp.

{
  if (uuid.empty())
    return;

  DeviceList::iterator pos = std::find(favorites_.begin(), favorites_.end(), uuid);
  if (pos == favorites_.end())
    return;

  favorites_.erase(pos);
  SaveFavorites(favorites_);
  Refresh();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::DevicesSettings::SaveFavorites ( DeviceList const &  favorites) [private]

Definition at line 90 of file DevicesSettings.cpp.

{
  const int size = favorites.size();
  const char* favs[size + 1];
  favs[size] = NULL;

  int index = 0;
  for (DeviceList::const_iterator i = favorites.begin(), end = favorites.end();
       i != end; ++i, ++index)
  {
    favs[index] = i->c_str();
  }

  ignore_signals_ = true;
  if (!g_settings_set_strv(settings_, "favorites", favs))
    g_warning("Saving favorites failed.");
  ignore_signals_ = false;
}

Here is the caller graph for this function:

Definition at line 120 of file DevicesSettings.cpp.

{
  if (devices_option == devices_option_)
    return;

  devices_option_ = devices_option;

  changed.emit();
}

Here is the caller graph for this function:


Member Data Documentation

sigc::signal<void> unity::DevicesSettings::changed

Definition at line 60 of file DevicesSettings.h.

Definition at line 69 of file DevicesSettings.h.

Definition at line 67 of file DevicesSettings.h.

Definition at line 68 of file DevicesSettings.h.

Definition at line 66 of file DevicesSettings.h.


The documentation for this class was generated from the following files: