static void lightdash_read (LightdashPlugin *lightdash)
{
    XfceRc *rc;
    gchar *file;
    const gchar *value;

    file = xfce_panel_plugin_save_location (lightdash->plugin, TRUE);

    if (G_LIKELY (file != NULL))
    {
        rc = xfce_rc_simple_open (file, TRUE);

        g_free (file);

        if (G_LIKELY (rc != NULL))
        {
            value = xfce_rc_read_entry (rc, "button-title", g_strdup (BUTTON_TITLE_DEFAULT));
            lightdash->button_title = g_strdup (value);
            lightdash->opacity = xfce_rc_read_int_entry (rc, "opacity", DEFAULT_OPACITY);
            lightdash->show_desktop = xfce_rc_read_int_entry (rc, "show-desktop", DEFAULT_SHOW_DESKTOP);

            xfce_rc_close (rc);

            return;
        }

    }

    lightdash->button_title = g_strdup (BUTTON_TITLE_DEFAULT);
    lightdash->opacity = DEFAULT_OPACITY;
}
void Plugin::debug_log(const Glib::ustring &msg)
{
  /* When Plugin stream reference goes out of scope, it will be automatically
   * flushed and closed etc */
  if (!debug_log_stream)
  {
      /* Work out a suitable log path in the same directory as the writeable
       * configuration path for this instance of the plugin - 'create_for_path'
       * doesn't actually create anything, but just instantiates the virtual
       * File object */
      gchar* file_path = xfce_panel_plugin_save_location(xfce_plugin, FALSE);
      Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(file_path)
              ->get_parent()
              ->get_child(
                  String::ucompose("%1-debug.log",
                                   xfce_panel_plugin_get_unique_id(xfce_plugin)));
      g_free(file_path);
      debug_log_stream = file->append_to();

      // Debug code
      std::cerr << "XFCE4 Hardware Monitor Plugin: Debug log file created at "
                << file->get_path() << std::endl;
  }

  debug_log_stream->write(String::ucompose("%1\n", msg));
  std::cerr << msg << "\n";
}
Esempio n. 3
0
t_quicklauncher *
quicklauncher_new (XfcePanelPlugin *plugin)
{
	t_quicklauncher *quicklauncher;
	gchar *filename;
	
	DBG ("create quicklauncher");
	quicklauncher = g_new0(t_quicklauncher, 1);
	filename = xfce_panel_plugin_save_location(plugin, TRUE);
	quicklauncher->icon_size = (gint) (0.75 * xfce_panel_plugin_get_size(plugin)/2);
	DBG ("icon size: %d", quicklauncher->icon_size);
	if((!filename) || (!quicklauncher_load_config(quicklauncher, filename) ) )
		quicklauncher_load_default(quicklauncher);

	quicklauncher->orientation = xfce_panel_plugin_get_orientation(plugin);
	quicklauncher->plugin = plugin;
	quicklauncher->table = g_object_ref(gtk_table_new(2, 2, TRUE));
	gtk_table_set_col_spacings(GTK_TABLE(quicklauncher->table), 0);
	gtk_container_add( GTK_CONTAINER(quicklauncher->plugin), quicklauncher->table);
	xfce_panel_plugin_add_action_widget(quicklauncher->plugin, quicklauncher->table);
	gtk_widget_show(quicklauncher->table);

	quicklauncher_organize(quicklauncher);
	return quicklauncher;
}
void
xfce_xkb_save_config (XfcePanelPlugin *plugin, t_xkb *xkb)
{
    gchar* filename;
    XfceRc* rcfile;


    filename = xfce_panel_plugin_save_location (plugin, TRUE);
    if (!filename)
        return;


    rcfile = xfce_rc_simple_open (filename, FALSE);
    if (!rcfile)
    {
        g_free (filename);
        return;
    }

    xfce_rc_set_group (rcfile, NULL);

    xfce_rc_write_int_entry (rcfile, "display_type", xkb->display_type);
    xfce_rc_write_int_entry (rcfile, "display_textscale", xkb->display_text_scale);
    xfce_rc_write_int_entry (rcfile, "display_imgscale", xkb->display_img_scale);
    xfce_rc_write_int_entry (rcfile, "group_policy", xkb->group_policy);

    xfce_rc_close (rcfile);
    g_free (filename);
}
/* Function declared here as its a callback for a C signal, so cant be a
 * method */
