void launcher_save_config(t_launcher *launcher, XfceRc *rcfile, guint16 num) { char group[15]; g_sprintf(group, "launcher_%d%c", num,0); xfce_rc_set_group(rcfile, group); xfce_rc_write_entry(rcfile, "command", launcher->command); if(launcher->icon_name) xfce_rc_write_entry(rcfile, "icon_name", launcher->icon_name); xfce_rc_write_int_entry(rcfile, "icon_id", launcher->icon_id); xfce_rc_flush(rcfile); }
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); } }
/** * 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; }
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); } }
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; }
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 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); } }
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); }
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 gboolean thunar_preferences_store_idle (gpointer user_data) { ThunarPreferences *preferences = THUNAR_PREFERENCES (user_data); const gchar *string; GParamSpec **specs; GParamSpec *spec; XfceRc *rc; GValue dst = { 0, }; GValue src = { 0, }; gchar *option; guint nspecs; guint n; rc = xfce_rc_config_open (XFCE_RESOURCE_CONFIG, "Thunar/thunarrc", FALSE); if (G_UNLIKELY (rc == NULL)) { g_warning ("Failed to store thunar preferences."); return FALSE; } /* suspend the monitor (hopefully tricking FAM to avoid unnecessary reloads) */ thunar_preferences_suspend_monitor (preferences); xfce_rc_set_group (rc, "Configuration"); specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (preferences), &nspecs); for (n = 0; n < nspecs; ++n) { spec = specs[n]; g_value_init (&dst, G_TYPE_STRING); if (spec->value_type == G_TYPE_STRING) { g_object_get_property (G_OBJECT (preferences), spec->name, &dst); } else { g_value_init (&src, spec->value_type); g_object_get_property (G_OBJECT (preferences), spec->name, &src); g_value_transform (&src, &dst); g_value_unset (&src); } /* determine the option name for the spec */ option = property_name_to_option_name (spec->name); /* store the setting */ string = g_value_get_string (&dst); if (G_LIKELY (string != NULL)) xfce_rc_write_entry (rc, option, string); /* cleanup */ g_value_unset (&dst); g_free (option); } /* cleanup */ xfce_rc_close (rc); g_free (specs); /* restart the monitor */ thunar_preferences_resume_monitor (preferences); return FALSE; }
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); }
void multiload_ps_settings_set_string(gpointer settings, const gchar *key, const gchar *value) { xfce_rc_write_entry((XfceRc*)settings, key, value); }
/** * 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; }