Beispiel #1
0
void
mc_load_preferences (MCData *mc)
{
    GConfValue *history;
    GError     *error = NULL;

    g_return_if_fail (mc != NULL);
    g_return_if_fail (PANEL_IS_APPLET (mc->applet));

    mc->preferences.show_default_theme =
		panel_applet_gconf_get_bool (mc->applet, "show_default_theme", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.show_default_theme = MC_DEFAULT_SHOW_DEFAULT_THEME;
    }

    mc->preferences.auto_complete_history =
		panel_applet_gconf_get_bool (mc->applet, "autocomplete_history", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.auto_complete_history = MC_DEFAULT_AUTO_COMPLETE_HISTORY;
    }

    mc->preferences.normal_size_x =
		panel_applet_gconf_get_int (mc->applet, "normal_size_x", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.normal_size_x = MC_DEFAULT_NORMAL_SIZE_X;
    }
    mc->preferences.normal_size_x = MAX (mc->preferences.normal_size_x, 50);

    mc->preferences.normal_size_y =
		panel_applet_gconf_get_int (mc->applet, "normal_size_y", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.normal_size_y = MC_DEFAULT_NORMAL_SIZE_Y;
    }
    mc->preferences.normal_size_y = CLAMP (mc->preferences.normal_size_y, 5, 200);

    mc->preferences.cmd_line_color_fg_r =
		panel_applet_gconf_get_int (mc->applet, "cmd_line_color_fg_r", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_fg_r = MC_DEFAULT_CMD_LINE_COLOR_FG_R;
    }

    mc->preferences.cmd_line_color_fg_g =
		panel_applet_gconf_get_int (mc->applet, "cmd_line_color_fg_g", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_fg_g = MC_DEFAULT_CMD_LINE_COLOR_FG_G;
    }

    mc->preferences.cmd_line_color_fg_b =
		panel_applet_gconf_get_int (mc->applet, "cmd_line_color_fg_b", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_fg_b = MC_DEFAULT_CMD_LINE_COLOR_FG_B;
    }

    mc->preferences.cmd_line_color_bg_r =
		panel_applet_gconf_get_int (mc->applet, "cmd_line_color_bg_r", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_bg_r = MC_DEFAULT_CMD_LINE_COLOR_BG_R;
    }

    mc->preferences.cmd_line_color_bg_g =
		panel_applet_gconf_get_int (mc->applet, "cmd_line_color_bg_g", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_bg_g = MC_DEFAULT_CMD_LINE_COLOR_BG_G;
    }

    mc->preferences.cmd_line_color_bg_b =
		panel_applet_gconf_get_int (mc->applet, "cmd_line_color_bg_b", &error);
    if (error) {
	g_error_free (error);
	error = NULL;
	mc->preferences.cmd_line_color_bg_b = MC_DEFAULT_CMD_LINE_COLOR_BG_B;
    }

    mc->preferences.macros = mc_load_macros (mc);

    history = panel_applet_gconf_get_value (mc->applet, "history", NULL);
    if (history) {
        GSList *l;

	for (l = gconf_value_get_list (history); l; l = l->next) {
            const char *entry = NULL;
            
            if ((entry = gconf_value_get_string (l->data)))
                append_history_entry (mc, entry, TRUE);
        }
	
	gconf_value_free (history);
    }

    mc_setup_listeners (mc);

    mc->preferences.idle_macros_loader_id = 0;
}
gboolean
window_list_applet_fill (PanelApplet *applet)
{
	TasklistData *tasklist;
	GError *error;
	GConfValue *value;

	gint sizepref;

	tasklist = g_new0 (TasklistData, 1);

	tasklist->applet = GTK_WIDGET (applet);

	panel_applet_set_flags (PANEL_APPLET (tasklist->applet),
				PANEL_APPLET_EXPAND_MAJOR |
				PANEL_APPLET_EXPAND_MINOR |
				PANEL_APPLET_HAS_HANDLE);

	panel_applet_add_preferences (applet, "/schemas/apps/window_list_applet/prefs", NULL);

	setup_gconf (tasklist);

	error = NULL;
	tasklist->include_all_workspaces = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error);
	if (error) {
		g_error_free (error);
		tasklist->include_all_workspaces = FALSE; /* Default value */
	}

	error = NULL;
	tasklist->grouping = -1;
	value = panel_applet_gconf_get_value (applet, "group_windows", &error);
	if (error) {
		g_error_free (error);
	} else if (value) {
		tasklist->grouping = get_grouping_type (value);
		gconf_value_free (value);
	}
	if (tasklist->grouping < 0)
		tasklist->grouping = WNCK_TASKLIST_AUTO_GROUP; /* Default value */
	
	error = NULL;
	tasklist->move_unminimized_windows = panel_applet_gconf_get_bool (applet, "move_unminimized_windows", &error);
	if (error) {
		g_error_free (error);
		tasklist->move_unminimized_windows = TRUE; /* Default value */
	}

	tasklist->size = panel_applet_get_size (applet);
	switch (panel_applet_get_orient (applet)) {
	case PANEL_APPLET_ORIENT_LEFT:
	case PANEL_APPLET_ORIENT_RIGHT:
		tasklist->orientation = GTK_ORIENTATION_VERTICAL;
		break;
	case PANEL_APPLET_ORIENT_UP:
	case PANEL_APPLET_ORIENT_DOWN:
	default:
		tasklist->orientation = GTK_ORIENTATION_HORIZONTAL;
		break;
	}

	tasklist->screen = wncklet_get_screen (tasklist->applet);

	/* because the tasklist doesn't respond to signals at the moment */
	wnck_screen_force_update (tasklist->screen);

	tasklist->tasklist = wnck_tasklist_new (tasklist->screen);

        wnck_tasklist_set_icon_loader (WNCK_TASKLIST (tasklist->tasklist),
                                       icon_loader_func,
                                       tasklist,
                                       NULL);
        
	/* get size preferences */
	error = NULL;
	sizepref = panel_applet_gconf_get_int (applet, "minimum_size", &error);
	if (error) {
		sizepref = 50; /* Default value */
		g_error_free (error);
	}

	if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL)
		wnck_tasklist_set_minimum_width (WNCK_TASKLIST (tasklist->tasklist), sizepref);	  
	else
		wnck_tasklist_set_minimum_height (WNCK_TASKLIST (tasklist->tasklist), sizepref);	  

	error = NULL;
	sizepref = panel_applet_gconf_get_int (applet, "maximum_size", &error);
	if (error) {
		sizepref = 4096; /* Default value */
		g_error_free (error);
	}

	tasklist->maximum_size = sizepref;

	g_signal_connect (G_OBJECT (tasklist->tasklist), "destroy",
			  G_CALLBACK (destroy_tasklist),
			  tasklist);

	g_signal_connect (G_OBJECT (tasklist->applet), "size_request",
			  G_CALLBACK (applet_size_request),
			  tasklist);
	tasklist_update (tasklist);
	gtk_widget_show (tasklist->tasklist);

	gtk_container_add (GTK_CONTAINER (tasklist->applet), tasklist->tasklist);

	g_signal_connect (G_OBJECT (tasklist->applet),
			  "realize",
			  G_CALLBACK (applet_realized),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_orient",
			  G_CALLBACK (applet_change_orient),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_size",
			  G_CALLBACK (applet_change_pixel_size),
			  tasklist);
	g_signal_connect (G_OBJECT (tasklist->applet),
			  "change_background",
			  G_CALLBACK (applet_change_background),
			  tasklist);

	panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet),
					    GTK_WIDGET (tasklist->applet));
	
	panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet),
					   NULL,
					   "GNOME_WindowListApplet.xml",
					   NULL,
					   tasklist_menu_verbs, 
					   tasklist);

	if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) {
		BonoboUIComponent *popup_component;

		popup_component = panel_applet_get_popup_component (PANEL_APPLET (tasklist->applet));

		bonobo_ui_component_set_prop (popup_component,
					      "/commands/TasklistPreferences",
					      "hidden", "1",
					      NULL);
	}

	gtk_widget_show (tasklist->applet);
	
	return TRUE;
}