void save_monitors(Plugin *plugin)
{
  // Getting at plugin objects
  XfcePanelPlugin *xfce_plugin = plugin->xfce_plugin;

  // Search for a writeable settings file, create one if it doesnt exist
  gchar* file = xfce_panel_plugin_save_location(xfce_plugin, true);

  if (file)
  {
    // Opening setting file
    XfceRc* settings_w = xfce_rc_simple_open(file, false);
    g_free(file);

    // Looping for all monitors and calling save on each
    for (monitor_iter i = plugin->monitors.begin(),
         end = plugin->monitors.end(); i != end; ++i)
      (*i)->save(settings_w);

    // Close settings file
    xfce_rc_close(settings_w);
  }
  else
  {
    // Unable to obtain writeable config file - informing user and exiting
    std::cerr << _("Unable to obtain writeable config file path in order to"
      " save monitors!\n");
  }
}
Esempio n. 6
0
void
sample_save (XfcePanelPlugin *plugin,
             SamplePlugin    *sample)
{
  XfceRc *rc;
  gchar  *file;

  /* get the config file location */
  file = xfce_panel_plugin_save_location (plugin, TRUE);

  if (G_UNLIKELY (file == NULL))
    {
       DBG ("Failed to open config file");
       return;
    }

  /* open the config file, read/write */
  rc = xfce_rc_simple_open (file, FALSE);
  g_free (file);

  if (G_LIKELY (rc != NULL))
    {
      /* save the settings */
      DBG(".");
      if (sample->setting1)
        xfce_rc_write_entry    (rc, "setting1", sample->setting1);

      xfce_rc_write_int_entry  (rc, "setting2", sample->setting2);
      xfce_rc_write_bool_entry (rc, "setting3", sample->setting3);

      /* close the rc file */
      xfce_rc_close (rc);
    }
}
void lightdash_save (XfcePanelPlugin *plugin, LightdashPlugin *lightdash)
{
    XfceRc *rc;
    gchar *file;

    file = xfce_panel_plugin_save_location (plugin, TRUE);

    if (G_UNLIKELY (file == NULL))
    {
        return;
    }

    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);

    if (G_LIKELY (rc != NULL))
    {
        if (lightdash->button_title)
        {
            xfce_rc_write_entry (rc, "button-title", lightdash->button_title);
        }

        xfce_rc_write_int_entry (rc, "opacity", lightdash->opacity);
        xfce_rc_write_bool_entry (rc, "show-desktop", lightdash->show_desktop);


        xfce_rc_close (rc);

    }
}
Esempio n. 8
0
void quicklauncher_save(XfcePanelPlugin *plugin, t_quicklauncher *quicklauncher)
{
	gchar *filename;
	filename = xfce_panel_plugin_save_location(plugin, TRUE);
	if(filename)
	{
		quicklauncher_save_config(quicklauncher, filename);
		g_free(filename);
	}
}
Esempio n. 9
0
static void
wckbuttons_read (WBPlugin *wb)
{
    XfceRc      *rc;
    gchar       *file;
    const gchar *button_layout, *theme;

    /* allocate memory for the preferences structure */
    wb->prefs = g_slice_new0(WBPreferences);

    /* get the plugin config file location */
    file = xfce_panel_plugin_save_location (wb->plugin, TRUE);

    if (G_LIKELY (file != NULL))
    {
        /* open the config file, readonly */
        rc = xfce_rc_simple_open (file, TRUE);

        /* cleanup */
        g_free (file);

        if (G_LIKELY (rc != NULL))
        {
            /* read the settings */
            wb->prefs->only_maximized = xfce_rc_read_bool_entry(rc, "only_maximized", DEFAULT_ONLY_MAXIMIZED);
            wb->prefs->show_on_desktop = xfce_rc_read_bool_entry(rc, "show_on_desktop", DEFAULT_SHOW_ON_DESKTOP);
            wb->prefs->sync_wm_theme = xfce_rc_read_bool_entry(rc, "sync_wm_theme", DEFAULT_SYNC_WM_THEME);
            button_layout = xfce_rc_read_entry (rc, "button_layout", DEFAULT_BUTTON_LAYOUT);
            wb->prefs->button_layout = button_layout_filter (button_layout, DEFAULT_BUTTON_LAYOUT);
            theme = xfce_rc_read_entry (rc, "theme", DEFAULT_THEME);
            wb->prefs->theme = g_strdup (theme);

            wb->prefs->inactive_text_alpha = xfce_rc_read_int_entry (rc, "inactive_text_alpha", DEFAULT_INACTIVE_TEXT_ALPHA);
            wb->prefs->inactive_text_shade = xfce_rc_read_int_entry (rc, "inactive_text_shade", DEFAULT_INACTIVE_TEXT_SHADE);

            /* cleanup */
            xfce_rc_close (rc);

            /* leave the function, everything went well */
            return;
        }
    }

    /* something went wrong, apply default values */
    DBG ("Applying default settings");

    wb->prefs->only_maximized = DEFAULT_ONLY_MAXIMIZED;
    wb->prefs->show_on_desktop = DEFAULT_SHOW_ON_DESKTOP;
    wb->prefs->sync_wm_theme = DEFAULT_SYNC_WM_THEME;
    wb->prefs->button_layout = DEFAULT_BUTTON_LAYOUT;
    wb->prefs->theme = DEFAULT_THEME;
    wb->prefs->inactive_text_alpha = DEFAULT_INACTIVE_TEXT_ALPHA;
    wb->prefs->inactive_text_shade = DEFAULT_INACTIVE_TEXT_SHADE;
}
Esempio n. 10
0
static void macmenu_write_rc(MacMenu* mmb)
{
  char* file;
  if (!(file = xfce_panel_plugin_save_location(mmb->applet, TRUE))) return;
  unlink(file);
  XfceRc* rc = xfce_rc_simple_open(file, FALSE);
  g_free(file);
  if (!rc) return;

  xfce_rc_write_bool_entry(rc, "HideLabel", mmb->hide_label);

  xfce_rc_close (rc);
}
Esempio n. 11
0
gpointer
multiload_ps_settings_open_for_save(MultiloadPlugin *ma)
{
	gchar *file;
	XfceRc *rc;

	file = xfce_panel_plugin_save_location((XfcePanelPlugin*)(ma->panel_data), TRUE);
	if (G_UNLIKELY(file == NULL))
		return NULL;

	rc = xfce_rc_simple_open (file, FALSE);
	g_free(file);

	return (gpointer)rc;
}
Esempio n. 12
0
void windowck_save(XfcePanelPlugin *plugin, WindowckPlugin *wckp)
{
    XfceRc *rc;
    gchar *file;

    /* get the config file location */
    file = xfce_panel_plugin_save_location(plugin, TRUE);

    if (G_UNLIKELY (file == NULL))
    {
        DBG("Failed to open config file");
        return;
    }

    /* open the config file, read/write */
    rc = xfce_rc_simple_open(file, FALSE);
    g_free(file);

    if (G_LIKELY (rc != NULL))
    {
        /* save the settings */
        DBG(".");
        xfce_rc_write_bool_entry(rc, "only_maximized", wckp->prefs->only_maximized);
        xfce_rc_write_bool_entry(rc, "show_on_desktop", wckp->prefs->show_on_desktop);
        xfce_rc_write_bool_entry(rc, "show_icon", wckp->prefs->show_icon);
        xfce_rc_write_bool_entry(rc, "icon_on_right", wckp->prefs->icon_on_right);
        xfce_rc_write_bool_entry(rc, "show_window_menu", wckp->prefs->show_window_menu);
        xfce_rc_write_bool_entry(rc, "hide_title", wckp->prefs->hide_title);
        xfce_rc_write_bool_entry(rc, "full_name", wckp->prefs->full_name);
        xfce_rc_write_bool_entry(rc, "show_tooltips", wckp->prefs->show_tooltips);
        xfce_rc_write_int_entry(rc, "size_mode", wckp->prefs->size_mode);
        xfce_rc_write_int_entry(rc, "title_size", wckp->prefs->title_size);
        xfce_rc_write_bool_entry(rc, "custom_font", wckp->prefs->custom_font);
        if (wckp->prefs->title_font)
            xfce_rc_write_entry(rc, "title_font", wckp->prefs->title_font);

        xfce_rc_write_int_entry(rc, "title_alignment", wckp->prefs->title_alignment);
        xfce_rc_write_int_entry(rc, "title_padding", wckp->prefs->title_padding);

        /* close the rc file */
        xfce_rc_close(rc);
    }
}
void Plugin::replace_monitor(Monitor *prev_monitor, Monitor *new_monitor)
{
  // Locating monitor of interest
  monitor_iter i = std::find(monitors.begin(), monitors.end(), prev_monitor);
  assert(i != monitors.end());

  // Basic configuration
  //add_sync_for(new_mon);
  *i = new_monitor;
  new_monitor->set_settings_dir(prev_monitor->get_settings_dir());

  // Search for a writeable settings file, create one if it doesnt exist
  gchar* file = xfce_panel_plugin_save_location(xfce_plugin, true);
    
  if (file)
  {
    // Opening setting file
    XfceRc* settings_w = xfce_rc_simple_open(file, false);
    g_free(file);

    // Saving settings
    new_monitor->save(settings_w);
    
    // Close settings file
    xfce_rc_close(settings_w);
  }
  else
  {
    // Unable to obtain writeable config file - informing user
    std::cerr << _("Unable to obtain writeable config file path in "
      "order to save monitor settings in replace_monitor call!\n");
  }

  // Reattach monitor if its attached to the current view
  if (view.get()) {
    view->detach(prev_monitor);
    view->attach(new_monitor);
  }

  // Deleting previous monitor
  //remove_sync_for(prev_monitor);
  delete prev_monitor;
}
unsigned int Plugin::get_fg_color()
{
  static unsigned int colors[] = {
    0x83A67FB0, 0xC1665AB0, 0x7590AEB0, 0xE0C39ED0, 0x887FA3B0
  };

  /* Saving 'current' next color - note that this is an index into the colors,
   * not a color itself */
  int color = next_color;
  
  // Updating next_color
  next_color = int((next_color + 1) %
    (sizeof(colors) / sizeof(unsigned int)));
  
  // Search for a writeable settings file, create one if it doesnt exist
  gchar* file = xfce_panel_plugin_save_location(xfce_plugin, true);
    
  if (file)
  {
    // Opening setting file
    XfceRc* settings_w = xfce_rc_simple_open(file, false);
    g_free(file);

    // Ensuring default group is in focus
    xfce_rc_set_group(settings_w, NULL);

    // Saving next_color
    xfce_rc_write_int_entry(settings_w, "next_color", next_color);
    
    // Close settings file
    xfce_rc_close(settings_w);
  }
  else
  {
    // Unable to obtain writeable config file - informing user and exiting
    std::cerr << _("Unable to obtain writeable config file path in order to"
      " save next_color!\n");
  }

  // Returning actual next color
  return colors[color];
}
Esempio n. 15
0
static void
sample_read (SamplePlugin *sample)
{
  XfceRc      *rc;
  gchar       *file;
  const gchar *value;

  /* get the plugin config file location */
  file = xfce_panel_plugin_save_location (sample->plugin, TRUE);

  if (G_LIKELY (file != NULL))
    {
      /* open the config file, readonly */
      rc = xfce_rc_simple_open (file, TRUE);

      /* cleanup */
      g_free (file);

      if (G_LIKELY (rc != NULL))
        {
          /* read the settings */
          value = xfce_rc_read_entry (rc, "setting1", DEFAULT_SETTING1);
          sample->setting1 = g_strdup (value);

          sample->setting2 = xfce_rc_read_int_entry (rc, "setting2", DEFAULT_SETTING2);
          sample->setting3 = xfce_rc_read_bool_entry (rc, "setting3", DEFAULT_SETTING3);

          /* cleanup */
          xfce_rc_close (rc);

          /* leave the function, everything went well */
          return;
        }
    }

  /* something went wrong, apply default values */
  DBG ("Applying default settings");

  sample->setting1 = g_strdup (DEFAULT_SETTING1);
  sample->setting2 = DEFAULT_SETTING2;
  sample->setting3 = DEFAULT_SETTING3;
}
void
exitbutton_save(XfcePanelPlugin *plugin, ExitbuttonPlugin *exitbutton) {

  if (exo_str_is_empty(exitbutton->icon_name))
    {
      return;
    }

  // Update the icon
  xfce_panel_image_set_from_source(XFCE_PANEL_IMAGE(exitbutton->icon), exitbutton->icon_name);

  /********************************************************
   * Save the properties
   ********************************************************/
  XfceRc *rc;
  gchar *file;

  /* get the config file location */
  file = xfce_panel_plugin_save_location(plugin, TRUE);

  if (G_UNLIKELY (file == NULL))
    {
      DBG("Failed to open config file");
      return;
    }

  /* open the config file, read/write */
  rc = xfce_rc_simple_open(file, FALSE);
  g_free(file);

  if (G_LIKELY (rc != NULL))
    {
      /* save the settings */
      DBG(".");
      if (exitbutton->icon_name)
        xfce_rc_write_entry(rc, "icon_name", exitbutton->icon_name);

      /* close the rc file */
      xfce_rc_close(rc);
    }
}
Esempio n. 17
0
static void
eyes_write_rc_file (XfcePanelPlugin *plugin, t_eyes* eyes)
{
    char *file;
    XfceRc *rc;

    if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
        return;

    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);

    if (!rc)
        return;

    if (eyes->options.theme != NULL) {
        xfce_rc_write_entry (rc, "theme", eyes->options.theme);
    }

    xfce_rc_close (rc);
}
Esempio n. 18
0
void
wckbuttons_save (XfcePanelPlugin *plugin,
             WBPlugin    *wb)
{
    XfceRc *rc;
    gchar  *file;

    /* get the config file location */
    file = xfce_panel_plugin_save_location (plugin, TRUE);

    if (G_UNLIKELY (file == NULL))
    {
       DBG ("Failed to open config file");
       return;
    }

    /* open the config file, read/write */
    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);

    if (G_LIKELY (rc != NULL))
    {
        /* save the settings */
        DBG(".");
        xfce_rc_write_bool_entry(rc, "only_maximized", wb->prefs->only_maximized);
        xfce_rc_write_bool_entry(rc, "show_on_desktop", wb->prefs->show_on_desktop);
        xfce_rc_write_bool_entry(rc, "sync_wm_theme", wb->prefs->sync_wm_theme);
        if (wb->prefs->button_layout)
            xfce_rc_write_entry (rc, "button_layout", wb->prefs->button_layout);

        if (wb->prefs->theme)
            xfce_rc_write_entry (rc, "theme", wb->prefs->theme);

        xfce_rc_write_int_entry  (rc, "inactive_text_alpha", wb->prefs->inactive_text_alpha);
        xfce_rc_write_int_entry  (rc, "inactive_text_shade", wb->prefs->inactive_text_shade);

        /* close the rc file */
        xfce_rc_close (rc);
    }
}
Esempio n. 19
0
static void
time_out_save_settings (TimeOutPlugin *time_out)
{
  XfceRc *rc;
  gchar  *filename;

  g_return_if_fail (time_out != NULL);

  /* Search for config file */
  filename = xfce_panel_plugin_save_location (time_out->plugin, TRUE);

  /* Only try to write to the file if it exists */
  if (G_LIKELY (filename != NULL))
    {
      /* Open file handle */
      rc = xfce_rc_simple_open (filename, FALSE);

      /* Check if the file could be opened */
      if (G_LIKELY (rc != NULL))
        {
          /* Write settings */
          xfce_rc_write_int_entry (rc, "break-countdown-seconds", time_out->break_countdown_seconds);
          xfce_rc_write_int_entry (rc, "lock-countdown-seconds", time_out->lock_countdown_seconds);
          xfce_rc_write_int_entry (rc, "postpone-countdown-seconds", time_out->postpone_countdown_seconds);
          xfce_rc_write_bool_entry (rc, "enabled", time_out->enabled);
          xfce_rc_write_bool_entry (rc, "display-seconds", time_out->display_seconds);
          xfce_rc_write_bool_entry (rc, "display-hours", time_out->display_hours);
          xfce_rc_write_bool_entry (rc, "display-time", time_out->display_time);
          xfce_rc_write_bool_entry (rc, "display-icon", time_out->display_icon);
          xfce_rc_write_bool_entry (rc, "allow-postpone", time_out->allow_postpone);
          xfce_rc_write_bool_entry (rc, "auto-resume", time_out->auto_resume);

          /* Close file handle */
          xfce_rc_close (rc);
        }

      /* Free filename */
      g_free (filename);
    }
}
void Plugin::add_monitor(Monitor *monitor)
{
  //add_sync_for(monitor);
  monitors.push_back(monitor);

  /* Checking if monitor has a defined settings directory and therefore
   * settings to load */
  if (monitor->get_settings_dir().empty())
  {
    // It hasn't - creating one and saving
    monitor->set_settings_dir(find_empty_monitor_dir());

    // Search for a writeable settings file, create one if it doesnt exist
    gchar* file = xfce_panel_plugin_save_location(xfce_plugin, true);
      
    if (file)
    {
      // Opening setting file
      XfceRc* settings_w = xfce_rc_simple_open(file, false);
      g_free(file);

      // Saving monitor
      monitor->save(settings_w);

      // Close settings file
      xfce_rc_close(settings_w);
    }
    else
    {
      // Unable to obtain writeable config file - informing user
      std::cerr << _("Unable to obtain writeable config file path in "
        "order to save monitor in add_monitor call!\n");
    }
  }

  // Attaching monitor to view
  if (view.get())
    view->attach(monitor);
}
static void
screenshot_write_rc_file (XfcePanelPlugin *plugin, ScreenshotData *screenshot)
{
    char *file;
    XfceRc *rc;
    
    if (!(file = xfce_panel_plugin_save_location (plugin, TRUE)))
        return;

    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);

    if (!rc)
        return;
    
    xfce_rc_write_int_entry (rc, "screenshot_delay", screenshot->screenshot_delay);
    xfce_rc_write_int_entry (rc, "window_delay", screenshot->window_delay);
    xfce_rc_write_int_entry (rc, "whole_screen", screenshot->whole_screen);
    xfce_rc_write_int_entry (rc, "ask_for_file", screenshot->ask_for_file);

    xfce_rc_close (rc);
}
Esempio n. 22
0
static gboolean
xfapplet_save_configuration (XfAppletPlugin *xap)
{
	XfceRc         *config;
	gchar          *path;

	if (!xap->configured)
		return FALSE;

	path = xfce_panel_plugin_lookup_rc_file (xap->plugin);
	if (!path)
		path = xfce_panel_plugin_save_location (xap->plugin, TRUE);

	if (!path)
		return FALSE;

        config = xfce_rc_simple_open (path, FALSE);
	g_free (path);

	if (!config)
		return FALSE;

	xfce_rc_set_group (config, "xfapplet");

	/* iid for matecomponent control */
	xfce_rc_write_entry (config, "iid", xap->iid);

	/* applet name (used in dialog messages) */
	xfce_rc_write_entry (config, "name", xap->name);

	/* mateconf key for applet preferences */
	xfce_rc_write_entry (config, "mateconfkey", xap->mateconf_key);

	xfce_rc_close (config);

	return TRUE;
}
static void
exitbutton_read(ExitbuttonPlugin *exitbutton)
{
  XfceRc *rc;
  gchar *file;
  const gchar *value;

  /* get the plugin config file location */
  file = xfce_panel_plugin_save_location(exitbutton->plugin, TRUE);

  if (G_LIKELY (file != NULL))
    {
      /* open the config file, readonly */
      rc = xfce_rc_simple_open(file, TRUE);

      /* cleanup */
      g_free(file);

      if (G_LIKELY (rc != NULL))
        {
          /* read the settings */
          value = xfce_rc_read_entry(rc, "icon_name", DEFAULT_ICON_NAME);
          exitbutton->icon_name = g_strdup(value);

          /* cleanup */
          xfce_rc_close(rc);

          /* leave the function, everything went well */
          return;
        }
    }

  /* something went wrong, apply default values */
  DBG("Applying default settings");

  exitbutton->icon_name = g_strdup(DEFAULT_ICON_NAME);
}
void Plugin::remove_monitor(Monitor *monitor)
{
  // Detatching monitor
  if (view.get())
    view->detach(monitor);

  // Search for a writeable settings file, create one if it doesnt exist
  gchar* file = xfce_panel_plugin_save_location(xfce_plugin, true);
    
  if (file)
  {
    // Opening setting file
    XfceRc* settings_w = xfce_rc_simple_open(file, false);
    g_free(file);

    // Removing settings group associated with the monitor if it exists
    if (xfce_rc_has_group(settings_w, monitor->get_settings_dir().c_str()))
      xfce_rc_delete_group(settings_w, monitor->get_settings_dir().c_str(),
        FALSE);

    // Close settings file
    xfce_rc_close(settings_w);
  }
  else
  {
    // Unable to obtain writeable config file - informing user
    std::cerr << _("Unable to obtain writeable config file path in "
      "order to remove a monitor!\n");
  }

  // Everyone has been notified, it's now safe to remove and delete
  // the monitor
  monitors.remove(monitor);
  //remove_sync_for(monitor);
  
  delete monitor;
}
Esempio n. 25
0
static void windowck_read(WindowckPlugin *wckp)
{
    XfceRc *rc;
    gchar *file;
    const gchar *title_font;

    /* allocate memory for the preferences structure */
    wckp->prefs = g_slice_new0(WCKPreferences);

    /* get the plugin config file location */
    file = xfce_panel_plugin_save_location(wckp->plugin, TRUE);

    if (G_LIKELY (file != NULL))
    {
        /* open the config file, readonly */
        rc = xfce_rc_simple_open(file, TRUE);

        /* cleanup */
        g_free(file);

        if (G_LIKELY (rc != NULL))
        {
            /* read the settings */
            wckp->prefs->only_maximized = xfce_rc_read_bool_entry(rc, "only_maximized", DEFAULT_ONLY_MAXIMIZED);
            wckp->prefs->show_on_desktop = xfce_rc_read_bool_entry(rc, "show_on_desktop", DEFAULT_SHOW_ON_DESKTOP);
            wckp->prefs->show_icon = xfce_rc_read_bool_entry(rc, "show_icon", DEFAULT_SHOW_ICON);
            wckp->prefs->icon_on_right = xfce_rc_read_bool_entry(rc, "icon_on_right", DEFAULT_ICON_ON_RIGHT);
            wckp->prefs->show_window_menu = xfce_rc_read_bool_entry(rc, "show_window_menu", DEFAULT_SHOW_WINDOW_MENU);
            wckp->prefs->hide_title = xfce_rc_read_bool_entry(rc, "hide_title", DEFAULT_HIDE_TITLE);
            wckp->prefs->full_name = xfce_rc_read_bool_entry(rc, "full_name", DEFAULT_FULL_NAME);
            wckp->prefs->show_tooltips = xfce_rc_read_bool_entry(rc, "show_tooltips", DEFAULT_SHOW_TOOLTIPS);
            wckp->prefs->size_mode = xfce_rc_read_int_entry (rc, "size_mode", DEFAULT_SIZE_MODE);
            wckp->prefs->title_size = xfce_rc_read_int_entry(rc, "title_size", DEFAULT_TITLE_SIZE);
            wckp->prefs->custom_font = xfce_rc_read_bool_entry(rc, "custom_font", DEFAULT_CUSTOM_FONT);
            title_font = xfce_rc_read_entry(rc, "title_font", DEFAULT_TITLE_FONT);
            wckp->prefs->title_font = g_strdup(title_font);
            wckp->prefs->title_alignment = xfce_rc_read_int_entry(rc, "title_alignment", DEFAULT_TITLE_ALIGNMENT);
            wckp->prefs->title_padding = xfce_rc_read_int_entry(rc, "title_padding", DEFAULT_TITLE_PADDING);

            /* cleanup */
            xfce_rc_close(rc);

            /* leave the function, everything went well */
            return;
        }
    }

    /* something went wrong, apply default values */
    DBG("Applying default settings");

    wckp->prefs->only_maximized = DEFAULT_ONLY_MAXIMIZED;
    wckp->prefs->show_on_desktop = DEFAULT_SHOW_ON_DESKTOP;
    wckp->prefs->show_icon = DEFAULT_SHOW_ICON;
    wckp->prefs->icon_on_right = DEFAULT_ICON_ON_RIGHT;
    wckp->prefs->show_window_menu = DEFAULT_SHOW_WINDOW_MENU;
    wckp->prefs->hide_title = DEFAULT_HIDE_TITLE;
    wckp->prefs->full_name = DEFAULT_FULL_NAME;
    wckp->prefs->show_tooltips = DEFAULT_SHOW_TOOLTIPS;
    wckp->prefs->size_mode = DEFAULT_SIZE_MODE;
    wckp->prefs->title_size = DEFAULT_TITLE_SIZE;
    wckp->prefs->custom_font = DEFAULT_CUSTOM_FONT;
    wckp->prefs->title_font = DEFAULT_TITLE_FONT;
    wckp->prefs->title_alignment = DEFAULT_TITLE_ALIGNMENT;
    wckp->prefs->title_padding = DEFAULT_TITLE_PADDING;
}
Esempio n. 26
0
static void
time_out_load_settings (TimeOutPlugin *time_out)
{
  XfceRc  *rc;
  gchar   *filename;

  /* Default settings */
  gint     break_countdown_seconds = DEFAULT_BREAK_COUNTDOWN_SECONDS;
  gint     lock_countdown_seconds = DEFAULT_LOCK_COUNTDOWN_SECONDS;
  gint     postpone_countdown_seconds = DEFAULT_POSTPONE_COUNTDOWN_SECONDS;
  gboolean enabled = DEFAULT_ENABLED;
  gboolean display_seconds = DEFAULT_DISPLAY_SECONDS;
  gboolean display_hours = DEFAULT_DISPLAY_HOURS;
  gboolean display_time = DEFAULT_DISPLAY_TIME;
  gboolean display_icon = DEFAULT_DISPLAY_ICON;
  gboolean allow_postpone = DEFAULT_ALLOW_POSTPONE;
  gboolean auto_resume = DEFAULT_AUTO_RESUME;;

  g_return_if_fail (time_out != NULL);

  /* Search for the config file */
  filename = xfce_panel_plugin_save_location (time_out->plugin, FALSE);

  /* Only try to read the file if it exists */
  if (G_LIKELY (filename != NULL))
    {
      /* Open file handle */
      rc = xfce_rc_simple_open (filename, TRUE);

      /* Check if the file could be opened */
      if (G_LIKELY (rc != NULL))
        {
          /* Read settings */
          break_countdown_seconds = xfce_rc_read_int_entry (rc, "break-countdown-seconds", break_countdown_seconds);
          lock_countdown_seconds = xfce_rc_read_int_entry (rc, "lock-countdown-seconds", lock_countdown_seconds);
          postpone_countdown_seconds = xfce_rc_read_int_entry (rc, "postpone-countdown-seconds", postpone_countdown_seconds);
          enabled = xfce_rc_read_bool_entry (rc, "enabled", enabled);
          display_seconds = xfce_rc_read_bool_entry (rc, "display-seconds", display_seconds);
          display_hours = xfce_rc_read_bool_entry (rc, "display-hours", display_hours);
          display_time = xfce_rc_read_bool_entry (rc, "display-time", display_time);
          display_icon = xfce_rc_read_bool_entry (rc, "display-icon", display_icon);
          allow_postpone = xfce_rc_read_bool_entry (rc, "allow-postpone", allow_postpone);
          auto_resume = xfce_rc_read_bool_entry (rc, "auto-resume", auto_resume);

          /* Close file handle */
          xfce_rc_close (rc);
        }

      /* Free filename */
      g_free (filename);
    }

  /* Apply settings */
  time_out->break_countdown_seconds = break_countdown_seconds;
  time_out->lock_countdown_seconds = lock_countdown_seconds;
  time_out->postpone_countdown_seconds = postpone_countdown_seconds;
  time_out->enabled = enabled;
  time_out->display_seconds = display_seconds;
  time_out->display_hours = display_hours;
  time_out->display_time = display_time;
  time_out->display_icon = display_icon;
  time_out->allow_postpone = allow_postpone;
  time_out->auto_resume = auto_resume;
}