static void
thunar_preferences_resume_monitor (ThunarPreferences *preferences)
{
  ThunarVfsPath *path;
  gchar         *filename;

  /* verify that the monitor is suspended */
  if (G_LIKELY (preferences->handle == NULL))
    {
      /* determine the save location for thunarrc to monitor */
      filename = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "Thunar/thunarrc", TRUE);
      if (G_LIKELY (filename != NULL))
        {
          /* determine the VFS path for the filename */
          path = thunar_vfs_path_new (filename, NULL);
          if (G_LIKELY (path != NULL))
            {
              /* add the monitor handle for the file */
              preferences->handle = thunar_vfs_monitor_add_file (preferences->monitor, path, thunar_preferences_monitor, preferences);
              thunar_vfs_path_unref (path);
            }

          /* release the filename */
          g_free (filename);
        }
    }
}
Example #2
0
static gboolean
terminal_toolbars_model_sync (gpointer user_data)
{
  TerminalToolbarsModel *model = TERMINAL_TOOLBARS_MODEL (user_data);
  gchar                 *file;

  file = xfce_resource_save_location (XFCE_RESOURCE_DATA, "Terminal/Terminal-toolbars.ui", TRUE);
  exo_toolbars_model_save_to_file (EXO_TOOLBARS_MODEL (model), file, NULL);
  g_free (file);

  return FALSE;
}
Example #3
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);
}
Example #4
0
/**
 * rstto_settings_finalize:
 * @object:
 *
 */
