Glib::ustring Plugin::find_empty_monitor_dir()
{
  Glib::ustring mon_dir;
  int c = 1;

  // Search for read-only settings file
  gchar* file = xfce_panel_plugin_lookup_rc_file(xfce_plugin);

  if (file)
  {
    // One exists - loading readonly settings
    XfceRc* settings_ro = xfce_rc_simple_open(file, true);
    g_free(file);

    do {
      mon_dir = String::ucompose("%1", c++);
    } while (xfce_rc_has_group(settings_ro, mon_dir.c_str()));
    
    // Close settings file
    xfce_rc_close(settings_ro);
  }
  else
  {
    /* No configuration file exists yet - setting mon_dir to 1 and
     * informing user */
    mon_dir = String::ucompose("%1", c);
  }  

  // Returning next free monitor directory (number)
  return mon_dir;
}
Ejemplo n.º 2
0
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");
  }
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
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);

    }
}
static void
screenshot_read_rc_file (XfcePanelPlugin *plugin, ScreenshotData *screenshot)
{
    char *file;
    XfceRc *rc;
    gint screenshot_delay = 2;
    gint window_delay = 2;
    gint whole_screen = 1;
    gint ask_for_file = 1;
    
    if ((file = xfce_panel_plugin_lookup_rc_file (plugin)) != NULL)
    {
        rc = xfce_rc_simple_open (file, TRUE);
        g_free (file);

        if (rc != NULL)
        {
            screenshot_delay = xfce_rc_read_int_entry (rc, "screenshot_delay", 2);
            window_delay = xfce_rc_read_int_entry (rc, "window_delay", 2);
            whole_screen = xfce_rc_read_int_entry (rc, "whole_screen", 1);
            ask_for_file = xfce_rc_read_int_entry (rc, "ask_for_file", 1);
            
            xfce_rc_close (rc);
        }
    }

    screenshot->screenshot_delay = screenshot_delay;
    screenshot->window_delay = window_delay;
    screenshot->whole_screen = whole_screen;
    screenshot->ask_for_file = ask_for_file;
}
Ejemplo n.º 7
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);
    }
}
Ejemplo n.º 8
0
static gboolean
xfapplet_read_configuration (XfAppletPlugin *xap)
{
	XfceRc		*config;
	gchar		*path;
	const gchar	*iid;
	const gchar	*name;
	const gchar	*mateconf_key;

	path = xfce_panel_plugin_lookup_rc_file (xap->plugin);
	if (!path)
		return FALSE;

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

	if (!config)
		return FALSE;

	xfce_rc_set_group (config, "xfapplet");

	/* iid for matecomponent control */
	iid = xfce_rc_read_entry (config, "iid", NULL);

	/* applet name (used in dialog messages) */
	name = xfce_rc_read_entry (config, "name", NULL);

	/* mateconf key for applet preferences */
	mateconf_key = xfce_rc_read_entry (config, "mateconfkey", NULL);

	if (!iid || !mateconf_key || !name) {
		xfce_rc_close (config);
		return FALSE;
	}
	
	xap->iid = g_strdup (iid);
	xap->name = g_strdup (name);
	xap->mateconf_key = g_strdup (mateconf_key);

	xfce_rc_close (config);

	return TRUE;
}
Ejemplo 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;
}
Ejemplo n.º 10
0
static void macmenu_load_from_rc(MacMenu* mmb)
{
  char* file;
  if (!(file = xfce_panel_plugin_lookup_rc_file(mmb->applet))) return;
  XfceRc* rc = xfce_rc_simple_open(file, TRUE);
  g_free(file);
  if (!rc) return;

  mmb->hide_label = xfce_rc_read_bool_entry(rc, "HideLabel", FALSE);

  xfce_rc_close (rc);
}
Ejemplo n.º 11
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);
}
Ejemplo n.º 12
0
static void
write_entry_bool (const gchar *entry, gboolean value)
{
    gchar *file;
    XfceRc *rc;
    
    file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, RESOURCE_FILE, TRUE);
    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);
    
    xfce_rc_write_bool_entry (rc, entry, value);
    xfce_rc_close (rc);
}
Ejemplo n.º 13
0
static void
xfce_dialog_show_help_auto_toggled (GtkWidget *button)
{
  XfceRc   *rc;
  gboolean  active = FALSE;

  if (button != NULL)
    active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));

  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "xfce4/help.rc", FALSE);
  if (rc != NULL)
    {
      xfce_rc_write_bool_entry (rc, "auto-online", active);
      xfce_rc_close (rc);
    }
}
Ejemplo n.º 14
0
/**
 * xfae_model_get:
 * @model       : a #XfaeModel.
 * @name        : the user visible name of the new item.
 * @description : the description for the new item.
 * @command     : the command for the new item.
 * @error       : return locations for errors or %NULL.
 *
 * Attempts to add a new item with the given parameters
 * to @model.
 *
 * Return value: %TRUE if successfull, else %FALSE.
 **/
