static void save_changed_permissions (const char *path, mode_t need_mask) { GKeyFile *key_file; char *key_file_path; char str[50]; key_file = g_key_file_new (); key_file_path = get_key_file_path (); /* NULL GError * * We don't check the return value of this. If the file doesn't exist, we'll * simply want to create it. */ g_key_file_load_from_file (key_file, key_file_path, 0, NULL); g_snprintf (str, sizeof (str), "%o", (guint) need_mask); /* octal, baby */ g_key_file_set_string (key_file, path, "need_mask", str); save_key_file (key_file_path, key_file); g_key_file_free (key_file); g_free (key_file_path); }
void e_print_run_page_setup_dialog (GtkWindow *parent) { GtkPageSetup *new_page_setup; GtkPageSetup *old_page_setup; GtkPrintSettings *settings; GKeyFile *key_file; key_file = g_key_file_new (); load_key_file (key_file); settings = load_settings (key_file); old_page_setup = load_page_setup (key_file); new_page_setup = gtk_print_run_page_setup_dialog ( parent, old_page_setup, settings); save_page_setup (new_page_setup, key_file); save_settings (settings, key_file); g_object_unref (new_page_setup); g_object_unref (old_page_setup); g_object_unref (settings); save_key_file (key_file); g_key_file_free (key_file); }
static void remove_from_saved_permissions (const char *path, mode_t remove_mask) { GKeyFile *key_file; char *key_file_path; if (remove_mask == 0) return; key_file = g_key_file_new (); key_file_path = get_key_file_path (); if (g_key_file_load_from_file (key_file, key_file_path, 0, NULL)) { mode_t need_mask; mode_t remove_from_current_mask; char *str; need_mask = 0; /* NULL GError */ str = g_key_file_get_string (key_file, path, "need_mask", NULL); if (str) { guint i; if (sscanf (str, "%o", &i) == 1) /* octal */ need_mask = i; g_free (str); } remove_from_current_mask = need_mask & remove_mask; remove_permissions (path, remove_from_current_mask); need_mask &= ~remove_mask; if (need_mask == 0) { /* NULL GError */ g_key_file_remove_group (key_file, path, NULL); } else { char buf[50]; g_snprintf (buf, sizeof (buf), "%o", (guint) need_mask); /* octal */ g_key_file_set_string (key_file, path, "need_mask", buf); } save_key_file (key_file_path, key_file); } g_key_file_free (key_file); g_free (key_file_path); }
static void print_done_cb (GtkPrintOperation *operation, GtkPrintOperationResult result, GKeyFile *key_file) { GtkPrintSettings *settings; settings = gtk_print_operation_get_print_settings (operation); if (result == GTK_PRINT_OPERATION_RESULT_APPLY) save_settings (settings, key_file); if (result == GTK_PRINT_OPERATION_RESULT_ERROR) handle_error (operation); save_key_file (key_file); g_key_file_free (key_file); }
void save_app_config(GKeyFile* key, const char* name) { char* path = g_build_filename(g_get_user_config_dir(), name, NULL); save_key_file(key, path); g_free(path); }