gchar *
gst_validate_media_info_to_string (GstValidateMediaInfo * mi, gsize * length)
{
  GKeyFile *kf = g_key_file_new ();
  gchar *data = NULL;
  gchar *str;

  /* file info */
  g_key_file_set_string (kf, "file-info", "uri", mi->uri);
  g_key_file_set_uint64 (kf, "file-info", "file-size", mi->file_size);

  /* media info */
  g_key_file_set_uint64 (kf, "media-info", "file-duration", mi->duration);
  g_key_file_set_boolean (kf, "media-info", "seekable", mi->seekable);
  g_key_file_set_boolean (kf, "media-info", "is-image", mi->is_image);

  if (mi->stream_info && mi->stream_info->caps) {
    str = gst_caps_to_string (mi->stream_info->caps);
    g_key_file_set_string (kf, "media-info", "caps", str);
    g_free (str);
  }

  /* playback tests */
  g_key_file_set_string (kf, "playback-tests", "playback-error",
      mi->playback_error ? mi->playback_error : "");
  g_key_file_set_string (kf, "playback-tests", "reverse-playback-error",
      mi->reverse_playback_error ? mi->reverse_playback_error : "");
  g_key_file_set_string (kf, "playback-tests", "track-switch-error",
      mi->track_switch_error ? mi->track_switch_error : "");

  data = g_key_file_to_data (kf, length, NULL);
  g_key_file_free (kf);

  return data;
}
예제 #2
0
파일: config_file.c 프로젝트: ukleinek/rauc
static void status_file_set_slot_status(GKeyFile *key_file, const gchar *group, RaucSlotStatus *slotstatus)
{
	status_file_set_string_or_remove_key(key_file, group, "bundle.compatible", slotstatus->bundle_compatible);
	status_file_set_string_or_remove_key(key_file, group, "bundle.version", slotstatus->bundle_version);
	status_file_set_string_or_remove_key(key_file, group, "bundle.description", slotstatus->bundle_description);
	status_file_set_string_or_remove_key(key_file, group, "bundle.build", slotstatus->bundle_build);
	status_file_set_string_or_remove_key(key_file, group, "status", slotstatus->status);

	if (slotstatus->checksum.digest && slotstatus->checksum.type == G_CHECKSUM_SHA256) {
		g_key_file_set_string(key_file, group, "sha256", slotstatus->checksum.digest);
		g_key_file_set_uint64(key_file, group, "size", slotstatus->checksum.size);
	} else {
		g_key_file_remove_key(key_file, group, "sha256", NULL);
		g_key_file_remove_key(key_file, group, "size", NULL);
	}

	if (slotstatus->installed_timestamp) {
		g_key_file_set_string(key_file, group, "installed.timestamp", slotstatus->installed_timestamp);
		g_key_file_set_uint64(key_file, group, "installed.count", slotstatus->installed_count);
	} else {
		g_key_file_remove_key(key_file, group, "installed.timestamp", NULL);
		g_key_file_remove_key(key_file, group, "installed.count", NULL);
	}

	if (slotstatus->activated_timestamp) {
		g_key_file_set_string(key_file, group, "activated.timestamp", slotstatus->activated_timestamp);
		g_key_file_set_uint64(key_file, group, "activated.count", slotstatus->activated_count);
	} else {
		g_key_file_remove_key(key_file, group, "activated.timestamp", NULL);
		g_key_file_remove_key(key_file, group, "activated.count", NULL);
	}

	return;
}
예제 #3
0
// save all stored preferences to file
void save_preferences (char *filepad) {
    gchar *data;
    gsize len;
	GString *label = g_string_new_len("", 20);
	int i;

    g_key_file_set_double (settings, "display", "opacity", 		conf.opacity);
    g_key_file_set_string (settings, "display", "font", 		conf.font);
    g_key_file_set_integer (settings, "display", "x", 			conf.x);
    g_key_file_set_integer (settings, "display", "y", 			conf.y);
    g_key_file_set_integer (settings, "display", "lx", 			conf.lx);
    g_key_file_set_integer (settings, "display", "ly", 			conf.ly);
    g_key_file_set_integer (settings, "display", "dx", 			conf.dx);
    g_key_file_set_integer (settings, "display", "dy", 			conf.dy);
	g_key_file_set_boolean (settings, "display", "tooltips", 	conf.tips);
    g_key_file_set_string (settings, "reader", "device", 		conf.device);
    g_key_file_set_integer (settings, "reader", "speed", 		conf.speed);
    g_key_file_set_uint64 (settings, "reader", "lijnkleur", 	conf.lijnkleur);
    g_key_file_set_uint64 (settings, "reader", "rasterkleur", 	conf.rasterkleur);
    g_key_file_set_boolean (settings, "reader", "raster", 		conf.raster);
	g_key_file_set_boolean (settings, "reader", "speech", 		conf.speech);
	g_key_file_set_integer (settings, "reader", "voice",		conf.voice);
    g_key_file_set_integer (settings, "keys", "paste0",			conf.paste[0]);
    g_key_file_set_integer (settings, "keys", "paste1",			conf.paste[1]);
    g_key_file_set_integer (settings, "keys", "backspace0",		conf.backspace[0]);
    g_key_file_set_integer (settings, "keys", "backspace1",		conf.backspace[1]);

	g_key_file_set_integer (settings, "GB1", "key",			conf.keymode[0].key);
    g_key_file_set_integer (settings, "GB1", "mode",		conf.keymode[0].mode);
    g_key_file_set_integer (settings, "BIG5", "key",		conf.keymode[1].key);
    g_key_file_set_integer (settings, "BIG5", "mode",		conf.keymode[1].mode);
    g_key_file_set_integer (settings, "DIGITS", "key", 		conf.keymode[2].key);
    g_key_file_set_integer (settings, "DIGITS", "mode", 	conf.keymode[2].mode);
    g_key_file_set_integer (settings, "LOWERCASE", "key", 	conf.keymode[3].key);
    g_key_file_set_integer (settings, "LOWERCASE", "mode", 	conf.keymode[3].mode);
    g_key_file_set_integer (settings, "UPPERCASE", "key", 	conf.keymode[4].key);
    g_key_file_set_integer (settings, "UPPERCASE", "mode",	conf.keymode[4].mode);
    g_key_file_set_integer (settings, "PUNC", "key",		conf.keymode[5].key);
    g_key_file_set_integer (settings, "PUNC", "mode",		conf.keymode[5].mode);
    g_key_file_set_integer (settings, "DEFAULT", "key",		conf.keymode[6].key);
    g_key_file_set_integer (settings, "DEFAULT", "mode", 	conf.keymode[6].mode);

	for (i=0; i<13; i++) {
		g_string_sprintf(label, "key%d", i+1);
		g_key_file_set_integer (settings, "keydefs", label->str, conf.defkey[i].key);
		g_string_sprintf(label, "label%d", i+1);
		g_key_file_set_string (settings, "keydefs", label->str, conf.defkey[i].label);
	}

    data = g_key_file_to_data (settings, &len, NULL);
    g_file_set_contents (filepad, data, len, NULL);

    g_string_free(label, TRUE);
    g_free(data);
}
예제 #4
0
void PluginInfoCache::updatePluginInfo(const String& pluginPath, const PluginModuleInfo& plugin)
{
    time_t lastModified;
    if (!WebCore::getFileModificationTime(pluginPath, lastModified))
        return;

    CString pluginGroup = pluginPath.utf8();
    g_key_file_set_uint64(m_cacheFile.get(), pluginGroup.data(), "mtime", static_cast<guint64>(lastModified));
    g_key_file_set_string(m_cacheFile.get(), pluginGroup.data(), "name", plugin.info.name.utf8().data());
    g_key_file_set_string(m_cacheFile.get(), pluginGroup.data(), "description", plugin.info.desc.utf8().data());

#if PLUGIN_ARCHITECTURE(X11)
    String mimeDescription = NetscapePluginModule::buildMIMEDescription(plugin.info.mimes);
    g_key_file_set_string(m_cacheFile.get(), pluginGroup.data(), "mime-description", mimeDescription.utf8().data());
#endif

    g_key_file_set_boolean(m_cacheFile.get(), pluginGroup.data(), "requires-gtk2", plugin.requiresGtk2);

    if (m_cachePath && !m_readOnlyMode) {
        // Save the cache file in an idle to make sure it happens in the main thread and
        // it's done only once when this is called multiple times in a very short time.
        std::lock_guard<std::mutex> lock(m_mutex);
        if (m_saveToFileIdle.isScheduled())
            return;

        m_saveToFileIdle.schedule("[WebKit] PluginInfoCache::saveToFile", std::bind(&PluginInfoCache::saveToFile, this), G_PRIORITY_DEFAULT_IDLE);
    }
}
예제 #5
0
bool state_write(const struct piiptyyt_state *st, GError **err_p)
{
	const char *path = state_path();
	int fd = open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
	if(fd == -1) {
		g_set_error(err_p, 0, errno, "open(2) failed: %s",
			g_strerror(errno));
		return false;
	}
	int n = fchmod(fd, 0600);
	if(n == -1) {
		g_set_error(err_p, 0, errno, "fchmod(2) failed: %s",
			g_strerror(errno));
		close(fd);
		return false;
	}

	GKeyFile *kf = g_key_file_new();
	g_key_file_set_string(kf, "auth", "username", st->username);
	g_key_file_set_string(kf, "auth", "auth_token", st->auth_token);
	g_key_file_set_string(kf, "auth", "auth_secret", st->auth_secret);
	g_key_file_set_uint64(kf, "auth", "userid", st->userid);

	gsize length = 0;
	gchar *contents = g_key_file_to_data(kf, &length, err_p);
	g_key_file_free(kf);

	/* FIXME: this should be re-engineered to write into a temporary file in
	 * the same directory with the appropriate mode, and then rename that file
	 * on top of the old file when the initial write has succeeded.
	 *
	 * i.e. this bit should be a function of its own.
	 */
	bool ret = false;
	if(contents != NULL) {
		off_t nn = lseek(fd, 0, SEEK_SET);
		if(nn == (off_t)-1) {
			/* FIXME: handle */
		}
		n = ftruncate(fd, length);
		if(n == -1) {
			/* FIXME: handle */
		}
		ssize_t n_wr = write(fd, contents, length);
		if(n_wr == -1) {
			/* FIXME: handle */
		} else if(n_wr != length) {
			/* FIXME: handle */
		} else {
			ret = true;
		}
		g_free(contents);
	}

	close(fd);
	return ret;
}
예제 #6
0
/**
 * fm_folder_config_set_uint64
 * @fc: a configuration descriptor
 * @key: a key to search
 * @val: data to set
 *
 * Associates unsigned integer @val with @key for given folder configuration.
 *
 * Since: 1.2.0
 */
