Пример #1
0
static int _new_config(Panel * panel)
{
	char * filename;

	if((panel->config = config_new()) == NULL)
		return -1;
	if((filename = _config_get_filename()) == NULL)
		return -1;
	config_load(panel->config, filename); /* we can ignore errors */
	free(filename);
	return 0;
}
Пример #2
0
/* panel_init */
static int _panel_init(Panel * panel, PanelWindowPosition position,
		PanelWindowType type, GtkIconSize iconsize)
{
	const PanelPosition top = PANEL_POSITION_TOP;
	char * filename;
	GdkRectangle rect;
	size_t i;

	if((panel->config = config_new()) == NULL)
		return -1;
	if((filename = _config_get_filename()) != NULL
			&& config_load(panel->config, filename) != 0)
		error_print(PROGNAME);
	free(filename);
	panel->prefs.iconsize = NULL;
	panel->prefs.monitor = -1;
	/* root window */
	panel->screen = gdk_screen_get_default();
	panel->root = gdk_screen_get_root_window(panel->screen);
	gdk_screen_get_monitor_geometry(panel->screen, 0, &rect);
	panel->root_height = rect.height;
	panel->root_width = rect.width;
	/* panel window */
	_helper_init(&panel->helper[top], panel, type, iconsize);
	panel->windows[top] = panel_window_new(&panel->helper[top],
			PANEL_WINDOW_TYPE_NORMAL, position, iconsize, &rect);
	panel->helper[top].window = panel->windows[top];
	for(i = 0; i < sizeof(panel->windows) / sizeof(*panel->windows); i++)
		if(i != top)
			panel->windows[i] = NULL;
	panel->source = 0;
	panel->timeout = 0;
	panel->ab_window = NULL;
	panel->lk_window = NULL;
	panel->lo_window = NULL;
	panel->sh_window = NULL;
	panel->su_window = NULL;
	return 0;
}
Пример #3
0
static void _preferences_on_ok(gpointer data)
{
	Panel * panel = data;
	gint i;
	gint cnt = sizeof(_panel_sizes) / sizeof(*_panel_sizes);
	GtkTreeModel * model;
	GtkTreeIter iter;
	gboolean valid;
	gchar * p;
	String * value;
	String * sep;
	char * filename;
	GtkWidget * widget;
	PanelAppletDefinition * pad;
	PanelApplet * pa;

	gtk_widget_hide(panel->pr_window);
	/* general */
	config_set(panel->config, NULL, "accept_focus",
			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
					panel->pr_accept_focus)) ? "1" : "0");
	config_set(panel->config, NULL, "keep_above",
			gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
					panel->pr_keep_above)) ? "1" : "0");
	/* top panel */
	if((i = gtk_combo_box_get_active(GTK_COMBO_BOX(panel->pr_top_size)))
			>= 0 && i <= cnt)
		config_set(panel->config, NULL, "top_size", (i > 0)
				? _panel_sizes[i - 1].name : NULL);
	model = GTK_TREE_MODEL(panel->pr_top_store);
	value = NULL;
	sep = "";
	for(valid = gtk_tree_model_get_iter_first(model, &iter); valid == TRUE;
			valid = gtk_tree_model_iter_next(model, &iter))
	{
		gtk_tree_model_get(model, &iter, 0, &p, -1);
		string_append(&value, sep);
		string_append(&value, p);
		sep = ",";
		g_free(p);
	}
	config_set(panel->config, NULL, "top", value);
	string_delete(value);
	/* bottom panel */
	if((i = gtk_combo_box_get_active(GTK_COMBO_BOX(panel->pr_bottom_size)))
			>= 0 && i <= cnt)
		config_set(panel->config, NULL, "bottom_size", (i > 0)
				? _panel_sizes[i - 1].name : NULL);
	model = GTK_TREE_MODEL(panel->pr_bottom_store);
	value = NULL;
	sep = "";
	for(valid = gtk_tree_model_get_iter_first(model, &iter); valid == TRUE;
			valid = gtk_tree_model_iter_next(model, &iter))
	{
		gtk_tree_model_get(model, &iter, 0, &p, -1);
		string_append(&value, sep);
		string_append(&value, p);
		sep = ",";
		g_free(p);
	}
	config_set(panel->config, NULL, "bottom", value);
	string_delete(value);
	/* XXX applets should be known from Panel already */
	cnt = gtk_notebook_get_n_pages(GTK_NOTEBOOK(panel->pr_notebook));
	for(i = 1; i < cnt; i++)
	{
		widget = gtk_notebook_get_nth_page(GTK_NOTEBOOK(
					panel->pr_notebook), i);
		if(widget == NULL || (pad = g_object_get_data(G_OBJECT(widget),
						"definition")) == NULL
				|| (pa = g_object_get_data(G_OBJECT(widget),
						"applet")) == NULL)
			continue;
		pad->settings(pa, TRUE, FALSE);
	}
	if((filename = _config_get_filename()) != NULL)
		config_save(panel->config, filename);
	free(filename);
}