Example #1
0
void
on_css_filechooser_file_set(GtkFileChooserButton *button, ChimaraGlk *glk)
{
	GError *error = NULL;
	extern GSettings *prefs_settings;
	char *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(button) );
	if(!chimara_glk_set_css_from_file(glk, filename, &error)) {
		error_dialog(NULL, error, "There was a problem reading the CSS file: ");
		g_settings_set(prefs_settings, "css-file", "ms", NULL);
	} else {
		g_settings_set(prefs_settings, "css-file", "ms", filename);
	}
	g_free(filename);
}
Example #2
0
void
on_interpreter_cell_changed(GtkCellRendererCombo *combo, char *path_string, GtkTreeIter *new_iter, ChimaraGlk *glk)
{
	unsigned int format, interpreter;
	format = (unsigned int)strtol(path_string, NULL, 10);
	GtkTreeModel *combo_model;
	g_object_get(combo, "model", &combo_model, NULL);
	char *combo_string = gtk_tree_model_get_string_from_iter(combo_model, new_iter);
	interpreter = (unsigned int)strtol(combo_string, NULL, 10);
	g_free(combo_string);

	chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), format, interpreter);

	/* Display the new setting in the list */
	GtkTreeIter iter;
	GtkTreePath *path = gtk_tree_path_new_from_string(path_string);
	gtk_tree_model_get_iter(GTK_TREE_MODEL(preferred_list), &iter, path);
	gtk_tree_path_free(path);
	gtk_list_store_set(preferred_list, &iter,
		1, interpreter_to_display_string(interpreter),
		-1);

	/* Save the new settings in the preferences file */
	extern GSettings *prefs_settings;
	GVariantBuilder *builder = g_variant_builder_new( G_VARIANT_TYPE("a{ss}") );
	unsigned int count;
	for(count = 0; count < CHIMARA_IF_NUM_FORMATS; count++) {
		g_variant_builder_add(builder, "{ss}",
			format_to_string(count),
			interpreter_to_string(chimara_if_get_preferred_interpreter(CHIMARA_IF(glk), count)));
	}
	g_settings_set(prefs_settings, "preferred-interpreters", "a{ss}", builder);
	g_variant_builder_unref(builder);
}
Example #3
0
gboolean
xmr_settings_set_window_pos(XmrSettings *sett,
			gint x, gint y)
{
	g_return_val_if_fail( sett != NULL, FALSE);

	return g_settings_set(G_SETTINGS(sett), "window-pos", "(ii)", x, y);
}
Example #4
0
static gboolean
window_state_timeout_cb (WindowState *state)
{
  g_settings_set (state->settings, "size", "(ii)", state->width, state->height);

  state->timeout_id = 0;
  return FALSE;
}
Example #5
0
void
on_resource_file_set(GtkFileChooserButton *button, ChimaraGlk *glk)
{
	extern GSettings *prefs_settings;
	char *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(button) );
	g_settings_set(prefs_settings, "resource-path", "ms", filename);
	g_free(filename);
}
static void
save_last_used_obex_device (const char *bdaddr)
{
	GSettings *settings;

	settings = g_settings_new (SCHEMA_NAME);
	g_settings_set (settings, PREF_LAST_USED, bdaddr);
	g_object_unref (settings);
}
static void
set_idle_delay_from_dpms (CcScreenPanel *self,
                          int            value)
{
  guint off_delay;

  off_delay = 0;

  if (value > 0)
    off_delay = (guint) value;

  g_settings_set (self->priv->session_settings, "idle-delay", "u", off_delay);
}
Example #8
0
/**
 * gva_main_set_last_selected_match:
 * @column_name: the column name of the completion match
 * @search_text: the search text of the completion match
 *
 * Writes @column_name and @search_text to GSettings key
 * <filename>sql-expression</filename> as a string tuple.
 *
 * This is used to remember whether the search results from the previous
 * session of <emphasis>GNOME Video Arcade</emphasis> were the result of
 * selecting a match from the search completion list.  If so, the values
 * are also used to restore the contents of the Search Results view.
 **/