static void
rstto_settings_finalize (GObject *object)
{
    gchar *accelmap_path = NULL;
    /*RsttoSettings *settings = RSTTO_SETTINGS (object);*/

    accelmap_path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "ristretto/accels.scm", TRUE);
    if (accelmap_path)
    {
        gtk_accel_map_save (accelmap_path);
        g_free (accelmap_path);
        accelmap_path = NULL;
    }
    
}
static void
_verve_history_cache_write (void)
{
  if (verve_history_is_empty ())
    return;

  const gchar *basename = _verve_history_cache_get_filename ();
  gchar *filename = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, basename, TRUE);

  if (G_UNLIKELY (filename == NULL))
    return;

  GError *error = NULL;
  GIOChannel *handle = g_io_channel_new_file (filename, "w+", &error);

  if (error)
    g_error_free (error);

  if (G_LIKELY (handle != NULL))
  {
    GList *current = verve_history_begin();
    
    GIOStatus status;
    gsize bytes;
    
    int i;
    for (i=0; i<25, current != NULL; i++) /* Cache the last 25 commands */
    {
      g_io_channel_write_chars (handle, g_strconcat ("", current->data, "\n", NULL), -1, &bytes, &error);
      
      if (error)
        break;
      
      current = verve_history_get_next (current);
    }

    g_io_channel_shutdown (handle, TRUE, &error);

    if (error)
      g_error_free (error);

    g_io_channel_unref (handle);
  }
  
  g_free (filename);
}
Example #6
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;
}
static void
verve_history_cache_write (void)
{
  /* Do not write history if it is empty */
  if (verve_history_is_empty ())
    return;

  const gchar *basename = verve_history_cache_get_filename ();

  /* Search for history file, create if it does not exist yet */
  gchar *filename = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, basename, TRUE);

  if (G_LIKELY (filename != NULL))
    {
      GError     *error = NULL;
      GIOChannel *handle;
     
      /* Open output stream */
      handle = g_io_channel_new_file (filename, "w+", &error);

      /* Ignore and free error messages */
      if (G_UNLIKELY (error != NULL))
        g_error_free (error);

      /* Only write contents if stream could be opened */
      if (G_LIKELY (handle != NULL))
      {
        GList    *current;
        gsize     bytes;
        int       i;

        /* Get first history entry */
        current = verve_history_begin();

        /* Save the last 25 commands */
        for (i = 0; i < history_length && current != NULL; i++)
          {
            /* Build output line */
            gchar *line = g_strconcat ("", current->data, "\n", NULL);

            /* Write line */
            g_io_channel_write_chars (handle, line, -1, &bytes, &error);

            /* Free line string */
            g_free (line);
            
            /* Do not write more records if there was an error (e.g. no space left on device) */
            if (G_UNLIKELY (error != NULL))
              {
                g_error_free (error);
                break;
              }
            
            /* Step over to next entry */
            current = verve_history_get_next (current);
          }

        /* Close file handle */
        g_io_channel_shutdown (handle, TRUE, &error);

        /* Free error message */
        if (G_UNLIKELY (error != NULL))
          g_error_free (error);

        /* Destroy stream object */
        g_io_channel_unref (handle);
      }
    }
  
  /* Free filename string */
  g_free (filename);
}
Example #8
0
static void
migrate_46_plugin_launcher (XfconfChannel  *channel,
                            XfceRc         *rc,
                            guint           plugin_id,
                            GError        **error)
{
  guint      i;
  gchar      buf[128];
  XfceRc    *new_desktop;
  gchar     *path;
  GTimeVal   timeval;
  GPtrArray *array;
  GValue    *value;
  gchar     *filename;

  if (xfce_rc_has_group (rc, "Global"))
    {
      xfce_rc_set_group (rc, "Global");

      migrate_46_plugin_bool ("MoveFirst", "move-first", FALSE);
      migrate_46_plugin_bool ("ArrowPosition", "arrow-position", 0);
    }

  g_get_current_time (&timeval);
  array = g_ptr_array_new ();

  for (i = 0; i < 100 /* arbitrary */; i++)
    {
      g_snprintf (buf, sizeof (buf), "Entry %d", i);
      if (!xfce_rc_has_group (rc, buf))
        break;

      xfce_rc_set_group (rc, buf);

      g_snprintf (buf, sizeof (buf), "heartlenv" G_DIR_SEPARATOR_S "panel"
                  G_DIR_SEPARATOR_S LAUNCHER_FOLDER "-%d" G_DIR_SEPARATOR_S "%ld%d.desktop",
                  plugin_id, timeval.tv_sec, i);
      path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, buf, TRUE);
      if (G_UNLIKELY (path == NULL))
        {
          g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
                       "Failed to create new launcher desktop file in \"%s\"", buf);
          break;
        }
      else if (g_file_test (path, G_FILE_TEST_EXISTS))
        {
          g_set_error (error, G_FILE_ERROR_EXIST, G_FILE_ERROR,
                       "Deasktop item \"%s\" already exists", path);
          g_free (path);
          break;
        }

      new_desktop = xfce_rc_simple_open (path, FALSE);
      if (G_UNLIKELY (new_desktop == NULL))
        {
          g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
                       "Failed to create new desktop file \"%s\"", path);
          g_free (path);
          break;
        }


      xfce_rc_set_group (new_desktop, G_KEY_FILE_DESKTOP_GROUP);

      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_TYPE,
          G_KEY_FILE_DESKTOP_TYPE_APPLICATION);
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_NAME,
          xfce_rc_read_entry (rc, "Name", ""));
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_COMMENT,
          xfce_rc_read_entry (rc, "Comment", ""));
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_ICON,
          xfce_rc_read_entry (rc, "Icon", ""));
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_EXEC,
          xfce_rc_read_entry (rc, "Exec", ""));
      xfce_rc_write_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_PATH,
          xfce_rc_read_entry (rc, "Path", ""));
      xfce_rc_write_bool_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_TERMINAL,
          xfce_rc_read_bool_entry (rc, "Terminal", FALSE));
      xfce_rc_write_bool_entry (new_desktop, G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY,
          xfce_rc_read_bool_entry (rc, "StartupNotify", FALSE));

      xfce_rc_flush (new_desktop);
      if (xfce_rc_is_dirty (new_desktop))
        {
          g_set_error (error, G_FILE_ERROR_FAILED, G_FILE_ERROR,
                       "Failed to flush desktop file \"%s\"", path);
          g_free (path);
          xfce_rc_close (new_desktop);
          break;
        }

      g_free (path);
      xfce_rc_close (new_desktop);

      value = g_new0 (GValue, 1);
      g_value_init (value, G_TYPE_STRING);
      filename = g_strdup_printf ("%ld%d.desktop", timeval.tv_sec, i);
      g_value_take_string (value, filename);
      g_ptr_array_add (array, value);
    }

  xfconf_channel_set_arrayv (channel, "/items", array);
  xfconf_array_free (array);
}
static void
clipman_read (ClipmanPlugin *clipman)
{
    XfceRc      *rc;
    gchar       *file;
    guint        type, i, clipslen;
    gchar        name[13];
    const gchar *value;
    
    /* Because Clipman is unique, we use 1 config file */
    /*
    file = xfce_panel_plugin_save_location (clipman->plugin, FALSE);
    DBG("Read from file: %s", file);
    */
    
    file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE);

    if (G_UNLIKELY (!file))
        return;
    
    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);
    
    xfce_rc_set_group (rc, "Properties");
    
    clipman->ExitSave         = xfce_rc_read_bool_entry (rc, "ExitSave",     DEFEXITSAVE);
    clipman->IgnoreSelect     = xfce_rc_read_bool_entry (rc, "IgnoreSelect", DEFIGNORESELECT);
    clipman->PreventEmpty     = xfce_rc_read_bool_entry (rc, "PreventEmpty", DEFPREVENTEMPTY);
    
    switch (xfce_rc_read_int_entry (rc, "Behaviour", DEFBEHAVIOUR))
    {
        case 1:
            clipman->Behaviour = NORMAL;
            DBG ("Behaviour = NORMAL");
            break;
        case 2:
            clipman->Behaviour = STRICTLY;
            DBG ("Behaviour = STRICTLY");
            break;
    }
    
    clipman->ItemNumbers      = xfce_rc_read_bool_entry (rc, "ItemNumbers",    DEFITEMNUMBERS);
    clipman->SeparateMenu     = xfce_rc_read_bool_entry (rc, "SeparateMenu",   DEFSEPMENU);
    
    clipman->HistoryItems     = xfce_rc_read_int_entry  (rc, "HistoryItems",   DEFHISTORY);
    clipman->MenuCharacters   = xfce_rc_read_int_entry  (rc, "MenuCharacters", DEFCHARS);
    
    if (clipman->HistoryItems > MAXHISTORY)
        clipman->HistoryItems = MAXHISTORY;
    if (clipman->HistoryItems < MINHISTORY)
        clipman->HistoryItems = MINHISTORY;
    
    if (clipman->MenuCharacters > MAXCHARS)
        clipman->MenuCharacters = MAXCHARS;
    if (clipman->MenuCharacters < MINCHARS)
        clipman->MenuCharacters = MINCHARS;
    
    xfce_rc_set_group (rc, "Clips");
    clipslen = xfce_rc_read_int_entry (rc, "ClipsLen", 0);
    
    if (clipslen > MAXHISTORY)
        clipslen = MAXHISTORY;
    
    if (clipman->ExitSave && 
        clipslen > 0
       )
    {
        DBG("Restoring the clipboard");
        
        for (i = 0; i < clipslen; ++i)
        {
            g_snprintf (name, 13, "clip_%d_text", i);
            value = xfce_rc_read_entry (rc, name, "");
            
            g_snprintf (name, 13, "clip_%d_from", i);
            type = xfce_rc_read_int_entry (rc, name, 0);
            
            if (type == 0)
                clipman_add_clip (clipman, (gchar *)value, PRIMARY);
            else
                clipman_add_clip (clipman, (gchar *)value, DEFAULT);
        }
    }
    
    xfce_rc_close (rc);
}
void
clipman_save (XfcePanelPlugin *plugin,
              ClipmanPlugin   *clipman)
{
    XfceRc      *rc;
    gchar       *file;
    guint        i;
    gchar        name[13];
    ClipmanClip *clip;
    
    DBG("Saving clipman settings");

    file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/panel/clipman.rc", TRUE);

    if (G_UNLIKELY (!file))
        return;
    
    rc = xfce_rc_simple_open (file, FALSE);
    g_free (file);
    
    /* Save the preferences */
    xfce_rc_set_group (rc, "Properties");
    
    xfce_rc_write_bool_entry (rc, "ExitSave",     clipman->ExitSave);
    xfce_rc_write_bool_entry (rc, "IgnoreSelect", clipman->IgnoreSelect);
    xfce_rc_write_bool_entry (rc, "PreventEmpty", clipman->PreventEmpty);
    
    switch (clipman->Behaviour)
    {
        case NORMAL:
            xfce_rc_write_int_entry (rc, "Behaviour", 1);
            break;
        case STRICTLY:
            xfce_rc_write_int_entry (rc, "Behaviour", 2);
            break;
    }
    
    xfce_rc_write_bool_entry (rc, "ItemNumbers",  clipman->ItemNumbers);
    xfce_rc_write_bool_entry (rc, "SeparateMenu", clipman->SeparateMenu);
    
    xfce_rc_write_int_entry (rc, "HistoryItems",   clipman->HistoryItems);
    xfce_rc_write_int_entry (rc, "MenuCharacters", clipman->MenuCharacters);
    
    /* Remove old content and create a new one */
    xfce_rc_delete_group (rc, "Clips", TRUE );
    
    if (clipman->ExitSave && 
        clipman->clips->len > 0
       )
    {
        DBG("Saving the clipboard history");
        
        xfce_rc_set_group (rc, "Clips");
        xfce_rc_write_int_entry (rc, "ClipsLen", clipman->clips->len);
        
        for (i = 0; i < clipman->clips->len; ++i)
        {
            clip = g_ptr_array_index (clipman->clips, i);
            
            g_snprintf (name, 13, "clip_%d_text", i);
            xfce_rc_write_entry (rc, name, clip->text);
            
            g_snprintf (name, 13, "clip_%d_from", i);
            if (clip->fromtype == PRIMARY)
                xfce_rc_write_int_entry (rc, name, 0);
            else
                xfce_rc_write_int_entry (rc, name, 1);
        }
    }

    xfce_rc_close (rc);
}
Example #11
0
int main (int argc, char **argv)
{
  GError *cli_error = NULL;
  GFile *default_save_dir;
  const gchar *rc_file;
  const gchar *conflict_error =
    _("Conflicting options: --%s and --%s cannot be used at the same time.\n");
  const gchar *ignore_error =
    _("The --%s option is only used when --fullscreen, --window or"
      " --region is given. It will be ignored.\n");

  ScreenshotData *sd = g_new0 (ScreenshotData, 1);
  sd->plugin = FALSE;

  xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");

  /* Print a message to advise to use help when a non existing cli option is
  passed to the executable. */
  if (!gtk_init_with_args(&argc, &argv, "", entries, PACKAGE, &cli_error))
    {
      if (cli_error != NULL)
        {
          g_print (_("%s: %s\nTry %s --help to see a full list of"
                     " available command line options.\n"),
                   PACKAGE, cli_error->message, PACKAGE_NAME);

          g_error_free (cli_error);

          return EXIT_FAILURE;
        }
    }

  /* Exit if two region options were given */
  if (window && fullscreen)
    {
      g_printerr (conflict_error, "window", "fullscreen");
      return EXIT_FAILURE;
    }
  else if (window && region)
    {
      g_printerr (conflict_error, "window", "region");
      return EXIT_FAILURE;
    }
  else if (fullscreen && region)
    {
      g_printerr (conflict_error, "fullscreen", "region");
      return EXIT_FAILURE;
    }

  /* Exit if two actions options were given */
  if (upload && (application != NULL))
    {
      g_printerr (conflict_error, "upload", "open");
      return EXIT_FAILURE;
    }
  else if (upload && (screenshot_dir != NULL))
    {
      g_printerr (conflict_error, "upload", "save");
      return EXIT_FAILURE;
    }
  else if ((application != NULL) && (screenshot_dir != NULL))
    {
      g_printerr (conflict_error, "open", "save");
      return EXIT_FAILURE;
    }
  else if (upload_imgur && upload)
    {
      g_printerr (conflict_error, "upload", "imgur");
      return EXIT_FAILURE;
    }
  else if (upload_imgur && (screenshot_dir != NULL))
    {
      g_printerr (conflict_error, "imgur", "save");
      return EXIT_FAILURE;
    }
  else if (upload_imgur && (application != NULL))
    {
      g_printerr (conflict_error, "imgur", "open");
      return EXIT_FAILURE;
    }

  /* Warn that action options, mouse and delay will be ignored in 
   * non-cli mode */
  if ((application != NULL) && !(fullscreen || window || region))
    g_printerr (ignore_error, "open");
  if ((screenshot_dir != NULL)  && !(fullscreen || window || region ))
    g_printerr (ignore_error, "save");
  if (upload_imgur && !(fullscreen || window || region))
    g_printerr (ignore_error, "imgur");
  if (upload && !(fullscreen || window || region))
    g_printerr (ignore_error, "upload");
  if (delay && !(fullscreen || window || region))
    g_printerr (ignore_error, "delay");
  if (mouse && !(fullscreen || window || region))
    g_printerr (ignore_error, "mouse");

  if (!g_thread_supported ())
    g_thread_init (NULL);

  /* Read the preferences */
  rc_file = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/xfce4-screenshooter", TRUE);
  screenshooter_read_rc_file (rc_file, sd);

  /* Default to no action specified */
  sd->action_specified = FALSE;

  /* Check if the directory read from the preferences is valid */
  default_save_dir = g_file_new_for_uri (sd->screenshot_dir);

  if (G_UNLIKELY (!g_file_query_exists (default_save_dir, NULL)))
    {
      g_free (sd->screenshot_dir);
      sd->screenshot_dir = screenshooter_get_xdg_image_dir_uri ();
    }

  g_object_unref (default_save_dir);

  /* Just print the version if we are in version mode */
  if (version)
    {
      g_print ("%s\n", PACKAGE_STRING);

      return EXIT_SUCCESS;
    }

  /* If a region cli option is given, take the screenshot accordingly.*/
  if (fullscreen || window || region)
    {
      /* Set the region to be captured */
      if (window)
        sd->region = ACTIVE_WINDOW;
      else if (fullscreen)
        sd->region = FULLSCREEN;
      else if (region)
        sd->region = SELECT;

      /* Whether to display the mouse pointer on the screenshot */
      mouse ? (sd->show_mouse = 1) : (sd->show_mouse = 0);

      sd->delay = delay;

      if (application != NULL)
        {
          sd->app = application;
          sd->action = OPEN;
          sd->action_specified = TRUE;
        }
      else if (upload)
        {
          sd->app = g_strdup ("none");
          sd->action = UPLOAD;
          sd->action_specified = TRUE;
        }
      else if (upload_imgur)
        {
          sd->app = g_strdup ("none");
          sd->action = UPLOAD_IMGUR;
          sd->action_specified = TRUE;
        }
      else
        {
          sd->app = g_strdup ("none");
          sd->action = SAVE;
        }

      /* If the user gave a directory name, check that it is valid */
      if (screenshot_dir != NULL)
        {
          default_save_dir = g_file_new_for_commandline_arg (screenshot_dir);

          if (G_LIKELY (g_file_query_exists (default_save_dir, NULL)))
            {
              g_free (sd->screenshot_dir);
              sd->screenshot_dir = g_file_get_uri (default_save_dir);
              sd->action_specified = TRUE;
            }
          else
              screenshooter_error (_("%s is not a valid directory, the default"
                                   " directory will be used."),
                                   screenshot_dir);

          g_object_unref (default_save_dir);
          g_free (screenshot_dir);
        }

      g_idle_add ((GSourceFunc) screenshooter_take_screenshot_idle, sd);
    }
  /* Else we show a dialog which allows to set the screenshot options */
  else
    {
      GtkWidget *dialog;

      /* Use 0 as the minimal delay */
      if (sd->delay == 0)
        sd->delay = 1;

      /* Set the dialog up */
      dialog = screenshooter_region_dialog_new (sd, FALSE);
      g_signal_connect (dialog, "response",
                        G_CALLBACK (cb_dialog_response), sd);
      g_signal_connect (dialog, "key-press-event",
                        G_CALLBACK (screenshooter_f1_key), NULL);
      gtk_widget_show (dialog);
    }

  gtk_main ();

  /* Save preferences */
  screenshooter_write_rc_file (rc_file, sd);

  g_free (sd->screenshot_dir);
  g_free (sd->title);
  g_free (sd->app);
  g_free (sd->last_user);
  g_free (sd);

  TRACE ("Ciao");

  return EXIT_SUCCESS;
}
Example #12
0
/**
 * xfae_model_add:
 * @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_add (XfaeModel   *model,
                const gchar *name,
                const gchar *description,
                const gchar *command,
                GError     **error)
{
  GtkTreePath *path;
  GtkTreeIter  iter;
  XfaeItem    *item;
  XfceRc      *rc;
  gchar       *file;
  gchar       *dir;
  gchar        relpath[4096];
  guint        n;

  g_return_val_if_fail (XFAE_IS_MODEL (model), FALSE);
  g_return_val_if_fail (name != NULL, FALSE);
  g_return_val_if_fail (description != NULL, FALSE);
  g_return_val_if_fail (command != NULL, FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  dir = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "autostart/", TRUE);

  /* generate a unique file name */
  for (n = 0;; ++n)
    {
      file = (n == 0)
        ?  g_strdup_printf ("%s.desktop", name)
        : g_strdup_printf ("%s-%u.desktop", name, n);
      file = g_strdelimit (file, G_DIR_SEPARATOR_S, '-'); /* not a copy */

      g_snprintf (relpath, 4096, "%s%s", dir, file);
      if (!g_file_test (relpath, G_FILE_TEST_IS_REGULAR))
        break;

      g_free (file);
    }

  /* generate the file spec */
  g_snprintf (relpath, 4096, "autostart/%s", file);
  g_free (file);
  g_free (dir);

  /* generate the .desktop file */
  rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, relpath, FALSE);
  if (G_UNLIKELY (rc == NULL))
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (EIO),
                   _("Failed to create file %s"), relpath);
      return FALSE;
    }

  /* write the content */
  xfce_rc_set_group (rc, "Desktop Entry");
  xfce_rc_write_entry (rc, "Encoding", "UTF-8");
  xfce_rc_write_entry (rc, "Version", "0.9.4");
  xfce_rc_write_entry (rc, "Type", "Application");
  xfce_rc_write_entry (rc, "Name", name);
  xfce_rc_write_entry (rc, "Comment", description);
  xfce_rc_write_entry (rc, "Exec", command);
  xfce_rc_write_entry (rc, "OnlyShowIn", "XFCE;");
  xfce_rc_write_bool_entry (rc, "StartupNotify", FALSE);
  xfce_rc_write_bool_entry (rc, "Terminal", FALSE);
  xfce_rc_write_bool_entry (rc, "Hidden", FALSE);
  xfce_rc_close (rc);

  /* now load the matching item for the list */
  item = xfae_item_new (relpath);
  if (G_UNLIKELY (item == NULL))
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (EIO),
                   _("Failed to write file %s"), relpath);
      return FALSE;
    }

  /* append it to our list */
  model->items = g_list_append (model->items, item);

  /* generate the iter for the newly appended item */
  iter.stamp = model->stamp;
  iter.user_data = g_list_last (model->items);

  /* tell the view about it */
  path = gtk_tree_path_new_from_indices (g_list_length (model->items) - 1, -1);
  gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
  gtk_tree_path_free (path);

  return TRUE;
}