gboolean
xfae_model_get (XfaeModel    *model,
                GtkTreeIter  *iter,
                gchar       **name,
                gchar       **description,
                gchar       **command,
                GError      **error)
{
  XfaeItem    *item;
  GList       *lp;
  XfceRc      *rc;
  const gchar *value;

  g_return_val_if_fail (XFAE_IS_MODEL (model), FALSE);
  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  lp = iter->user_data;
  item = lp->data;

  /* try to open the resource config */
  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, item->relpath, FALSE);
  if (G_UNLIKELY (rc == NULL))
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (EIO),
                   _("Failed to open %s for reading"), item->relpath);
      return FALSE;
    }

  /* read the resource config */
  value = xfce_rc_read_entry (rc, "Name", NULL);
  if (name != NULL)
   *name = g_strdup (value);

  value = xfce_rc_read_entry (rc, "Comment", NULL);
  if (description != NULL)
    *description = g_strdup (value);

  value = xfce_rc_read_entry (rc, "Exec", NULL);
  if (command != NULL)
    *command = g_strdup (value);

  xfce_rc_close (rc);

  return TRUE;
}
Ejemplo n.º 15
0
/**
 * xfae_model_edit:
 * @model       : a #XfaeModel.
 * @iter        : the #GtkTreeIter referring to the item that should be removed.
 * @name        : the user visible name of the new item.
 * @description : the description for the new item.
 * @command     : the command for the new item.
 * @error       : return locations for errors or %NULL.
 *
 * Attempts to edit an item with the given parameters
 * to @model.
 *
 * Return value: %TRUE if successfull, else %FALSE.
 **/