void
gva_main_set_last_selected_match (const gchar *column_name,
                                  const gchar *search_text)
{
        GSettings *settings;

        settings = gva_get_settings ();

        g_settings_set (
                settings, GVA_SETTING_SELECTED_MATCH, "(ss)",
                (column_name != NULL) ? column_name : "",
                (search_text != NULL) ? search_text : "");
}
Example #9
0
static gboolean
sp_window_settings__window_save_settings_cb (gpointer data)
{
  GtkWindow *window = data;
  GdkRectangle geom;
  gboolean maximized;

  g_assert (GTK_IS_WINDOW (window));
  g_assert (G_IS_SETTINGS (settings));

  g_object_set_data (G_OBJECT (window), "SETTINGS_HANDLER_ID", NULL);

  gtk_window_get_size (window, &geom.width, &geom.height);
  gtk_window_get_position (window, &geom.x, &geom.y);
  maximized = gtk_window_is_maximized (window);

  g_settings_set (settings, "window-size", "(ii)", geom.width, geom.height);
  g_settings_set (settings, "window-position", "(ii)", geom.x, geom.y);
  g_settings_set_boolean (settings, "window-maximized", maximized);

  return G_SOURCE_REMOVE;
}
static void
new_chatroom_dialog_store_last_account (GSettings             *gsettings,
                                        EmpathyAccountChooser *account_chooser)
{
	TpAccount   *account;
	const char *account_path;

	account = empathy_account_chooser_get_account (account_chooser);
	if (account == NULL)
		return;

	account_path = tp_proxy_get_object_path (account);
	DEBUG ("Storing account path '%s'", account_path);

	g_settings_set (gsettings, EMPATHY_PREFS_CHAT_ROOM_LAST_ACCOUNT,
	                "o", account_path);
}
static void
lock_combo_changed_cb (GtkWidget *widget, CcScreenPanel *self)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  guint delay;
  gboolean ret;

  /* no selection */
  ret = gtk_combo_box_get_active_iter (GTK_COMBO_BOX(widget), &iter);
  if (!ret)
    return;

  /* get entry */
  model = gtk_combo_box_get_model (GTK_COMBO_BOX(widget));
  gtk_tree_model_get (model, &iter,
                      1, &delay,
                      -1);
  g_settings_set (self->priv->lock_settings, "lock-delay", "u", delay);
}
static void
fr_file_selector_dialog_unmap (GtkWidget *widget)
{
	FrFileSelectorDialog *self;
	int                   width;
	int                   height;

	self = FR_FILE_SELECTOR_DIALOG (widget);

	gtk_window_get_size (GTK_WINDOW (self), &width, &height);
	g_settings_set (self->priv->settings, PREF_FILE_SELECTOR_WINDOW_SIZE, "(ii)", width, height);
	g_settings_set_boolean (self->priv->settings, PREF_FILE_SELECTOR_SHOW_HIDDEN, self->priv->show_hidden);
	g_settings_set_int (self->priv->settings,
			    PREF_FILE_SELECTOR_SIDEBAR_SIZE,
			    gtk_paned_get_position (GTK_PANED (GET_WIDGET ("main_paned"))));

	if (self->priv->current_operation != NULL)
		g_cancellable_cancel (self->priv->current_operation->cancellable);

	GTK_WIDGET_CLASS (fr_file_selector_dialog_parent_class)->unmap (widget);
}
static void
purge_after_combo_changed_cb (GtkWidget      *widget,
                              CcPrivacyPanel *self)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  guint value;
  gboolean ret;

  /* no selection */
  ret = gtk_combo_box_get_active_iter (GTK_COMBO_BOX(widget), &iter);
  if (!ret)
    return;

  /* get entry */
  model = gtk_combo_box_get_model (GTK_COMBO_BOX(widget));
  gtk_tree_model_get (model, &iter,
                      1, &value,
                      -1);
  g_settings_set (self->priv->privacy_settings, OLD_FILES_AGE, "u", value);
}
Example #14
0
gboolean w_settings_set_window_size(wSettings *sett, gint w, gint h)
{
	g_return_val_if_fail( sett != NULL, FALSE);

	return g_settings_set(G_SETTINGS(sett), "window-size", "(ii)", w, h);
}
static gboolean
handle_file (const gchar *filename)
{
  GKeyFile *keyfile;
  MateConfClient *client;
  MateConfValue *value;
  gint i, j;
  gchar *mateconf_key;
  gchar **groups;
  gchar **keys;
  GVariantBuilder *builder;
  GVariant *v;
  const gchar *s;
  gchar *str;
  gint ii;
  GSList *list, *l;
  GSettings *settings;
  GError *error;

  keyfile = g_key_file_new ();

  error = NULL;
  if (!g_key_file_load_from_file (keyfile, filename, 0, &error))
    {
      g_printerr ("%s\n", error->message);
      g_error_free (error);

      g_key_file_free (keyfile);

      return FALSE;
    }

  client = mateconf_client_get_default ();

  groups = g_key_file_get_groups (keyfile, NULL);
  for (i = 0; groups[i]; i++)
    {
      gchar **schema_path;

      schema_path = g_strsplit (groups[i], ":", 2);

      if (verbose)
        {
          g_print ("collecting settings for schema '%s'\n", schema_path[0]);
          if (schema_path[1])
            g_print ("for storage at '%s'\n", schema_path[1]);
        }

      if (schema_path[1] != NULL)
        settings = g_settings_new_with_path (schema_path[0], schema_path[1]);
      else
        settings = g_settings_new (schema_path[0]);

      g_settings_delay (settings);

      error = NULL;
      if ((keys = g_key_file_get_keys (keyfile, groups[i], NULL, &error)) == NULL)
        {
          g_printerr ("%s", error->message);
          g_error_free (error);

          continue;
        }

      for (j = 0; keys[j]; j++)
        {
          if (strchr (keys[j], '/') != 0)
            {
              g_printerr ("Key '%s' contains a '/'\n", keys[j]);

              continue;
            }

          error = NULL;
          if ((mateconf_key = g_key_file_get_string (keyfile, groups[i], keys[j], &error)) ==  NULL)
            {
              g_printerr ("%s", error->message);
              g_error_free (error);

              continue;
            }

          error = NULL;
          if ((value = mateconf_client_get_without_default (client, mateconf_key, &error)) == NULL)
            {
              if (error)
                {
                  g_printerr ("Failed to get MateConf key '%s': %s\n",
                              mateconf_key, error->message);
                  g_error_free (error);
                }
              else
                {
                  if (verbose)
                    g_print ("Skipping MateConf key '%s', no user value\n",
                             mateconf_key);
                }

              g_free (mateconf_key);

              continue;
            }

          switch (value->type)
            {
            case MATECONF_VALUE_STRING:
              if (dry_run)
                g_print ("set key '%s' to string '%s'\n", keys[j],
                         mateconf_value_get_string (value));
              else
                g_settings_set (settings, keys[j], "s",
                                mateconf_value_get_string (value));
              break;

            case MATECONF_VALUE_INT:
              if (dry_run)
                g_print ("set key '%s' to integer '%d'\n",
                         keys[j], mateconf_value_get_int (value));
              else
                g_settings_set (settings, keys[j], "i",
                                mateconf_value_get_int (value));
              break;

            case MATECONF_VALUE_BOOL:
              if (dry_run)
                g_print ("set key '%s' to boolean '%d'\n",
                         keys[j], mateconf_value_get_bool (value));
              else
                g_settings_set (settings, keys[j], "b",
                                mateconf_value_get_bool (value));
              break;

            case MATECONF_VALUE_FLOAT:
              if (dry_run)
                g_print ("set key '%s' to double '%g'\n",
                         keys[j], mateconf_value_get_float (value));
              else
                g_settings_set (settings, keys[j], "d",
                                mateconf_value_get_float (value));
              break;

            case MATECONF_VALUE_LIST:
              switch (mateconf_value_get_list_type (value))
                {
                case MATECONF_VALUE_STRING:
                  builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
                  list = mateconf_value_get_list (value);
                  if (list != NULL)
                    {
                      for (l = list; l; l = l->next)
                        {
                          MateConfValue *lv = l->data;
                          s = mateconf_value_get_string (lv);
                          g_variant_builder_add (builder, "s", s);
                        }
                      v = g_variant_new ("as", builder);
                    }
                  else
                    v = g_variant_new_array (G_VARIANT_TYPE_STRING, NULL, 0);
                  g_variant_ref_sink (v);

                  if (dry_run)
                    {
                      str = g_variant_print (v, FALSE);
                      g_print ("set key '%s' to a list of strings: %s\n",
                               keys[j], str);
                      g_free (str);
                    }
                  else
                    g_settings_set_value (settings, keys[j], v);

                  g_variant_unref (v);
                  g_variant_builder_unref (builder);
                  break;

                case MATECONF_VALUE_INT:
                  builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
                  list = mateconf_value_get_list (value);
                  if (list != NULL)
                    {
                      for (l = list; l; l = l->next)
                        {
                          MateConfValue *lv = l->data;
                          ii = mateconf_value_get_int (lv);
                          g_variant_builder_add (builder, "i", ii);
                        }
                      v = g_variant_new ("ai", builder);
                    }
                  else
                    v = g_variant_new_array (G_VARIANT_TYPE_INT32, NULL, 0);
                  g_variant_ref_sink (v);

                  if (dry_run)
                    {
                      str = g_variant_print (v, FALSE);
                      g_print ("set key '%s' to a list of integers: %s\n",
                               keys[j], str);
                      g_free (str);
                    }
                  else
                    g_settings_set_value (settings, keys[j], v);

                  g_variant_unref (v);
                  g_variant_builder_unref (builder);
                  break;

                default:
                  g_printerr ("Keys of type 'list of %s' not handled yet\n",
                              mateconf_value_type_to_string (mateconf_value_get_list_type (value)));
                  break;
                }
              break;

            default:
              g_printerr ("Keys of type %s not handled yet\n",
                          mateconf_value_type_to_string (value->type));
              break;
            }

          mateconf_value_free (value);
          g_free (mateconf_key);
        }

      g_strfreev (keys);

      if (!dry_run)
        g_settings_apply (settings);

      g_object_unref (settings);
      g_strfreev (schema_path);
    }

  g_strfreev (groups);

  g_object_unref (client);

  return TRUE;
}
Example #16
0
/* Create the preferences dialog. */
void
preferences_create(ChimaraGlk *glk)
{
	/* Initialize the tree of style names */
	GtkTreeStore *style_list = GTK_TREE_STORE( load_object("style-list") );
	GtkTreeIter buffer, grid, buffer_child, grid_child;

	gtk_tree_store_append(style_list, &buffer, NULL);
	gtk_tree_store_append(style_list, &grid, NULL);
	gtk_tree_store_set(style_list, &buffer, 0, "Text buffer", -1);
	gtk_tree_store_set(style_list, &grid, 0, "Text grid", -1);

	unsigned i, num_tags;
	const char * const *tag_names = chimara_glk_get_tag_names(glk, &num_tags);
	for(i=0; i<num_tags; i++) {
		gtk_tree_store_append(style_list, &buffer_child, &buffer);
		gtk_tree_store_append(style_list, &grid_child, &grid);
		gtk_tree_store_set(style_list, &buffer_child, 0, tag_names[i], -1);
		gtk_tree_store_set(style_list, &grid_child, 0, tag_names[i], -1);
	}

	/* Set selection mode to single select */
	GtkTreeView *view = GTK_TREE_VIEW( load_object("style-treeview") );
	GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
	gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
	g_signal_connect(selection, "changed", G_CALLBACK(style_tree_select_callback), glk);

	/* Bind the preferences to the entries in the preferences file */
	extern GSettings *prefs_settings;
	GObject *flep = G_OBJECT( load_object("flep") );
	g_settings_bind(prefs_settings, "flep", flep, "active", G_SETTINGS_BIND_DEFAULT);
	GtkFileChooser *blorb_chooser = GTK_FILE_CHOOSER( load_object("blorb_file_chooser") );
	GtkFileChooser *css_chooser = GTK_FILE_CHOOSER( load_object("css-filechooser") );
	char *filename;
	g_settings_get(prefs_settings, "resource-path", "ms", &filename);
	if(filename) {
		gtk_file_chooser_set_filename(blorb_chooser, filename);
		g_free(filename);
	}
	g_settings_get(prefs_settings, "css-file", "ms", &filename);
	if(filename) {
		if(!chimara_glk_set_css_from_file(glk, filename, NULL)) {
			/* If the setting didn't point to a CSS file, fail silently and
			 null the setting */
			g_settings_set(prefs_settings, "css-file", "ms", NULL);
		} else {
			gtk_file_chooser_set_filename(css_chooser, filename);
		}
		g_free(filename);
	}

	/* Populate the list of available interpreters */
	GtkListStore *interp_list = GTK_LIST_STORE( load_object("available_interpreters") );
	unsigned int count;
	GtkTreeIter tree_iter;
	for(count = 0; count < CHIMARA_IF_NUM_INTERPRETERS; count++) {
		gtk_list_store_append(interp_list, &tree_iter);
		gtk_list_store_set(interp_list, &tree_iter,
			0, interpreter_to_display_string(count),
			-1);
	}

	/* Get the list of preferred interpreters from the preferences */
	GVariantIter *iter;
	char *format, *plugin;
	g_settings_get(prefs_settings, "preferred-interpreters", "a{ss}", &iter);
	while(g_variant_iter_loop(iter, "{ss}", &format, &plugin)) {
		ChimaraIFFormat format_num = parse_format(format);
		if(format_num == CHIMARA_IF_FORMAT_NONE)
			continue;
		ChimaraIFInterpreter interp_num = parse_interpreter(plugin);
		if(interp_num == CHIMARA_IF_INTERPRETER_NONE)
			continue;
		chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), format_num, interp_num);
	}
	g_variant_iter_free(iter);

	/* Display it all in the list */
	preferred_list = GTK_LIST_STORE( load_object("interpreters") );
	for(count = 0; count < CHIMARA_IF_NUM_FORMATS; count++) {
		gtk_list_store_append(preferred_list, &tree_iter);
		gtk_list_store_set(preferred_list, &tree_iter,
			0, format_to_display_string(count),
			1, interpreter_to_display_string(chimara_if_get_preferred_interpreter(CHIMARA_IF(glk), count)),
			-1);
	}
}
Example #17
0
void
on_style_remove_clicked(GtkButton *button, I7App *app)
{
	GtkTreeSelection *selection = gtk_tree_view_get_selection(app->prefs->schemes_view);
	GtkTreeModel *model;
	GtkTreeIter iter;
	if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
		gchar *id;
		gchar *name;
		gtk_tree_model_get(model, &iter,
			ID_COLUMN, &id,
			NAME_COLUMN, &name,
			-1);

		if(!i7_app_uninstall_color_scheme(app, id))
			error_dialog(GTK_WINDOW(app->prefs->window), NULL, _("Could not remove color scheme \"%s\"."), name);
		else {
			gchar *new_id = NULL;
			GtkTreeIter new_iter;
			gboolean new_iter_set = FALSE;

			/* If the removed style scheme is the last of the list, set as new
			 default style scheme the previous one, otherwise set the next one.
			 To make this possible, we need to get the id of the new default
			 style scheme before re-populating the list. */
			GtkTreePath *path = gtk_tree_model_get_path(model, &iter);
			/* Try to move to the next path */
			gtk_tree_path_next(path);
			if(!gtk_tree_model_get_iter(model, &new_iter, path)) {
				/* It seems the removed style scheme was the last of the list.
				 Try to move to the previous one */
				gtk_tree_path_free(path);
				path = gtk_tree_model_get_path(model, &iter);
				gtk_tree_path_prev(path);
				if(gtk_tree_model_get_iter(model, &new_iter, path))
					new_iter_set = TRUE;
			}
			else
				new_iter_set = TRUE;
			gtk_tree_path_free(path);

			if(new_iter_set)
				gtk_tree_model_get(model, &new_iter,
					ID_COLUMN, &new_id,
					-1);

			if(!new_id)
				new_id = g_strdup("inform");

			populate_schemes_list(app->prefs->schemes_list);

			I7App *theapp = i7_app_get();
			GSettings *prefs = i7_app_get_prefs(theapp);
			g_settings_set(prefs, PREFS_STYLE_SCHEME, new_id);

			g_free(new_id);
		}
		g_free(id);
		g_free(name);
	}
}