void fm_folder_config_set_uint64(FmFolderConfig *fc, const char *key, guint64 val)
{
    fc->changed = TRUE;
#if GLIB_CHECK_VERSION(2, 26, 0)
    g_key_file_set_uint64(fc->kf, fc->group, key, val);
#else
    gchar *result = g_strdup_printf("%" G_GUINT64_FORMAT, val);
    g_key_file_set_value(fc->kf, fc->group, key, result);
    g_free(result);
#endif
}
예제 #7
0
/*
 * Set a new maximum total size for the map tile cache.
 */
void
ph_config_set_max_tile_cache_size(const GValue *value)
{
    g_return_if_fail(ph_config != NULL);
    g_return_if_fail(value == NULL || G_VALUE_HOLDS_UINT(value));

    if (value != NULL)
        g_key_file_set_uint64(ph_config->key_file, "tile-cache", "max-size",
                              g_value_get_uint(value));
    else
        g_key_file_remove_key(ph_config->key_file, "tile-cache", "max-size",
                              NULL);
}
예제 #8
0
/*
 * Set a configuration setting to the content of a GValue.
 */
static void
ph_config_set_value(const gchar *group,
                    const gchar *key,
                    const GValue *value)
{
    switch (G_VALUE_TYPE(value)) {
    case G_TYPE_UINT:
        g_key_file_set_uint64(ph_config->key_file, group, key,
                g_value_get_uint(value));
        break;
    case G_TYPE_STRING:
        g_key_file_set_string(ph_config->key_file, group, key,
                g_value_get_string(value));
        break;
    default:
        g_return_if_reached();
    }
}
예제 #9
0
// load preferences from file
void load_preferences (char *filepad) {
    char txt[100];
    GString *label = g_string_new_len("", 20);
    int i, p, choice = -1;
    GdkDevice *device, *nodevice;
    GList *list;
    TS keus;

    if (settings == NULL) settings = g_key_file_new();
    if (g_key_file_load_from_file(settings, filepad, G_KEY_FILE_NONE, NULL) == FALSE) {	// set defaults
        gchar *data;
        gsize len;

		// default settings when xpen.cfg not found
		g_key_file_set_integer (settings, "display", "x", -1);
		g_key_file_set_integer (settings, "display", "y", -1);
		g_key_file_set_integer (settings, "display", "lx", -1);
		g_key_file_set_integer (settings, "display", "ly", -1);
		g_key_file_set_integer (settings, "display", "dx", 300);
		g_key_file_set_integer (settings, "display", "dy", 400);
        g_key_file_set_double (settings, "display", "opacity", 0.7);
        g_key_file_set_string (settings, "display", "font", gtk_font_button_get_font_name(GTK_FONT_BUTTON(fontbutton)));
        g_key_file_set_boolean (settings, "display", "tooltips", TRUE);
        g_key_file_set_string (settings, "reader", "device", "stylus");
        g_key_file_set_integer (settings, "reader", "speed", 6);
        g_key_file_set_uint64 (settings, "reader", "lijnkleur", 0x514942);
        g_key_file_set_uint64 (settings, "reader", "rasterkleur", 0xAB8C6D);
        g_key_file_set_boolean (settings, "reader", "raster", TRUE);
        g_key_file_set_boolean (settings, "reader", "speech", FALSE);
        g_key_file_set_string (settings, "reader", "command", "aplay -q");
        g_key_file_set_integer (settings, "reader", "voice", 0);
        g_key_file_set_integer (settings, "keys", "paste0", 37);
        g_key_file_set_integer (settings, "keys", "paste1", 55);
        g_key_file_set_integer (settings, "keys", "backspace0", 0);
        g_key_file_set_integer (settings, "keys", "backspace1", 22);

        g_key_file_set_integer (settings, "GB1", "key", 0);
        g_key_file_set_integer (settings, "GB1", "mode", 0);
        g_key_file_set_integer (settings, "BIG5", "key", CTRL_R);
        g_key_file_set_integer (settings, "BIG5", "mode", BIG5);
        g_key_file_set_integer (settings, "DIGITS", "key", ALT_L);
        g_key_file_set_integer (settings, "DIGITS", "mode", DIGITS);
        g_key_file_set_integer (settings, "LOWERCASE", "key", ALT_L);
        g_key_file_set_integer (settings, "LOWERCASE", "mode", LOWERCASE);
        g_key_file_set_integer (settings, "UPPERCASE", "key", 0);
        g_key_file_set_integer (settings, "UPPERCASE", "mode", 0);
        g_key_file_set_integer (settings, "PUNC", "key", 0);
        g_key_file_set_integer (settings, "PUNC", "mode", 0);
        g_key_file_set_integer (settings, "DEFAULT", "key", ESC);
        g_key_file_set_integer (settings, "DEFAULT", "mode", (GB1|GB2|DIGITS));

		g_key_file_set_string (settings, "keydefs", "label1", "Control-Left");
		g_key_file_set_integer (settings, "keydefs", "key1", CTRL_L);
		g_key_file_set_string (settings, "keydefs", "label2", "Control-Right");
		g_key_file_set_integer (settings, "keydefs", "key2", CTRL_R);
		g_key_file_set_string (settings, "keydefs", "label3", "Shift-Left");
		g_key_file_set_integer (settings, "keydefs", "key3", SHIFT_L);
		g_key_file_set_string (settings, "keydefs", "label4", "Shift-Right");
		g_key_file_set_integer (settings, "keydefs", "key4", SHIFT_R);
		g_key_file_set_string (settings, "keydefs", "label5", "Alt-Left");
		g_key_file_set_integer (settings, "keydefs", "key5", ALT_L);
		g_key_file_set_string (settings, "keydefs", "label6", "Alt-Right");
		g_key_file_set_integer (settings, "keydefs", "key6", ALT_R);
		g_key_file_set_string (settings, "keydefs", "label7", "Escape");
		g_key_file_set_integer (settings, "keydefs", "key7", ESC);
		g_key_file_set_string (settings, "keydefs", "label8", "Caps-Lock");
		g_key_file_set_integer (settings, "keydefs", "key8", CAPS);
		g_key_file_set_string (settings, "keydefs", "label9", "Num-Lock");
		g_key_file_set_integer (settings, "keydefs", "key9", NUMS);
		g_key_file_set_string (settings, "keydefs", "label10", "Scroll-Lock");
		g_key_file_set_integer (settings, "keydefs", "key10", SCROLLS);
		g_key_file_set_string (settings, "keydefs", "label11", "Pause/Break");
		g_key_file_set_integer (settings, "keydefs", "key11", PAUSE);
		g_key_file_set_string (settings, "keydefs", "label12", "not set");
		g_key_file_set_integer (settings, "keydefs", "key12", 0);
		g_key_file_set_string (settings, "keydefs", "label13", "not set");
		g_key_file_set_integer (settings, "keydefs", "key13", 0);

        data = g_key_file_to_data (settings, &len, NULL);	// save defaults
        g_file_set_contents (filepad, data, len, NULL);
        g_free(data);
    }
    // fill the preferences structure
    conf.x 				= g_key_file_get_integer (settings, "display", "x", NULL);
    conf.y 				= g_key_file_get_integer (settings, "display", "y", NULL);
    conf.lx 			= g_key_file_get_integer (settings, "display", "lx", NULL);
    conf.ly 			= g_key_file_get_integer (settings, "display", "ly", NULL);
    conf.dx 			= g_key_file_get_integer (settings, "display", "dx", NULL);
    conf.dy 			= g_key_file_get_integer (settings, "display", "dy", NULL);
    conf.opacity 		= g_key_file_get_double (settings, "display", "opacity", NULL);
    conf.tips			= g_key_file_get_boolean (settings, "display", "tooltips", NULL);
    conf.font 			= g_key_file_get_string (settings, "display", "font", NULL);
    conf.device 		= g_key_file_get_string (settings, "reader", "device", NULL);
    conf.speed 			= g_key_file_get_integer (settings, "reader", "speed", NULL);
    conf.lijnkleur		= g_key_file_get_uint64 (settings, "reader", "lijnkleur", NULL);
    conf.rasterkleur	= g_key_file_get_uint64 (settings, "reader", "rasterkleur", NULL);
    conf.raster 		= g_key_file_get_boolean (settings, "reader", "raster", NULL);
	conf.speech 		= g_key_file_get_boolean (settings, "reader", "speech", NULL);
	conf.voice	 		= g_key_file_get_integer (settings, "reader", "voice", NULL);
    conf.paste[0] 		= g_key_file_get_integer (settings, "keys", "paste0", NULL);
    conf.paste[1] 		= g_key_file_get_integer (settings, "keys", "paste1", NULL);
    conf.backspace[0]	= g_key_file_get_integer (settings, "keys", "backspace0", NULL);
    conf.backspace[1]	= g_key_file_get_integer (settings, "keys", "backspace1", NULL);
    conf.keymode[0].key	= g_key_file_get_integer (settings, "GB1", "key", NULL);
	conf.keymode[0].mode	= g_key_file_get_integer (settings, "GB1", "mode", NULL);
    conf.keymode[1].key	= g_key_file_get_integer (settings, "BIG5", "key", NULL);
	conf.keymode[1].mode	= g_key_file_get_integer (settings, "BIG5", "mode", NULL);
	conf.keymode[2].key	= g_key_file_get_integer (settings, "DIGITS", "key", NULL);
	conf.keymode[2].mode	= g_key_file_get_integer (settings, "DIGITS", "mode", NULL);
    conf.keymode[3].key	= g_key_file_get_integer (settings, "LOWERCASE", "key", NULL);
	conf.keymode[3].mode	= g_key_file_get_integer (settings, "LOWERCASE", "mode", NULL);
    conf.keymode[4].key	= g_key_file_get_integer (settings, "UPPERCASE", "key", NULL);
	conf.keymode[4].mode	= g_key_file_get_integer (settings, "UPPERCASE", "mode", NULL);
    conf.keymode[5].key	= g_key_file_get_integer (settings, "PUNC", "key", NULL);
	conf.keymode[5].mode	= g_key_file_get_integer (settings, "PUNC", "mode", NULL);
    conf.keymode[6].key	= g_key_file_get_integer (settings, "DEFAULT", "key", NULL);
	conf.keymode[6].mode	= g_key_file_get_integer (settings, "DEFAULT", "mode", NULL);

	// set speech + command
	GTK_TOGGLE_BUTTON(checkbutton9)->active = conf.speech;

	gtk_combo_box_set_active(GTK_COMBO_BOX(combobox1), conf.voice);

	for (i=0; i<13; i++) {
		g_string_sprintf(label, "key%d", i+1);
		conf.defkey[i].key = g_key_file_get_integer (settings, "keydefs", label->str, NULL);
		g_string_sprintf(label, "label%d", i+1);
		conf.defkey[i].label = g_key_file_get_string (settings, "keydefs", label->str, NULL);
	}

	// start setting all widgets with the values from the configuration (conf)

	// set tooltips
    GTK_TOGGLE_BUTTON(checkbutton8)->active = conf.tips;

	// set the 13 buttons/entries in preferences
	for (i=0; i<13; i++) {
		if (conf.defkey[i].key > 0) {
			g_string_sprintf(label, "key = %d", conf.defkey[i].key);
			gtk_button_set_label(GTK_BUTTON(conf.defkey[i].button), label->str);
			gtk_entry_set_text(GTK_ENTRY(conf.defkey[i].entry), conf.defkey[i].label);
		} else {
			gtk_button_set_label(GTK_BUTTON(conf.defkey[i].button), "not set");
			gtk_entry_set_text(GTK_ENTRY(conf.defkey[i].entry), "");
		}
	}
	g_string_free(label, TRUE);

	// set the default recognition mode
	mode = conf.keymode[6].mode;
	keus = (mode & BIG5) ? Traditional : Simplified;
	selecteer(keus);

	// set the labels of the hotkeys (preferences)
	for (i=0; i<7; i++) {
		bool found;

		hotkey[conf.keymode[i].key] |= conf.keymode[i].mode;		// set the hotkeys
		found = FALSE;
		for (p=0; p<13; p++) {
			if (conf.defkey[p].key > 0) {
				if (conf.keymode[i].key == conf.defkey[p].key) {
					strcpy(txt, conf.defkey[p].label);
					found = TRUE;
					break;
				}
			}
		}
		if (found == FALSE) {
			if (conf.keymode[i].key > 0)
				sprintf(txt, "key = %d", conf.keymode[i].key);
			else
				strcpy(txt, "not set");
		}
		gtk_button_set_label(GTK_BUTTON(modebits[i].button), txt);

		// set the default checkboxes (preferences)
		if (conf.keymode[6].mode & GB1)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(modebits[0].check), TRUE);
		if (conf.keymode[6].mode & BIG5)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(modebits[1].check), TRUE);
		if (conf.keymode[6].mode & DIGITS)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(modebits[2].check), TRUE);
		if (conf.keymode[6].mode & LOWERCASE)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(modebits[3].check), TRUE);
		if (conf.keymode[6].mode & UPPERCASE)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(modebits[4].check), TRUE);
		if (conf.keymode[6].mode & PUNC)
			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(modebits[5].check), TRUE);
	}

    // fill combobox with input-devices
    list = gdk_devices_list();
    device = (GdkDevice *) list->data;	// default device
    nodevice = NULL;
    for (p=0; list->next; p++) {
        strcpy(txt, gdk_device_get_name((GdkDevice *)list->data));
        gtk_combo_box_append_text(GTK_COMBO_BOX(combo), txt);
        if (strstr(txt, conf.device)) {
            device = (GdkDevice *) list->data;
            choice = p;
        }
        nodevice = (GdkDevice *) list->data;
        list = list->next;
    }
    if (choice == -1) {		// prefered device not found
		choice = p-1;
		device = nodevice;
    }

    //g_list_free(list);
    gtk_combo_box_set_active(GTK_COMBO_BOX(combo), choice);
    gdk_device_set_source (device, GDK_SOURCE_PEN);
    gdk_device_set_mode(device, GDK_MODE_SCREEN);

    // set line color
    lijnkleur.pixel = conf.lijnkleur;
    sprintf(txt, "#%.6X", lijnkleur.pixel);
    gdk_color_parse(txt, &lijnkleur);
    gtk_color_button_set_color(GTK_COLOR_BUTTON(colorbutton1),  &lijnkleur);

    // set raster color
    rasterkleur.pixel = conf.rasterkleur;
    sprintf(txt, "#%.6X", rasterkleur.pixel);
    gdk_color_parse(txt, &rasterkleur);
    gtk_color_button_set_color(GTK_COLOR_BUTTON(colorbutton2),  &rasterkleur);

    // set raster on/off check button
    GTK_TOGGLE_BUTTON(checkbutton1)->active = conf.raster;

    // set main window opacity slider
    gtk_adjustment_set_value(opacity, conf.opacity);

    // set the 9 candidate buttons with a default font
    for (i=0; i< 9; i++) {
		PangoFontDescription *pfont;
    	pfont = pango_font_description_from_string(conf.font);
        gtk_widget_modify_font (GTK_WIDGET(knop[i]), pfont );
        pango_font_description_free(pfont);
    }

    // set the font selection button with the font title
    gtk_font_button_set_font_name(GTK_FONT_BUTTON(fontbutton), conf.font);

    // set the recognize speed slider
    gtk_adjustment_set_value(speed, conf.speed);
    WTSetSpeed(conf.speed);

    // set the default paste and backspace entry fields
    gtk_entry_set_text(GTK_ENTRY(entry1), key2string(conf.paste[1], conf.paste[0]));
    gtk_entry_set_text(GTK_ENTRY(entry2), key2string(conf.backspace[1], conf.backspace[0]));
}
예제 #10
0
파일: repoconf.c 프로젝트: mruprich/librepo
gboolean
lr_yum_repoconf_setopt(LrYumRepoConf *repoconf,
                       GError **err,
                       LrYumRepoConfOption option,
                       ...)
{
    GError *tmp_err = NULL;
    va_list arg;

    char *str;
    char **strv;
    long lnum;

    assert(!err || *err == NULL);

    if (!repoconf) {
        g_set_error(err, LR_REPOCONF_ERROR, LRE_BADFUNCARG,
                    "No config specified");
        return FALSE;
    }

    // Shortcuts
    LrYumRepoFile *repofile = repoconf_repofile(repoconf);
    GKeyFile *keyfile = repoconf_keyfile(repoconf);
    gchar *id = repoconf_id(repoconf);

    // Basic sanity checks
    if (!keyfile) {
        g_set_error(err, LR_REPOCONF_ERROR, LRE_BADFUNCARG,
                    "No keyfile available in yumrepoconf");
        return FALSE;
    }

    va_start(arg, option);

    switch (option) {

    case LR_YRC_ID:              /*!<  0 (char *) ID (short name) of the repo */
        g_set_error(&tmp_err, LR_REPOCONF_ERROR, LRE_BADOPTARG,
                    "ID is read only option");
        break;

    case LR_YRC_NAME:            /*!<  1 (char *) Pretty name of the repo */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "name", str);
        break;

    case LR_YRC_ENABLED:         /*!<  2 (long 1 or 0) Is repo enabled? */
        lnum = va_arg(arg, long);
        g_key_file_set_boolean(keyfile, id, "enabled", lnum ? TRUE : FALSE);
        break;

    case LR_YRC_BASEURL:         /*!<  3 (char **) List of base URLs */
        strv = va_arg(arg, char **);
        lr_key_file_set_string_list(keyfile, id, "baseurl", (const gchar **) strv);
        break;

    case LR_YRC_MIRRORLIST:      /*!<  4 (char *) Mirrorlist URL */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "mirrorlist", str);
        break;

    case LR_YRC_METALINK:        /*!<  5 (char *) Metalink URL */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "metalink", str);
        break;

    case LR_YRC_MEDIAID:         /*!<  6 (char *) Media ID */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "mediaid", str);
        break;

    case LR_YRC_GPGKEY:          /*!<  7 (char **) URL of GPG key */
        strv = va_arg(arg, char **);
        lr_key_file_set_string_list(keyfile, id, "gpgkey", (const gchar **) strv);
        break;

    case LR_YRC_GPGCAKEY:        /*!<  8 (char **) GPG CA key */
        strv = va_arg(arg, char **);
        lr_key_file_set_string_list(keyfile, id, "gpgcakey", (const gchar **) strv);
        break;

    case LR_YRC_EXCLUDE:         /*!<  9 (char **) List of exluded packages */
        strv = va_arg(arg, char **);
        lr_key_file_set_string_list(keyfile, id, "exclude", (const gchar **) strv);
        break;

    case LR_YRC_INCLUDE:         /*!< 10 (char **) List of included packages */
        strv = va_arg(arg, char **);
        lr_key_file_set_string_list(keyfile, id, "include", (const gchar **) strv);
        break;

    case LR_YRC_FASTESTMIRROR:   /*!< 11 (long 1 or 0) Fastest mirror determination */
        lnum = va_arg(arg, long);
        g_key_file_set_boolean(keyfile, id, "fastestmirror", lnum);
        break;

    case LR_YRC_PROXY:           /*!< 12 (char *) Proxy addres */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "proxy", str);
        break;

    case LR_YRC_PROXY_USERNAME:  /*!< 13 (char *) Proxy username */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "proxy_username", str);
        break;

    case LR_YRC_PROXY_PASSWORD:  /*!< 14 (char *) Proxy password */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "proxy_password", str);
        break;

    case LR_YRC_USERNAME:        /*!< 15 (char *) Username */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "username", str);
        break;

    case LR_YRC_PASSWORD:        /*!< 16 (char *) Password */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "password", str);
        break;

    case LR_YRC_GPGCHECK:        /*!< 17 (long 1 or 0) GPG check for packages */
        lnum = va_arg(arg, long);
        g_key_file_set_boolean(keyfile, id, "gpgcheck", (gboolean) lnum);
        break;

    case LR_YRC_REPO_GPGCHECK:   /*!< 18 (long 1 or 0) GPG check for repodata */
        lnum = va_arg(arg, long);
        g_key_file_set_boolean(keyfile, id, "repo_gpgcheck", (gboolean) lnum);
        break;

    case LR_YRC_ENABLEGROUPS:    /*!< 19 (long 1 or 0) Use groups */
        lnum = va_arg(arg, long);
        g_key_file_set_boolean(keyfile, id, "enablegroups", (gboolean) lnum);
        break;

    case LR_YRC_BANDWIDTH:       /*!< 20 (guint64) Bandwidth - Number of bytes */
    {
        guint64 val = va_arg(arg, guint64);
        g_key_file_set_uint64(keyfile, id, "bandwidth", val);
        break;
    }

    case LR_YRC_THROTTLE:        /*!< 21 (char *) Throttle string */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "throttle", str);
        break;

    case LR_YRC_IP_RESOLVE:      /*!< 22 (LrIpResolveType) Ip resolve type */
    {
        LrIpResolveType val = va_arg(arg, LrIpResolveType);
        lr_key_file_set_ip_resolve(keyfile, id, "ip_resolve", val);
        break;
    }

    case LR_YRC_METADATA_EXPIRE: /*!< 23 (gint64) Interval in secs for metadata expiration */
    {
        // TODO: Store value in appropriate units
        gint64 val = va_arg(arg, gint64);
        g_key_file_set_int64(keyfile, id, "metadata_expire", val);
        break;
    }

    case LR_YRC_COST:            /*!< 24 (gint) Repo cost */
    {
        gint val = va_arg(arg, gint);
        g_key_file_set_integer(keyfile, id, "cost", val);
        break;
    }

    case LR_YRC_PRIORITY:        /*!< 25 (gint) Repo priority */
    {
        guint val = va_arg(arg, gint);
        g_key_file_set_integer(keyfile, id, "priority", val);
        break;
    }

    case LR_YRC_SSLCACERT:       /*!< 26 (gchar *) SSL Certification authority cert */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "sslcacert", str);
        break;

    case LR_YRC_SSLVERIFY:       /*!< 27 (long 1 or 0) SSL verification */
        lnum = va_arg(arg, long);
        g_key_file_set_boolean(keyfile, id, "sslverify", (gboolean) lnum);
        break;

    case LR_YRC_SSLCLIENTCERT:   /*!< 28 (gchar *) SSL Client certificate */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "sslclientcert", str);
        break;

    case LR_YRC_SSLCLIENTKEY:    /*!< 29 (gchar *) SSL Client key */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "sslclientkey", str);
        break;

    case LR_YRC_DELTAREPOBASEURL:/*!< 30 (char **) Deltarepo mirror URLs */
        strv = va_arg(arg, char **);
        lr_key_file_set_string_list(keyfile, id, "deltarepobaseurl", (const gchar **) strv);
        break;

    case LR_YRC_FAILOVERMETHOD:   /*!< 31 (gchar *) Failover method */
        str = va_arg(arg, char *);
        lr_key_file_set_string(keyfile, id, "failovermethod", str);
        break;

    case LR_YRC_SKIP_IF_UNAVAILABLE: /*!< 32 (long 1 or 0) Skip if unavailable */
        lnum = va_arg(arg, long);
        g_key_file_set_boolean(keyfile, id, "skip_if_unavailable", (gboolean) lnum);
        break;
    }

    va_end(arg);

    if (tmp_err) {
        g_propagate_error(err, tmp_err);
        return FALSE;
    }

    repofile_set_modified(repofile, TRUE);

    return TRUE;
}
예제 #11
0
void configure_program_dialog(GtkWidget *widget, gpointer user_data) {

  /** Program configuration dailog window. **/

  #ifdef DEBUG
  DEBUG_FUNC_MARK
  #endif

  GtkWidget *configure_dialog = gtk_dialog_new() ;



  gtk_window_set_icon_from_file(GTK_WINDOW(configure_dialog), PATH_TO_PRG_WIN_ICON, NULL) ;
  gtk_window_set_title(GTK_WINDOW(configure_dialog), "Configure program") ;
  gtk_window_set_position(GTK_WINDOW(configure_dialog), GTK_WIN_POS_CENTER_ALWAYS) ;
  gtk_window_set_resizable(GTK_WINDOW(configure_dialog), FALSE);
  gtk_widget_set_size_request(configure_dialog,-1,-1) ;
  gtk_window_set_modal(GTK_WINDOW(configure_dialog), FALSE) ;
  gtk_window_set_destroy_with_parent(GTK_WINDOW(configure_dialog), TRUE) ;
  gtk_window_set_decorated(GTK_WINDOW(configure_dialog), TRUE) ;

  gtk_window_set_type_hint(GTK_WINDOW(configure_dialog), GDK_WINDOW_TYPE_HINT_NORMAL) ;
  gtk_window_set_transient_for(GTK_WINDOW(configure_dialog), GTK_WINDOW(gui->window)) ;

  gtk_container_set_border_width(GTK_CONTAINER(configure_dialog), 12) ;


  #define DIALOG_DEFAULT_SPACE 12


  /** ***** [START] Icon set choice [START] ***** **/

  GtkWidget *icon_set_choice_frame = gtk_frame_new(" Icon set ") ;


  GtkWidget *icon_set_choice_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(icon_set_choice_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_box_set_spacing(GTK_BOX(icon_set_choice_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_box_set_homogeneous(GTK_BOX(icon_set_choice_hbox), TRUE) ;


  GtkWidget *radiobutton_icons_high_contrast = gtk_radio_button_new_with_label(NULL, " HighContrast") ;

  GtkWidget *image_icons_high_contrast       ;

  GtkWidget *radiobutton_icons_oxygen        = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radiobutton_icons_high_contrast)), " Oxygen") ;

  GtkWidget *image_icons_oxygen              ;


  gtk_widget_set_tooltip_markup(radiobutton_icons_high_contrast, "Set the <b>HighContrast</b> theme icon set.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(radiobutton_icons_oxygen,        "Set the <b>Oxygen</b> theme icon set.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(radiobutton_icons_high_contrast), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(radiobutton_icons_oxygen),        FALSE) ;


  if (settings.icon_set_oxygen) {

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_icons_oxygen), TRUE) ;

    image_icons_high_contrast = gtk_image_new_from_file( PATH_TO_HIGH_CONTRAST_BUTTON_ICONS  "face-angry.png")     ;

    image_icons_oxygen        = gtk_image_new_from_file( PATH_TO_OXYGEN_BUTTON_ICONS         "face-smile-big.png") ;

  }
  else {

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radiobutton_icons_high_contrast), TRUE) ;

    image_icons_high_contrast = gtk_image_new_from_file( PATH_TO_HIGH_CONTRAST_BUTTON_ICONS  "face-smile-big.png") ;

    image_icons_oxygen        = gtk_image_new_from_file( PATH_TO_OXYGEN_BUTTON_ICONS         "face-angry.png")     ;

  }


  gtk_button_set_image(GTK_BUTTON(radiobutton_icons_high_contrast), image_icons_high_contrast) ;

  gtk_button_set_always_show_image(GTK_BUTTON(radiobutton_icons_high_contrast), TRUE) ;

  gtk_button_set_image(GTK_BUTTON(radiobutton_icons_oxygen), image_icons_oxygen) ;

  gtk_button_set_always_show_image(GTK_BUTTON(radiobutton_icons_oxygen), TRUE)   ;





  gtk_box_pack_start(GTK_BOX(icon_set_choice_hbox), radiobutton_icons_high_contrast, TRUE,  TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(icon_set_choice_hbox), radiobutton_icons_oxygen,        TRUE,  TRUE, 0) ;

  gtk_container_add(GTK_CONTAINER(icon_set_choice_frame), icon_set_choice_hbox) ;

  /** ***** [END] Icon set choice [END] ***** **/



  /** ***** [START] Playing settings [START] ***** **/

  GtkWidget *playing_settings_frame = gtk_frame_new(" Player settings ") ;


  GtkWidget *playing_settings_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(playing_settings_vbox), DIALOG_DEFAULT_SPACE) ;



  GtkWidget *playing_settings_repeat_all = gtk_check_button_new_with_label(" Repeat all mode. ") ;

  gtk_widget_set_tooltip_markup(playing_settings_repeat_all, "Enable the <b>repeat all</b> feature.\nThis will update the player settings.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(playing_settings_repeat_all), is_repeat_all) ;



  GtkWidget *playing_settings_shuffle = gtk_check_button_new_with_label(" Shuffle mode. ") ;

  gtk_widget_set_tooltip_markup(playing_settings_shuffle, "Enable the <b>shuffle</b> feature.\nThis will update the player settings.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(playing_settings_shuffle), is_shuffle ) ;

  GtkWidget *playing_settings_volume_hbox  = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;



  GtkWidget *playing_settings_volume_label_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  GtkWidget *playing_settings_volume_image      = gtk_image_new_from_file( (settings.path_to_button_icons + "audio-volume-medium.png").c_str() ) ;

  GtkWidget *playing_settings_volume_label      = gtk_label_new(" Default Volume:") ;

  gtk_box_pack_start(GTK_BOX(playing_settings_volume_label_hbox), playing_settings_volume_image, FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(playing_settings_volume_label_hbox), playing_settings_volume_label, FALSE, FALSE, 0) ;


  GtkWidget *playing_settings_volume_scale = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1.0) ;



  gtk_widget_set_tooltip_markup(playing_settings_volume_scale, "Set the <b>default player volume</b> at start.\nThis will <b>not</b> update the player settings.\nYou must press the <b>Apply</b> button to store your configuration.") ;

  gtk_range_set_value(GTK_RANGE(playing_settings_volume_scale), settings.volume) ;

  gtk_scale_set_draw_value(GTK_SCALE(playing_settings_volume_scale), TRUE) ;
  gtk_scale_set_has_origin(GTK_SCALE(playing_settings_volume_scale), TRUE) ;

  gtk_scale_set_value_pos(GTK_SCALE(playing_settings_volume_scale), GTK_POS_TOP) ;

  gtk_scale_add_mark(GTK_SCALE(playing_settings_volume_scale), 50.0, GTK_POS_TOP, NULL) ;



  gtk_box_pack_start(GTK_BOX(playing_settings_volume_hbox), playing_settings_volume_label_hbox, FALSE,  FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(playing_settings_volume_hbox), playing_settings_volume_scale,      TRUE,   TRUE,  0) ;



  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_repeat_all,               FALSE, FALSE, 0)   ;
  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_shuffle,                  FALSE, FALSE, 0)   ;
  gtk_box_pack_start(GTK_BOX(playing_settings_vbox), playing_settings_volume_hbox,              FALSE, FALSE, 0)   ;

  gtk_container_add(GTK_CONTAINER(playing_settings_frame), playing_settings_vbox) ;

  /** ***** [END] Playing settings [END] ***** **/



  /** ***** [START] Interface size setting [START] ***** **/

  GtkWidget *interface_size_frame = gtk_frame_new(" Interface size ") ;

  GtkWidget *interface_size_hbox  = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(interface_size_hbox), DIALOG_DEFAULT_SPACE) ;

  GtkWidget *interface_size_radiobutton_little = gtk_radio_button_new_with_label(NULL, " Little") ;
  GtkWidget *interface_size_radiobutton_middle = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(interface_size_radiobutton_little)), " Medium") ;
  GtkWidget *interface_size_radiobutton_big    = gtk_radio_button_new_with_label(gtk_radio_button_get_group(GTK_RADIO_BUTTON(interface_size_radiobutton_little)), "  Big  ") ;

  GtkWidget *interface_size_little_image       = gtk_image_new_from_file((settings.path_to_button_icons + "interface-little.png").c_str() ) ;
  GtkWidget *interface_size_middle_image       = gtk_image_new_from_file((settings.path_to_button_icons + "interface-middle.png").c_str() ) ;
  GtkWidget *interface_size_big_image          = gtk_image_new_from_file((settings.path_to_button_icons + "interface-big.png").c_str()    ) ;

  gtk_widget_set_tooltip_markup(interface_size_radiobutton_little, "Set the <b>interface size</b> on <b>little</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(interface_size_radiobutton_middle, "Set the <b>interface size</b> on <b>middle</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.") ;
  gtk_widget_set_tooltip_markup(interface_size_radiobutton_big,    "Set the <b>interface size</b> on <b>big</b>.\nThis will update the interface.\nBut you must press the <b>Apply</b> button to store your configuration.")    ;

  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_little), interface_size_little_image) ;
  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_middle), interface_size_middle_image) ;
  gtk_button_set_image(GTK_BUTTON(interface_size_radiobutton_big),    interface_size_big_image   ) ;

  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_little), TRUE) ;
  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_middle), TRUE) ;
  gtk_button_set_always_show_image(GTK_BUTTON(interface_size_radiobutton_big),    TRUE) ;

  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_little), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_middle), FALSE) ;
  gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(interface_size_radiobutton_big),    FALSE) ;


  switch (settings.image_resized_size) {

    case IMAGE_RESIZED_SIZE_LITTLE :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_little), TRUE) ;
      break ;

    case IMAGE_RESIZED_SIZE_MIDDLE :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_middle), TRUE) ;
      break ;

    case IMAGE_RESIZED_SIZE_BIG :

      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(interface_size_radiobutton_big),    TRUE) ;
      break ;

    default :
      break ;
  }


  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_little, TRUE, TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_middle, TRUE, TRUE, 0) ;
  gtk_box_pack_start(GTK_BOX(interface_size_hbox), interface_size_radiobutton_big,    TRUE, TRUE, 0) ;

  gtk_box_set_homogeneous(GTK_BOX(interface_size_hbox), TRUE) ;

  gtk_box_set_spacing(GTK_BOX(interface_size_hbox), DIALOG_DEFAULT_SPACE) ;

  gtk_container_add(GTK_CONTAINER(interface_size_frame), interface_size_hbox) ;

  /** ***** [END] Interface size setting [END] ***** **/



  /** ***** [START] Music folder setting [START] ***** **/

  GtkWidget *folder_selecting_frame = gtk_frame_new(" Music folder ") ;

  GtkWidget *folder_selecting_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0) ;

  gtk_container_set_border_width(GTK_CONTAINER(folder_selecting_box), DIALOG_DEFAULT_SPACE) ;


  GtkWidget *folder_selecting_button = gtk_file_chooser_button_new("Set the Music folder to open per default.", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) ;

  gtk_widget_set_tooltip_markup(folder_selecting_button, "Set the folder to open per default: your <b>default music folder</b>.\n<i>The default folder from the folder selector</i>.\nSet it simply to your <b>Music folder</b>.\nChanges are immediatly applied.\nBut you must press the <b>Apply</b> button to store your configuration.") ;

  gtk_file_chooser_button_set_title(GTK_FILE_CHOOSER_BUTTON(folder_selecting_button), "Set the Music folder to open per default.") ;

  const char *user_music_folder = g_get_user_special_dir(G_USER_DIRECTORY_MUSIC) ;

  gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(folder_selecting_button), (g_file_test(settings.path_to_music_folder.c_str(), G_FILE_TEST_IS_DIR)) ? settings.path_to_music_folder.c_str() : (user_music_folder != NULL) ? user_music_folder : g_get_home_dir()  ) ;


  gtk_box_pack_start(GTK_BOX(folder_selecting_box), folder_selecting_button,  TRUE, TRUE, 0)   ;

  gtk_container_add(GTK_CONTAINER(folder_selecting_frame), folder_selecting_box) ;

  /** ***** [END] Music folder setting [END] ***** **/



  /** ***** [START] Dialog main content box [START] ***** **/

  GtkWidget *content_area = gtk_dialog_get_content_area( GTK_DIALOG(configure_dialog) ) ;

  gtk_box_pack_start(GTK_BOX(content_area), icon_set_choice_frame,  FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), playing_settings_frame, FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), interface_size_frame,   FALSE, FALSE, 0) ;
  gtk_box_pack_start(GTK_BOX(content_area), folder_selecting_frame, FALSE, FALSE, 0) ;

  gtk_box_set_spacing(GTK_BOX(content_area), DIALOG_DEFAULT_SPACE) ;

  /** ***** [END] Dialog main content box [END] ***** **/



  /** ***** [START] Dialog action buttons [START] ***** **/

  GtkWidget *button_close = gtk_button_new_with_label("Close") ; // gtk_dialog_add_button(GTK_DIALOG(configure_dialog), "Cancel", GTK_RESPONSE_CANCEL) ;

  GtkWidget *image_close  = gtk_image_new_from_file((settings.path_to_button_icons + "dialog-close.png").c_str()) ;

  gtk_widget_set_tooltip_markup(button_close, "<b>Close</b> the configuration window and don't store any setting.") ;

  gtk_button_set_image(GTK_BUTTON(button_close), image_close) ;

  gtk_button_set_always_show_image(GTK_BUTTON(button_close), TRUE) ;


  GtkWidget *button_ok = gtk_button_new_with_label("Apply") ; // gtk_dialog_add_button(GTK_DIALOG(configure_dialog), "Apply", GTK_RESPONSE_APPLY) ;

  GtkWidget *image_ok  = gtk_image_new_from_file((settings.path_to_button_icons + "dialog-ok.png").c_str()) ;

  gtk_widget_set_tooltip_markup(button_ok, "<b>Register</b> all the settings as <i>your default configuration</i> at start.") ;

  gtk_button_set_image(GTK_BUTTON(button_ok), image_ok) ;

  gtk_button_set_always_show_image(GTK_BUTTON(button_ok), TRUE) ;


  gtk_dialog_add_action_widget(GTK_DIALOG(configure_dialog), button_close, GTK_RESPONSE_CLOSE) ;

  gtk_dialog_add_action_widget(GTK_DIALOG(configure_dialog), button_ok,     GTK_RESPONSE_APPLY)  ;

  GtkWidget *action_area = gtk_dialog_get_action_area(GTK_DIALOG(configure_dialog)) ;

  gtk_container_set_border_width(GTK_CONTAINER(action_area), 0) ;

  gtk_button_box_set_layout(GTK_BUTTON_BOX(action_area), GTK_BUTTONBOX_EDGE) ;

  /** ***** [END] Dialog action buttons [END] ***** **/



  Radio_Config high_contrast_radiobutton ;

  high_contrast_radiobutton.button  = radiobutton_icons_high_contrast ;
  high_contrast_radiobutton.image   = image_icons_high_contrast       ;

  high_contrast_radiobutton.volume  = playing_settings_volume_image       ;
  high_contrast_radiobutton.cancel  = image_close    ;
  high_contrast_radiobutton.apply   = image_ok       ;

  high_contrast_radiobutton.little  = interface_size_little_image ;
  high_contrast_radiobutton.middle  = interface_size_middle_image ;
  high_contrast_radiobutton.big     = interface_size_big_image    ;


  Radio_Config oxygen_radiobutton ;

  oxygen_radiobutton.button  = radiobutton_icons_oxygen ;
  oxygen_radiobutton.image   = image_icons_oxygen       ;

  oxygen_radiobutton.volume  = playing_settings_volume_image       ;
  oxygen_radiobutton.cancel  = image_close    ;
  oxygen_radiobutton.apply   = image_ok       ;

  oxygen_radiobutton.little  = interface_size_little_image ;
  oxygen_radiobutton.middle  = interface_size_middle_image ;
  oxygen_radiobutton.big     = interface_size_big_image    ;

  g_signal_connect(G_OBJECT(radiobutton_icons_high_contrast), "clicked", G_CALLBACK(configure_high_contrast_radiobutton), &high_contrast_radiobutton) ;
  g_signal_connect(G_OBJECT(radiobutton_icons_oxygen),        "clicked", G_CALLBACK(configure_oxygen_radiobutton),        &oxygen_radiobutton       ) ;


  int little = -1 ;
  int middle =  0 ;
  int big    =  1 ;

  g_signal_connect(G_OBJECT(interface_size_radiobutton_little), "clicked",       G_CALLBACK(reconfigure_interface_size), &little) ;
  g_signal_connect(G_OBJECT(interface_size_radiobutton_middle), "clicked",       G_CALLBACK(reconfigure_interface_size), &middle) ;
  g_signal_connect(G_OBJECT(interface_size_radiobutton_big),    "clicked",       G_CALLBACK(reconfigure_interface_size), &big)    ;


  g_signal_connect(G_OBJECT(playing_settings_repeat_all),       "toggled",       G_CALLBACK(repeat_all_feature_set),     NULL)    ;
  g_signal_connect(G_OBJECT(playing_settings_shuffle),          "toggled",       G_CALLBACK(shuffle_feature_set),        NULL)    ;
  g_signal_connect(G_OBJECT(playing_settings_volume_scale),     "value-changed", G_CALLBACK(get_volume),                 NULL)    ;
  g_signal_connect(G_OBJECT(folder_selecting_button),           "file-set",      G_CALLBACK(set_default_folder),         NULL)    ;


  gtk_widget_show_all(configure_dialog) ;



  int response = gtk_dialog_run(GTK_DIALOG(configure_dialog))  ;

  switch (response) {

    case GTK_RESPONSE_APPLY :

      {

        GKeyFile *conf_file = g_key_file_new() ;

        GError *error = NULL ;

        settings.is_repeat_all = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(playing_settings_repeat_all)) ;

        settings.is_shuffle       = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(playing_settings_shuffle))    ;



        // Set configuration settings to configuration file buffer.
        g_key_file_set_string(conf_file,   "Config",  "Buttons_Icons_Path",   settings.path_to_button_icons.c_str()) ;

        g_key_file_set_string(conf_file,   "Config",  "Menu_Icons_Path",      settings.path_to_menu_icons.c_str())   ;

        g_key_file_set_string(conf_file,   "Config",  "Music_Folder",         settings.path_to_music_folder.c_str())   ;

        g_key_file_set_boolean(conf_file,  "Config",  "Is_Oxygen",            settings.icon_set_oxygen) ;
        g_key_file_set_boolean(conf_file,  "Config",  "Repeat_all",           settings.is_repeat_all)  ;
        g_key_file_set_boolean(conf_file,  "Config",  "Shuffle",              settings.is_shuffle) ;

        g_key_file_set_double(conf_file,   "Config",  "Volume",               settings.volume) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Buttons_space",        settings.space_buttons) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Display_Size",         settings.display_size) ;

        g_key_file_set_uint64(conf_file,   "Config",  "Image_Resizing",       settings.image_resized_size) ;

        g_key_file_set_string(conf_file,   "Config",  "Sized_Default_Image",  settings.path_to_default_image.c_str())   ;

        // Write to configuration file
        g_key_file_save_to_file(conf_file, PATH_TO_CONF_FILE, &error);

        // Setting global variables.
        cover_image    = settings.path_to_default_image ;
        current_folder = settings.path_to_music_folder ;

        if ( error != NULL ) {

          display_message_dialog("Error store configuration !", "Cannot store the configuration.") ;

          #ifdef DEBUG
          fprintf(stdout,"\n%s: Error store configuratiom settings.\n", prgname.c_str() )    ; fflush(stdout) ;
          #endif
        }
        else { // Success
          #ifdef DEBUG
          fprintf(stdout,"\n%s: Success store configuratiom settings.\n", prgname.c_str() )  ;
          #endif
        }

      }

      break ;

    case GTK_RESPONSE_CLOSE :
      // Do nothing.
      break ;
  }

  gtk_widget_destroy(configure_dialog) ;

  return ;

}
예제 #12
0
파일: hlfs_mkfs.c 프로젝트: baibaibai/hlfs
/*  mkfs.lhfs -l http://<path>  -s name */
int main(int argc, char *argv[])
{
	if (log4c_init()) {
		g_message("log4c_init failed!");
	}
    GError *error = NULL;
    GOptionContext *context;
    context = g_option_context_new("- mkfs hlfs");
    g_option_context_add_main_entries(context, entries, NULL);
    g_option_context_set_help_enabled(context, TRUE);
    g_option_group_set_error_hook(g_option_context_get_main_group(context),
            					(GOptionErrorFunc)error_func);
    if (!g_option_context_parse(context, &argc, &argv, &error)) {
        g_message("option parsing failed: %s", error->message);
        exit(EXIT_FAILURE);
    }

    //g_print("location is :%s\n",location);
    //g_print("fsname   is :%s\n",fsname);
    //g_print("block size   is :%d\n",block_size);
    //g_print("segment size   is :%d\n",seg_size);

//  seg_size = SEGMENT_SIZE;
    if(seg_size <= 0 ||  seg_size%(1024*1024)!=0){
       g_message("segsize <=0 or segment size must 1M margin");
       return -1;
    }
    if(block_size <=0 || block_size%(512) != 0){
       g_message("blocksize <=0 or block size must 512 margin");
       return -1;
    }
    if(max_fs_size <=0){
       g_message("max fs size <=0");
       return -1;
    }
    struct back_storage *storage = init_storage_handler(uri);
    if(NULL ==storage){
       g_message("can not get storage handler for uri:%s",uri);
       g_option_context_free(context);
       return -1;
    }
    
    if((0==storage->bs_file_is_exist(storage,NULL)) && (0==storage->bs_file_is_exist(storage,"superblock"))){
        g_message("hlfs with uri:%s has exist",uri);
        g_option_context_free(context);
        return 1;
    }
    if( 0!=storage->bs_file_mkdir(storage,NULL)){
        g_message("can not mkdir for our fs %s",uri);
        g_option_context_free(context);
        return -1;
    }

    GKeyFile *sb_keyfile= g_key_file_new();
    g_key_file_set_string(sb_keyfile,"METADATA","uri",uri);
    g_key_file_set_integer(sb_keyfile,"METADATA","block_size",block_size);
    g_key_file_set_integer(sb_keyfile,"METADATA","segment_size",seg_size);
    g_key_file_set_uint64(sb_keyfile,"METADATA","max_fs_size",max_fs_size);
    gchar *data = g_key_file_to_data(sb_keyfile,NULL,NULL);
    g_message("key file data :%s",data);
    char *head,*hostname,*dir,*fs_name;
    int port;
    parse_from_uri(uri,&head,&hostname,&dir,&fs_name,&port);
    char *sb_file_path = g_build_filename(dir,fs_name,"superblock",NULL);
    g_message("sb file path %s",sb_file_path);
    bs_file_t file = storage->bs_file_create(storage,"superblock");
    g_message("sb file path 1%s",sb_file_path);
    //bs_file_t file = storage->bs_file_open(storage,"superblock",BS_WRITEABLE);
    if (NULL == file) {
       g_message("open file :superblock failed");
       g_free(sb_file_path);
       g_option_context_free(context);
       return -1;
    }

    g_message("sb file path 2%s",sb_file_path);
    int size = storage->bs_file_append(storage, file,(char*)data,strlen(data)+1);
    if(size != strlen(data)+1){
       g_message("can not write superblock file");
       g_free(sb_file_path);
       g_option_context_free(context);
       return -1;
    }
    g_message("append size:%d",size);
    storage->bs_file_flush(storage,file);
    storage->bs_file_close(storage,file);
    deinit_storage_handler(storage);
    if (log4c_fini()) {
	    g_message("log4c_fini failed!");
    }
    return 0;
}