gboolean
xfae_model_edit (XfaeModel   *model,
                 GtkTreeIter *iter,
                 const gchar *name,
                 const gchar *description,
                 const gchar *command,
                 GError     **error)
{
  GtkTreePath *path;
  XfaeItem    *item;
  XfceRc      *rc;
  GList       *lp;

  g_return_val_if_fail (XFAE_IS_MODEL (model), FALSE);
  g_return_val_if_fail (iter->stamp == model->stamp, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  lp = iter->user_data;
  item = lp->data;

  /* try to open the resource config */
  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, item->relpath, FALSE);
  if (G_UNLIKELY (rc == NULL))
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (EIO),
                   _("Failed to open %s for writing"), item->relpath);
      return FALSE;
    }

  item->name = g_strdup (name);
  item->comment = g_strdup (description);

  /* write the result */
  xfce_rc_set_group (rc, "Desktop Entry");
  xfce_rc_write_entry (rc, "Name", name);
  xfce_rc_write_entry (rc, "Comment", description);
  xfce_rc_write_entry (rc, "Exec", command);
  xfce_rc_close (rc);

  /* tell the view that we have most probably a new state */
  path = gtk_tree_path_new_from_indices (g_list_position (model->items, lp), -1);
  gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, iter);
  gtk_tree_path_free (path);

  return TRUE;
}
Ejemplo n.º 16
0
static gboolean
read_entry_bool (const gchar *entry, gboolean fallback)
{
    gboolean ret_val = fallback;
    gchar *file;
    XfceRc *rc;
    
    file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, RESOURCE_FILE, TRUE);
    rc = xfce_rc_simple_open (file, TRUE);
    g_free (file);
    
    if ( rc )
    {
	ret_val = xfce_rc_read_bool_entry (rc, entry, fallback);
	xfce_rc_close (rc);
    }
    
    return ret_val;
}
Ejemplo n.º 17
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];
}
Ejemplo n.º 20
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;
}
Ejemplo n.º 21
0
static gboolean
xkb_load_config (t_xkb *xkb, const gchar *filename)
{
    XfceRc* rcfile;
    gint text_scale;

    if ((rcfile = xfce_rc_simple_open (filename, TRUE)))
    {
        xfce_rc_set_group (rcfile, NULL);

        xkb->display_type = xfce_rc_read_int_entry (rcfile, "display_type", DISPLAY_TYPE_IMAGE);
        text_scale = xfce_rc_read_int_entry (rcfile, "display_textscale", -1);
        if (text_scale < 0)
        {
            /* Check if the old textsize value is there */
            text_scale = xfce_rc_read_int_entry (rcfile, "display_textsize", -1);
            switch (text_scale)
            {
            case DISPLAY_TEXTSIZE_SMALL:
                text_scale = 47;
                break;
            case DISPLAY_TEXTSIZE_MEDIUM:
                text_scale = 70;
                break;
            case DISPLAY_TEXTSIZE_LARGE:
            default:
                text_scale = DISPLAY_TEXTSCALE_LARGE;
                break;
            }
        }
        xkb->display_text_scale = text_scale;
        xkb->display_img_scale = xfce_rc_read_int_entry (rcfile, "display_imgscale", DISPLAY_IMGSCALE_LARGE);
        xkb->group_policy = xfce_rc_read_int_entry (rcfile, "group_policy", GROUP_POLICY_PER_APPLICATION);

        xfce_rc_close (rcfile);

        return TRUE;
    }

    return FALSE;
}
Ejemplo n.º 22
0
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);
    }
}
Ejemplo n.º 23
0
void
quicklauncher_save_config(t_quicklauncher *quicklauncher, const gchar* filename)
{
	XfceRc* rcfile;
	GList* liste;
	guint16 i;
	//guint16 i = quicklauncher->nb_launcher; //hope it always works ==> seems that it does not ;)
	i = quicklauncher->nb_launcher;
	rcfile = xfce_rc_simple_open(filename, FALSE);
	if(!rcfile) return;

	xfce_rc_set_group(rcfile, NULL);
	xfce_rc_write_int_entry(rcfile, "nb_lines", quicklauncher->nb_lines);
	xfce_rc_write_int_entry(rcfile, "nb_launcher", quicklauncher->nb_launcher);
	xfce_rc_flush(rcfile);
	for( liste = quicklauncher->launchers; liste; liste = g_list_next(liste), --i)
		launcher_save_config((t_launcher*)liste->data, rcfile, i);

	g_assert(i == 0);
	xfce_rc_close(rcfile);
}
Ejemplo n.º 24
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);
}
Ejemplo n.º 25
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);
    }
}
Ejemplo n.º 26
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);
    }
}
Ejemplo n.º 27
0
static GSList *
parole_pl_parser_parse_pls (const gchar *filename)
{
    XfceRc *rcfile;
    GSList *list = NULL;
    ParoleFile *file;
    const gchar *file_entry, *title_entry;
    guint i, nentries;
    gchar key[128];

    rcfile = xfce_rc_simple_open (filename, TRUE);

    if ( xfce_rc_has_group (rcfile, "playlist") ) 
    {
        xfce_rc_set_group (rcfile, "playlist");
        
        nentries = xfce_rc_read_int_entry (rcfile, "NumberOfEntries", 0);

        for (i = 1; i <= nentries; i++) 
	{
            g_snprintf (key, 128, "File%d", i);
	    
            file_entry = xfce_rc_read_entry (rcfile, key, NULL);
	    
            if (!file_entry)
                continue;
	    
	    g_snprintf (key, 128, "Title%d", i);
	    
            title_entry = xfce_rc_read_entry (rcfile, key, NULL);
	    
	    file = parole_file_new_with_display_name (file_entry, title_entry);
	    list = g_slist_append (list, file);
	}
    }
    
    xfce_rc_close (rcfile);
    
    return list;
}
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);
}
Ejemplo n.º 30
0
/* Internal: Load command config file */
void
_verve_db_load_rc (VerveDb *db, const gchar *filename)
{
  XfceRc *rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, filename, FALSE);
  
  g_return_if_fail (xfce_rc_has_entry (rc, "Type"));

  /* Get command type */
  gint cmd_type = xfce_rc_read_int_entry (rc, "Type", VERVE_COMMAND_TYPE_SIMPLE);
  
  switch (cmd_type)
  {
    case VERVE_COMMAND_TYPE_SCRIPT:
      _verve_db_load_script_rc (db, rc);
      break;
    
    case VERVE_COMMAND_TYPE_SIMPLE:
      _verve_db_load_simple_rc (db, rc);
      break;
  }

  xfce_rc_close (rc);
}