A
download distribution.c
Language: C
Copyright: (C) 2000 The Free Software Foundation
LOC: 73
Project Info
gnome-core
Server: Gnome
Type: cvs
...nome‑core\gnome‑core\panel\
   .cvsignore
   aligned-widget.c
   aligned-widget.h
   applet.c
   applet.h
   basep-widget.c
   basep-widget.h
   border-widget.c
   border-widget.h
   button-widget.c
   button-widget.h
   distribution.c
   distribution.h
   drawer-widget.c
   drawer-widget.h
   drawer.c
   drawer.h
   edge-widget.c
   edge-widget.h
   floating-widget.c
   floating-widget.h
   foobar-widget.c
   foobar-widget.h
   global-keys.c
   global-keys.h
   gnome-panel-add-launcher.c
   gnome-panel-properties.c
   ...l-properties.desktop.in
   ...-panel-properties.glade
   gnome-panel-screenshot.c
   ...-panel-screenshot.glade
   gnome-run.c
   gnome-run.h
   GNOME_Panel.server.in
   launcher.c
   launcher.h
   logout.c
   logout.h
   main.c
   Makefile.am
   menu-fentry.c
   menu-fentry.h
   menu-properties.c
   menu-properties.h
   menu-util.c
   menu-util.h
   menu.c
   menu.h
   multiscreen-stuff.c
   multiscreen-stuff.h
   nothing.cP
   nothing.h
   panel-applet-frame.c
   panel-applet-frame.h
   panel-config-global.h
   panel-config.c
   panel-config.h
   panel-gconf.c
   panel-gconf.h
   ...l-global-config.schemas
   panel-main.h
   panel-marshal.list
   ...er-panel-config.schemas
   panel-shell.c
   panel-shell.h
   panel-types.h
   panel-util.c
   panel-util.h
   panel-widget.c
   panel-widget.h
   panel.c
   panel.h
   panel.hints
   quick-desktop-reader.c
   quick-desktop-reader.h
   rgb-stuff.c
   rgb-stuff.h
   session.c
   session.h
   sliding-widget.c
   sliding-widget.h
   status-docklet.c
   status-docklet.h
   status.c
   status.h
   swallow.c
   swallow.h
   TODO.old
   xstuff.c
   xstuff.h

/*
 * GNOME panel linux distribution module.
 * (C) 2000 The Free Software Foundation
 *
 * Authors: Martin Baulig <baulig@suse.de>
 */

#include <config.h>

#include <libgnome/libgnome.h>

#include "distribution.h"
#include "menu.h"
#include "menu-fentry.h"

/* Note for distribution vendors:
 *
 * This file - especially the `distribution_info' array - is
 * the only place which you need to custumize in order to make
 * the `Distribution' menu in the panel working.
 *
 */

static DistributionInfo distribution_info [] = {
	{ DISTRIBUTION_DEBIAN, "/etc/debian_version",
	  N_("Debian GNU/Linux"), N_("Debian menus"),
	  "gnome-debian.png", "/var/lib/gnome/Debian/.",
	  NULL, NULL
	},
	{ DISTRIBUTION_SUSE, "/etc/SuSE-release",
	  N_("SuSE Linux"), N_("SuSE menus"), "gnome-suse.png",
	  "gnome/distribution-menus/SuSE/.",
	  NULL, NULL
	},
	{ DISTRIBUTION_SOLARIS, "/var/sadm/pkg/SUNWdtcor",
	 N_("Solaris"), N_("CDE Menus"), "gnome-gmenu.png", "cdemenu:/",
	 NULL, NULL
	},
	{ DISTRIBUTION_UNKNOWN, NULL, NULL, NULL, NULL }
};

static DistributionType
internal_get_distribution_type (void)
{
	DistributionInfo *ptr;

	for (ptr = distribution_info; ptr->type != DISTRIBUTION_UNKNOWN; ptr++)
		if (g_file_test (ptr->version_file, G_FILE_TEST_EXISTS))
			return ptr->type;

	return DISTRIBUTION_UNKNOWN;
}

static DistributionInfo *
internal_get_distribution_info (DistributionType type)
{
	DistributionInfo *ptr;

	for (ptr = distribution_info; ptr->type != DISTRIBUTION_UNKNOWN; ptr++)
		if (ptr->type == type)
			return ptr;

	return NULL;
}

/* note that this function is marked G_GNUC_CONST in distribution.h */
DistributionType
get_distribution_type (void)
{
	static gboolean cached = FALSE;
	static DistributionType cache = DISTRIBUTION_UNKNOWN;

	if (cached) {
		return cache;
	}

	cache = internal_get_distribution_type ();
	cached = TRUE;

	return cache;
}

/* note that this function is marked G_GNUC_CONST in distribution.h */
const DistributionInfo *
get_distribution_info (void)
{
	static gboolean cached = FALSE;
	static DistributionInfo *cache = NULL;
	DistributionType type;

	if (cached) {
		return cache;
	}

	type = get_distribution_type ();

	cache = internal_get_distribution_info (type);
	cached = TRUE;

	if (cache && cache->menu_path && !g_path_is_absolute (cache->menu_path)) {
		char *full_path;

		full_path = gnome_program_locate_file (
				NULL, GNOME_FILE_DOMAIN_DATADIR, cache->menu_path, TRUE, NULL);
		if (full_path)
			cache->menu_path = full_path;
	}

	return cache;
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us