re-write to use libgnome-menu to load the contents of the preferences
2004-11-10 Mark McLoughlin <mark@skynet.ie> * control-center-categories.[ch]: re-write to use libgnome-menu to load the contents of the preferences menu. * control-center.c: (relayout_canvas), (get_x), (get_y), (get_entry), (get_line_length): update for control-center-categories.[ch] changes. (activate_entry): load the .desktop file and launch. (create_window), (main): remove all nautilus and bonobo stuff. * gnome-control-center.png: rename from control-center2.png. * gnomecc.desktop.in: update for new icon name. * GNOME_ControlCenter.server.in: remove, we're not a Nautilus view anymore. * active.png, bcg_top.png, bg.png, bgtop.png, blank.png, ccsplash.png, empty.png, foot.png, gnome-lockscreen.png, gnome-unlockscreen.png, gnomecc-ui.xml, html-view.xpm, kill-gnomecc.sh, left.png, left_top.png, title.png, tree-view.xpm: Remove what seems to be a big bunch of cruft. * Makefile.am: remove cruft, install new icon, don't link aganst libnautilus.
|
@ -1,3 +1,31 @@
|
|||
2004-11-10 Mark McLoughlin <mark@skynet.ie>
|
||||
|
||||
* control-center-categories.[ch]: re-write to use libgnome-menu
|
||||
to load the contents of the preferences menu.
|
||||
|
||||
* control-center.c:
|
||||
(relayout_canvas), (get_x), (get_y), (get_entry),
|
||||
(get_line_length): update for control-center-categories.[ch] changes.
|
||||
(activate_entry): load the .desktop file and launch.
|
||||
(create_window), (main): remove all nautilus and bonobo stuff.
|
||||
|
||||
* gnome-control-center.png: rename from control-center2.png.
|
||||
|
||||
* gnomecc.desktop.in: update for new icon name.
|
||||
|
||||
* GNOME_ControlCenter.server.in: remove, we're not a Nautilus view
|
||||
anymore.
|
||||
|
||||
* active.png, bcg_top.png, bg.png, bgtop.png,
|
||||
blank.png, ccsplash.png, empty.png, foot.png,
|
||||
gnome-lockscreen.png, gnome-unlockscreen.png,
|
||||
gnomecc-ui.xml, html-view.xpm, kill-gnomecc.sh,
|
||||
left.png, left_top.png, title.png, tree-view.xpm:
|
||||
Remove what seems to be a big bunch of cruft.
|
||||
|
||||
* Makefile.am: remove cruft, install new icon, don't link
|
||||
aganst libnautilus.
|
||||
|
||||
2004-11-09 Mark McLoughlin <mark@skynet.ie>
|
||||
|
||||
* Makefile.am: don't define $(SETTINGS_DIR) - its not
|
||||
|
|
|
@ -1,30 +1,15 @@
|
|||
splashdir = $(datadir)/pixmaps/gnomecc-2
|
||||
splash_DATA = \
|
||||
bcg_top.png \
|
||||
title.png \
|
||||
blank.png \
|
||||
active.png
|
||||
icondir = $(datadir)/icons/hicolor/48x48/apps
|
||||
icon_DATA = gnome-control-center.png
|
||||
|
||||
sysdir = $(datadir)/applications
|
||||
sys_in_files = gnomecc.desktop.in
|
||||
sys_DATA = $(sys_in_files:.desktop.in=.desktop)
|
||||
@INTLTOOL_DESKTOP_RULE@
|
||||
|
||||
serverdir = $(libdir)/bonobo/servers
|
||||
server_in_files = GNOME_ControlCenter.server.in
|
||||
server_DATA = $(server_in_files:.server.in=.server)
|
||||
@INTLTOOL_SERVER_RULE@
|
||||
|
||||
uidir = $(datadir)/gnome-2.0/ui
|
||||
ui_DATA = gnomecc-ui.xml
|
||||
|
||||
INCLUDES = \
|
||||
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
|
||||
-DGNOMECC_ICONS_DIR=\""$(GNOMECC_ICONS_DIR)"\" \
|
||||
-DPIXMAP_DIR=\""$(datadir)/pixmaps"\" \
|
||||
-DART_DIR=\""$(splashdir)"\" \
|
||||
-DGNOME_SBINDIR=\""$(sbindir)"\" \
|
||||
$(GNOMECC_CFLAGS) $(NAUTILUS_CFLAGS)
|
||||
$(GNOMECC_CFLAGS)
|
||||
|
||||
bin_PROGRAMS = gnome-control-center
|
||||
|
||||
|
@ -37,7 +22,7 @@ gnome_control_center_SOURCES = \
|
|||
gnomecc-event-box.c \
|
||||
gnomecc-event-box.h
|
||||
|
||||
gnome_control_center_LDADD = $(GNOMECC_LIBS) $(NAUTILUS_LIBS)
|
||||
gnome_control_center_LDADD = $(GNOMECC_LIBS)
|
||||
|
||||
IMAGES = text-selection-frame.png
|
||||
VARIABLES = \
|
||||
|
@ -45,13 +30,11 @@ VARIABLES = \
|
|||
|
||||
pixbuf_file = $(top_builddir)/control-center/gnomecc-rounded-rect-pixbuf.h
|
||||
pixbuf_file = gnomecc-rounded-rect-pixbuf.h
|
||||
noinst_DATA = $(pixbuf_file)
|
||||
|
||||
$(pixbuf_file) : $(IMAGES)
|
||||
$(GDK_PIXBUF_CSOURCE) --raw --build-list $(VARIABLES) > $@
|
||||
|
||||
EXTRA_DIST = gnomecc.desktop.in $(splash_DATA) $(ui_DATA) $(server_DATA) \
|
||||
$(IMAGES)
|
||||
EXTRA_DIST = gnomecc.desktop.in $(IMAGES)
|
||||
|
||||
BUILT_SOURCES = $(pixbuf_file)
|
||||
CLEANFILES = gnomecc.desktop $(noinst_DATA)
|
||||
DISTCLEANFILES = gnomecc.desktop $(pixbuf_file)
|
||||
|
|
Before Width: | Height: | Size: 121 B |
Before Width: | Height: | Size: 93 B |
Before Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 396 B |
Before Width: | Height: | Size: 88 B |
Before Width: | Height: | Size: 25 KiB |
|
@ -1,10 +1,12 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
|
||||
/* capplet-dir.c
|
||||
/*
|
||||
* Copyright (C) 2004 Red Hat, Inc.
|
||||
* Copyright (C) 2000, 2001 Ximian, Inc.
|
||||
* Copyright (C) 1998 Red Hat Software, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@ximian.com>,
|
||||
* Written by Mark McLoughlin <mark@skynet.ie>
|
||||
* Bradford Hovinen <hovinen@ximian.com>,
|
||||
* Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -27,468 +29,258 @@
|
|||
|
||||
#include "control-center-categories.h"
|
||||
|
||||
#include <gnome.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#define MENU_I_KNOW_THIS_IS_UNSTABLE
|
||||
#include <menu-tree.h>
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
* Stolen from nautilus to keep control center and nautilus in sync
|
||||
*/
|
||||
static gboolean
|
||||
eel_str_has_suffix (const char *haystack, const char *needle)
|
||||
{
|
||||
const char *h, *n;
|
||||
|
||||
if (needle == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
if (haystack == NULL) {
|
||||
return needle[0] == '\0';
|
||||
}
|
||||
|
||||
/* Eat one character at a time. */
|
||||
h = haystack + strlen(haystack);
|
||||
n = needle + strlen(needle);
|
||||
do {
|
||||
if (n == needle) {
|
||||
return TRUE;
|
||||
}
|
||||
if (h == haystack) {
|
||||
return FALSE;
|
||||
}
|
||||
} while (*--h == *--n);
|
||||
return FALSE;
|
||||
}
|
||||
static char *
|
||||
eel_str_strip_trailing_str (const char *source, const char *remove_this)
|
||||
{
|
||||
const char *end;
|
||||
if (source == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (remove_this == NULL) {
|
||||
return g_strdup (source);
|
||||
}
|
||||
end = source + strlen (source);
|
||||
if (strcmp (end - strlen (remove_this), remove_this) != 0) {
|
||||
return g_strdup (source);
|
||||
}
|
||||
else {
|
||||
return g_strndup (source, strlen (source) - strlen(remove_this));
|
||||
}
|
||||
|
||||
}
|
||||
static char *
|
||||
nautilus_remove_icon_file_name_suffix (const char *icon_name)
|
||||
remove_icon_suffix (const char *icon)
|
||||
{
|
||||
guint i;
|
||||
const char *suffix;
|
||||
static const char *icon_file_name_suffixes[] = { ".svg", ".svgz", ".png", ".jpg", ".xpm" };
|
||||
static const char *icon_suffixes[] = { ".svg", ".svgz", ".png", ".jpg", ".xpm" };
|
||||
int i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (icon_file_name_suffixes); i++) {
|
||||
suffix = icon_file_name_suffixes[i];
|
||||
if (eel_str_has_suffix (icon_name, suffix)) {
|
||||
return eel_str_strip_trailing_str (icon_name, suffix);
|
||||
}
|
||||
}
|
||||
return g_strdup (icon_name);
|
||||
for (i = 0; i < G_N_ELEMENTS (icon_suffixes); i++)
|
||||
if (g_str_has_suffix (icon, icon_suffixes [i]))
|
||||
return g_strndup (icon, strlen (icon) - strlen (icon_suffixes [i]));
|
||||
|
||||
return g_strdup (icon);
|
||||
}
|
||||
/********************************************************************/
|
||||
|
||||
static GdkPixbuf *
|
||||
find_icon (GnomeDesktopItem *dentry)
|
||||
load_icon (const char *icon)
|
||||
{
|
||||
GdkPixbuf *res;
|
||||
char const *icon;
|
||||
GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
|
||||
GtkIconTheme *icon_theme;
|
||||
GdkPixbuf *retval;
|
||||
|
||||
icon = gnome_desktop_item_get_string (dentry, GNOME_DESKTOP_ITEM_ICON);
|
||||
icon_theme = gtk_icon_theme_get_default ();
|
||||
|
||||
if (icon == NULL || icon[0] == 0)
|
||||
icon = "gnome-settings";
|
||||
else if (g_path_is_absolute (icon))
|
||||
res = gdk_pixbuf_new_from_file (icon, NULL);
|
||||
else {
|
||||
char *no_suffix = nautilus_remove_icon_file_name_suffix (icon);
|
||||
res = gtk_icon_theme_load_icon (icon_theme, no_suffix, 48, 0, NULL);
|
||||
if (!g_path_is_absolute (icon)) {
|
||||
char *no_suffix;
|
||||
|
||||
no_suffix = remove_icon_suffix (icon);
|
||||
retval = gtk_icon_theme_load_icon (icon_theme, no_suffix, 48, 0, NULL);
|
||||
g_free (no_suffix);
|
||||
if (res == NULL) {
|
||||
char *path = g_build_filename (GNOMECC_ICONS_DIR, icon, NULL);
|
||||
res = gdk_pixbuf_new_from_file (path, NULL);
|
||||
|
||||
if (!retval) {
|
||||
char *path;
|
||||
|
||||
path = g_build_filename (GNOMECC_ICONS_DIR, icon, NULL);
|
||||
retval = gdk_pixbuf_new_from_file (path, NULL);
|
||||
g_free (path);
|
||||
}
|
||||
} else {
|
||||
retval = gdk_pixbuf_new_from_file (icon, NULL);
|
||||
}
|
||||
if (res == NULL)
|
||||
res = gtk_icon_theme_load_icon (icon_theme, "gnome-unknown", 48, 0, NULL);
|
||||
if (res == NULL)
|
||||
res = gtk_icon_theme_load_icon (icon_theme, "gtk-missing-image", 48, 0, NULL);
|
||||
return res;
|
||||
|
||||
if (!retval)
|
||||
retval = gtk_icon_theme_load_icon (icon_theme, "gnome-settings", 48, 0, NULL);
|
||||
if (!retval)
|
||||
retval = gtk_icon_theme_load_icon (icon_theme, "gnome-unknown", 48, 0, NULL);
|
||||
if (!retval)
|
||||
retval = gtk_icon_theme_load_icon (icon_theme, "gtk-missing-image", 48, 0, NULL);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
GnomeDesktopItem *
|
||||
get_directory_entry (GnomeVFSURI *uri)
|
||||
static ControlCenterEntry *
|
||||
control_center_entry_new (ControlCenterCategory *category,
|
||||
MenuTreeEntry *menu_entry)
|
||||
{
|
||||
GnomeVFSURI *desktop_uri;
|
||||
char *desktop_uri_string;
|
||||
GnomeDesktopItem *entry;
|
||||
ControlCenterEntry *retval;
|
||||
|
||||
desktop_uri = gnome_vfs_uri_append_file_name (uri, ".directory");
|
||||
desktop_uri_string = gnome_vfs_uri_to_string (desktop_uri, GNOME_VFS_URI_HIDE_NONE);
|
||||
retval = g_new0 (ControlCenterEntry, 1);
|
||||
|
||||
entry = gnome_desktop_item_new_from_uri (desktop_uri_string,
|
||||
GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
|
||||
NULL);
|
||||
gnome_vfs_uri_unref (desktop_uri);
|
||||
g_free (desktop_uri_string);
|
||||
return entry;
|
||||
}
|
||||
retval->category = category;
|
||||
retval->title = g_strdup (menu_tree_entry_get_name (menu_entry));
|
||||
retval->comment = g_strdup (menu_tree_entry_get_comment (menu_entry));
|
||||
retval->desktop_entry = g_strdup (menu_tree_entry_get_desktop_file_path (menu_entry));
|
||||
retval->icon_pixbuf = load_icon (menu_tree_entry_get_icon (menu_entry));
|
||||
|
||||
typedef void (*DirectoryCallback) (GnomeVFSURI *uri, const char *name, GnomeDesktopItem *entry, gpointer user_data);
|
||||
typedef void (*EntryCallback) (GnomeVFSURI *uri, const char *name, GnomeDesktopItem *entry, gpointer user_data);
|
||||
|
||||
static void
|
||||
read_entries (GnomeVFSURI *uri, gint auto_recurse_level, DirectoryCallback dcb, EntryCallback ecb, gpointer user_data)
|
||||
{
|
||||
gchar *test;
|
||||
GnomeVFSDirectoryHandle *parent_dir;
|
||||
GnomeVFSResult result;
|
||||
|
||||
GnomeVFSFileInfo *child = gnome_vfs_file_info_new ();
|
||||
|
||||
result = gnome_vfs_directory_open_from_uri (&parent_dir, uri,
|
||||
GNOME_VFS_FILE_INFO_DEFAULT);
|
||||
|
||||
if (result != GNOME_VFS_OK)
|
||||
return;
|
||||
|
||||
while (gnome_vfs_directory_read_next (parent_dir, child) == GNOME_VFS_OK) {
|
||||
GnomeVFSURI *fulluri;
|
||||
char *fullpath;
|
||||
|
||||
if (child->name[0] == '.')
|
||||
continue;
|
||||
|
||||
fulluri = gnome_vfs_uri_append_path (uri, child->name);
|
||||
fullpath = gnome_vfs_uri_to_string (fulluri, GNOME_VFS_URI_HIDE_NONE);
|
||||
|
||||
if (child->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
|
||||
if (auto_recurse_level != 0) {
|
||||
gint recurse;
|
||||
if (auto_recurse_level < 0)
|
||||
recurse = auto_recurse_level;
|
||||
else
|
||||
recurse = auto_recurse_level - 1;
|
||||
read_entries (fulluri, recurse, dcb, ecb, user_data);
|
||||
} else {
|
||||
GnomeDesktopItem *entry;
|
||||
|
||||
entry = get_directory_entry (fulluri);
|
||||
dcb (fulluri, child->name, entry, user_data);
|
||||
if (entry)
|
||||
gnome_desktop_item_unref (entry);
|
||||
}
|
||||
} else {
|
||||
|
||||
test = rindex(child->name, '.');
|
||||
|
||||
/* if it's a .desktop file, it's interesting for sure! */
|
||||
if (test && !strcmp (".desktop", test)) {
|
||||
GnomeDesktopItem *entry;
|
||||
entry = gnome_desktop_item_new_from_uri (fullpath,
|
||||
GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
|
||||
NULL);
|
||||
if (entry) {
|
||||
ecb (fulluri, child->name, entry, user_data);
|
||||
gnome_desktop_item_unref (entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
gnome_vfs_uri_unref (fulluri);
|
||||
g_free (fullpath);
|
||||
}
|
||||
|
||||
gnome_vfs_directory_close (parent_dir);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GSList *entries;
|
||||
GSList *names;
|
||||
GnomeDesktopItem *directory_entry;
|
||||
char *name;
|
||||
} CategoryLoadInformation;
|
||||
|
||||
typedef struct {
|
||||
CategoryLoadInformation *other;
|
||||
GSList *categories;
|
||||
} FullLoadInformation;
|
||||
|
||||
static void
|
||||
do_sort (GnomeDesktopItem *item, void **base, size_t nmemb,
|
||||
int (*compar)(const void *, const void *),
|
||||
const char *(*get_name)(const void *))
|
||||
{
|
||||
char **sort_orders = NULL;
|
||||
qsort (base, nmemb, sizeof (void *), compar);
|
||||
if (item)
|
||||
sort_orders = gnome_desktop_item_get_strings (item, GNOME_DESKTOP_ITEM_SORT_ORDER);
|
||||
if (sort_orders) {
|
||||
int i;
|
||||
int j = 0;
|
||||
for (i = 0; sort_orders[i]; i++) {
|
||||
int k;
|
||||
for (k = j; k < nmemb; k++) {
|
||||
const char *name = get_name (base[k]);
|
||||
if (name && !strcmp (name, sort_orders[i])) {
|
||||
void *temp = base[k];
|
||||
memmove (base + j + 1, base + j, (k - j) * sizeof (void *));
|
||||
base[j] = temp;
|
||||
j++;
|
||||
/* if (j >= nmemb), then k >= j >= nmemb
|
||||
and thus we don't need a break
|
||||
here. */
|
||||
}
|
||||
}
|
||||
if (j >= nmemb)
|
||||
break;
|
||||
}
|
||||
g_strfreev (sort_orders);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
compare_entries (const void *ap, const void *bp)
|
||||
{
|
||||
ControlCenterEntry *a = *(ControlCenterEntry **)ap;
|
||||
ControlCenterEntry *b = *(ControlCenterEntry **)bp;
|
||||
if (a->title == NULL && b->title == NULL)
|
||||
return 0;
|
||||
if (a->title == NULL)
|
||||
return 1;
|
||||
if (b->title == NULL)
|
||||
return -1;
|
||||
return strcmp (a->title,
|
||||
b->title);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_entry_name (const void *ap)
|
||||
{
|
||||
ControlCenterEntry *a = (ControlCenterEntry *)ap;
|
||||
return a->name;
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
free_entry (ControlCenterEntry *entry)
|
||||
control_center_entry_free (ControlCenterEntry *entry)
|
||||
{
|
||||
g_object_unref (entry->icon_pixbuf);
|
||||
if (entry->icon_pixbuf)
|
||||
g_object_unref (entry->icon_pixbuf);
|
||||
entry->icon_pixbuf = NULL;
|
||||
g_free (entry->name);
|
||||
if (entry->desktop_entry)
|
||||
gnome_desktop_item_unref (entry->desktop_entry);
|
||||
|
||||
g_free (entry->desktop_entry);
|
||||
entry->desktop_entry = NULL;
|
||||
|
||||
g_free (entry->comment);
|
||||
entry->comment = NULL;
|
||||
|
||||
g_free (entry->title);
|
||||
entry->title = NULL;
|
||||
|
||||
entry->category = NULL;
|
||||
|
||||
g_free (entry);
|
||||
}
|
||||
|
||||
static void
|
||||
free_category (ControlCenterCategory *category)
|
||||
populate_category (ControlCenterCategory *category,
|
||||
MenuTreeDirectory *menu_directory)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < category->count; i++) {
|
||||
free_entry (category->entries[i]);
|
||||
GSList *menu_entries;
|
||||
GSList *entries;
|
||||
GSList *l;
|
||||
|
||||
entries = NULL;
|
||||
|
||||
menu_entries = menu_tree_directory_get_entries (menu_directory);
|
||||
for (l = menu_entries; l; l = l->next) {
|
||||
MenuTreeEntry *menu_entry = l->data;
|
||||
|
||||
entries = g_slist_prepend (entries,
|
||||
control_center_entry_new (category, menu_entry));
|
||||
|
||||
menu_tree_entry_unref (menu_entry);
|
||||
}
|
||||
|
||||
g_slist_free (menu_entries);
|
||||
|
||||
if (entries != NULL) {
|
||||
GSList *l;
|
||||
int i;
|
||||
|
||||
category->n_entries = g_slist_length (entries);
|
||||
category->entries = g_new0 (ControlCenterEntry *, category->n_entries + 1);
|
||||
|
||||
for (l = entries, i = 0; l; l = l->next, i++)
|
||||
category->entries [i] = l->data;
|
||||
|
||||
g_slist_free (entries);
|
||||
}
|
||||
g_free (category->entries);
|
||||
if (category->directory_entry)
|
||||
gnome_desktop_item_unref (category->directory_entry);
|
||||
}
|
||||
|
||||
static ControlCenterCategory *
|
||||
load_information_to_category (CategoryLoadInformation *info, gboolean real_category)
|
||||
control_center_category_new (MenuTreeDirectory *menu_directory,
|
||||
const char *title,
|
||||
gboolean real_category)
|
||||
{
|
||||
ControlCenterCategory *retval;
|
||||
|
||||
retval = g_new0 (ControlCenterCategory, 1);
|
||||
|
||||
retval->title = g_strdup (title ? title : menu_tree_directory_get_name (menu_directory));
|
||||
retval->real_category = real_category != FALSE;
|
||||
|
||||
populate_category (retval, menu_directory);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
control_center_category_free (ControlCenterCategory *category)
|
||||
{
|
||||
ControlCenterCategory *category = g_new (ControlCenterCategory, 1);
|
||||
int i;
|
||||
GSList *iterator, *name_iterator;
|
||||
|
||||
category->count = g_slist_length (info->entries);
|
||||
category->entries = g_new (ControlCenterEntry *, category->count);
|
||||
category->directory_entry = info->directory_entry;
|
||||
category->title = NULL;
|
||||
category->name = info->name;
|
||||
category->user_data = NULL;
|
||||
category->real_category = real_category;
|
||||
if (category->directory_entry)
|
||||
category->title = gnome_desktop_item_get_localestring (category->directory_entry,
|
||||
GNOME_DESKTOP_ITEM_NAME);
|
||||
|
||||
if (!category->title || !category->title[0])
|
||||
category->title = category->name;
|
||||
if (!category->title || !category->title[0])
|
||||
category->title = _("Others");
|
||||
|
||||
for (i = 0, iterator = info->entries, name_iterator = info->names;
|
||||
i < category->count;
|
||||
i++, iterator = iterator->next, name_iterator = name_iterator->next) {
|
||||
category->entries[i] = g_new (ControlCenterEntry, 1);
|
||||
|
||||
category->entries[i]->desktop_entry = iterator->data;
|
||||
category->entries[i]->icon_pixbuf = find_icon (category->entries[i]->desktop_entry);
|
||||
category->entries[i]->user_data = NULL;
|
||||
category->entries[i]->name = name_iterator->data;
|
||||
category->entries[i]->category = category;
|
||||
if (category->entries[i]->desktop_entry) {
|
||||
category->entries[i]->title =
|
||||
gnome_desktop_item_get_localestring (category->entries[i]->desktop_entry,
|
||||
GNOME_DESKTOP_ITEM_NAME);
|
||||
category->entries[i]->comment =
|
||||
gnome_desktop_item_get_localestring (category->entries[i]->desktop_entry,
|
||||
GNOME_DESKTOP_ITEM_COMMENT);
|
||||
} else {
|
||||
category->entries[i]->title = NULL;
|
||||
category->entries[i]->comment = NULL;
|
||||
}
|
||||
for (i = 0; i < category->n_entries; i++) {
|
||||
control_center_entry_free (category->entries [i]);
|
||||
category->entries [i] = NULL;
|
||||
}
|
||||
|
||||
do_sort (category->directory_entry, (void **) category->entries, category->count, compare_entries, get_entry_name);
|
||||
g_free (category->entries);
|
||||
category->entries = NULL;
|
||||
|
||||
g_slist_free (info->entries);
|
||||
g_slist_free (info->names);
|
||||
|
||||
return category;
|
||||
g_free (category);
|
||||
}
|
||||
|
||||
static int
|
||||
compare_categories (const void *ap, const void *bp)
|
||||
static GSList *
|
||||
read_categories_from_menu_directory (MenuTreeDirectory *directory,
|
||||
GSList *categories)
|
||||
{
|
||||
ControlCenterCategory *a = *(ControlCenterCategory **)ap;
|
||||
ControlCenterCategory *b = *(ControlCenterCategory **)bp;
|
||||
if (a->title == NULL && b->title == NULL)
|
||||
return 0;
|
||||
if (a->title == NULL)
|
||||
return 1;
|
||||
if (b->title == NULL)
|
||||
return -1;
|
||||
return strcmp (a->title,
|
||||
b->title);
|
||||
}
|
||||
GSList *subdirs;
|
||||
GSList *l;
|
||||
|
||||
static const char *
|
||||
get_category_name (const void *ap)
|
||||
{
|
||||
ControlCenterCategory *a = (ControlCenterCategory *)ap;
|
||||
return a->name;
|
||||
}
|
||||
subdirs = menu_tree_directory_get_subdirs (directory);
|
||||
for (l = subdirs; l; l = l->next) {
|
||||
MenuTreeDirectory *subdir = l->data;
|
||||
|
||||
static ControlCenterInformation *
|
||||
load_information_to_information (GnomeVFSURI *base_uri, FullLoadInformation *info)
|
||||
{
|
||||
ControlCenterInformation *information = g_new (ControlCenterInformation, 1);
|
||||
int i;
|
||||
GSList *iterator;
|
||||
categories = g_slist_prepend (categories,
|
||||
control_center_category_new (subdir, NULL, TRUE));
|
||||
|
||||
information->count = g_slist_length (info->categories);
|
||||
information->categories = g_new (ControlCenterCategory *, information->count);
|
||||
categories = read_categories_from_menu_directory (subdir, categories);
|
||||
|
||||
i = 0;
|
||||
for (iterator = info->categories; iterator != NULL; iterator = iterator->next) {
|
||||
ControlCenterCategory *category = iterator->data;
|
||||
if (category->count)
|
||||
information->categories[i++] = category;
|
||||
else {
|
||||
free_category (category);
|
||||
}
|
||||
menu_tree_directory_unref (subdir);
|
||||
}
|
||||
|
||||
if (information->count != i) {
|
||||
information->count = i;
|
||||
information->categories = g_renew (ControlCenterCategory *, information->categories, information->count);
|
||||
}
|
||||
g_slist_free (subdirs);
|
||||
|
||||
g_slist_free (info->categories);
|
||||
|
||||
information->directory_entry = get_directory_entry (base_uri);
|
||||
information->title = NULL;
|
||||
if (information->directory_entry) {
|
||||
do_sort (information->directory_entry, (void **) information->categories, information->count, compare_categories, get_category_name);
|
||||
information->title = gnome_desktop_item_get_localestring (information->directory_entry,
|
||||
GNOME_DESKTOP_ITEM_NAME);
|
||||
}
|
||||
|
||||
if (!information->title || !information->title[0])
|
||||
information->title = _("GNOME Control Center");
|
||||
|
||||
return information;
|
||||
return categories;
|
||||
}
|
||||
|
||||
static void
|
||||
add_to_category (GnomeVFSURI *uri, const char *name, GnomeDesktopItem *entry, gpointer user_data)
|
||||
static int
|
||||
compare_categories (ControlCenterCategory *a,
|
||||
ControlCenterCategory *b)
|
||||
{
|
||||
CategoryLoadInformation *catinfo = user_data;
|
||||
|
||||
catinfo->entries = g_slist_prepend (catinfo->entries, entry);
|
||||
catinfo->names = g_slist_prepend (catinfo->names, g_strdup (name));
|
||||
|
||||
gnome_desktop_item_ref (entry);
|
||||
}
|
||||
|
||||
static void
|
||||
add_to_other (GnomeVFSURI *uri, const char *name, GnomeDesktopItem *entry, gpointer user_data)
|
||||
{
|
||||
FullLoadInformation *info = user_data;
|
||||
if (info->other == NULL) {
|
||||
info->other = g_new (CategoryLoadInformation, 1);
|
||||
info->other->entries = NULL;
|
||||
info->other->names = NULL;
|
||||
info->other->directory_entry = NULL;
|
||||
info->other->name = NULL;
|
||||
}
|
||||
add_to_category (uri, name, entry, info->other);
|
||||
}
|
||||
|
||||
static void
|
||||
create_category (GnomeVFSURI *uri, const char *name, GnomeDesktopItem *entry, gpointer user_data)
|
||||
{
|
||||
FullLoadInformation *info = user_data;
|
||||
CategoryLoadInformation catinfo;
|
||||
|
||||
catinfo.entries = NULL;
|
||||
catinfo.names = NULL;
|
||||
catinfo.directory_entry = entry;
|
||||
catinfo.name = g_strdup (name);
|
||||
if (entry)
|
||||
gnome_desktop_item_ref (entry);
|
||||
|
||||
read_entries (uri, -1, NULL, add_to_category, &catinfo);
|
||||
|
||||
info->categories = g_slist_prepend (info->categories,
|
||||
load_information_to_category (&catinfo, TRUE));
|
||||
return strcmp (a->title, b->title);
|
||||
}
|
||||
|
||||
ControlCenterInformation *
|
||||
control_center_get_categories (const gchar *prefsuri)
|
||||
control_center_get_information (void)
|
||||
{
|
||||
FullLoadInformation info;
|
||||
GnomeVFSURI *uri;
|
||||
ControlCenterInformation *information;
|
||||
MenuTree *menu_tree;
|
||||
MenuTreeDirectory *menu_root;
|
||||
GSList *categories;
|
||||
|
||||
info.categories = NULL;
|
||||
info.other = NULL;
|
||||
information = g_new0 (ControlCenterInformation, 1);
|
||||
|
||||
uri = gnome_vfs_uri_new (prefsuri);
|
||||
read_entries (uri, 0, create_category, add_to_other, &info);
|
||||
menu_tree = menu_tree_lookup ("preferences.menu");
|
||||
|
||||
if (info.other)
|
||||
info.categories = g_slist_prepend (info.categories, load_information_to_category (info.other, FALSE));
|
||||
g_free (info.other);
|
||||
if (!(menu_root = menu_tree_get_root_directory (menu_tree))) {
|
||||
menu_tree_unref (menu_tree);
|
||||
return information;
|
||||
}
|
||||
|
||||
information = load_information_to_information (uri, &info);
|
||||
gnome_vfs_uri_unref (uri);
|
||||
categories = read_categories_from_menu_directory (menu_root, NULL);
|
||||
categories = g_slist_sort (categories,
|
||||
(GCompareFunc) compare_categories);
|
||||
|
||||
categories = g_slist_append (categories,
|
||||
control_center_category_new (menu_root, _("Others"), FALSE));
|
||||
|
||||
menu_tree_directory_unref (menu_root);
|
||||
|
||||
if (categories != NULL) {
|
||||
GSList *l;
|
||||
int i;
|
||||
|
||||
information->n_categories = g_slist_length (categories);
|
||||
information->categories = g_new0 (ControlCenterCategory *, information->n_categories + 1);
|
||||
|
||||
for (l = categories, i = 0; l; l = l->next, i++)
|
||||
information->categories [i] = l->data;
|
||||
|
||||
g_slist_free (categories);
|
||||
}
|
||||
|
||||
menu_tree_unref (menu_tree);
|
||||
|
||||
return information;
|
||||
}
|
||||
|
||||
void
|
||||
control_center_information_free (ControlCenterInformation *information)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < information->n_categories; i++) {
|
||||
control_center_category_free (information->categories [i]);
|
||||
information->categories [i] = NULL;
|
||||
}
|
||||
|
||||
information->n_categories = 0;
|
||||
|
||||
g_free (information->categories);
|
||||
information->categories = NULL;
|
||||
|
||||
g_free (information);
|
||||
}
|
||||
|
|
|
@ -1,32 +1,73 @@
|
|||
#include <libgnome/gnome-desktop-item.h>
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
|
||||
typedef struct ControlCenterCategory_ ControlCenterCategory;
|
||||
/*
|
||||
* Copyright (C) 2004 Red Hat, Inc.
|
||||
* Copyright (C) 2000, 2001 Ximian, Inc.
|
||||
* Copyright (C) 1998 Red Hat Software, Inc.
|
||||
*
|
||||
* Written by Mark McLoughlin <mark@skynet.ie>
|
||||
* Bradford Hovinen <hovinen@ximian.com>,
|
||||
* Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
GnomeDesktopItem *desktop_entry;
|
||||
GdkPixbuf *icon_pixbuf;
|
||||
const char *title;
|
||||
const char *comment;
|
||||
char *name;
|
||||
ControlCenterCategory *category;
|
||||
gpointer user_data;
|
||||
} ControlCenterEntry;
|
||||
#ifndef __CONTROL_CENTER_CATEGORIES_H__
|
||||
#define __CONTROL_CENTER_CATEGORIES_H__
|
||||
|
||||
struct ControlCenterCategory_ {
|
||||
int count;
|
||||
ControlCenterEntry **entries;
|
||||
GnomeDesktopItem *directory_entry;
|
||||
const char *title;
|
||||
char *name;
|
||||
gpointer user_data;
|
||||
gboolean real_category;
|
||||
#include <glib.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct ControlCenterEntry ControlCenterEntry;
|
||||
typedef struct ControlCenterCategory ControlCenterCategory;
|
||||
typedef struct ControlCenterInformation ControlCenterInformation;
|
||||
|
||||
struct ControlCenterEntry {
|
||||
ControlCenterCategory *category;
|
||||
|
||||
char *title;
|
||||
char *comment;
|
||||
char *desktop_entry;
|
||||
|
||||
GdkPixbuf *icon_pixbuf;
|
||||
|
||||
gpointer user_data;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int count;
|
||||
ControlCenterCategory **categories;
|
||||
GnomeDesktopItem *directory_entry;
|
||||
const char *title;
|
||||
} ControlCenterInformation;
|
||||
struct ControlCenterCategory {
|
||||
ControlCenterEntry **entries;
|
||||
int n_entries;
|
||||
|
||||
ControlCenterInformation *control_center_get_categories (const gchar *prefsuri); /* Of type Category * */
|
||||
char *title;
|
||||
|
||||
gpointer user_data;
|
||||
|
||||
guint real_category : 1;
|
||||
};
|
||||
|
||||
struct ControlCenterInformation {
|
||||
ControlCenterCategory **categories;
|
||||
int n_categories;
|
||||
};
|
||||
|
||||
ControlCenterInformation *control_center_get_information (void);
|
||||
void control_center_information_free (ControlCenterInformation *information);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CONTROL_CENTER_CATEGORIES_H__ */
|
||||
|
|
|
@ -3,18 +3,14 @@
|
|||
|
||||
#include "control-center-categories.h"
|
||||
|
||||
#include <bonobo/bonobo-context.h>
|
||||
#include <bonobo/bonobo-control.h>
|
||||
#include <bonobo/bonobo-generic-factory.h>
|
||||
#include <bonobo/bonobo-main.h>
|
||||
#include <libnautilus/nautilus-view.h>
|
||||
#include <gnome.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#include <libgnome/libgnome.h>
|
||||
#include <libgnomeui/libgnomeui.h>
|
||||
#include <libgnomecanvas/libgnomecanvas.h>
|
||||
#include <libgnome/gnome-desktop-item.h>
|
||||
|
||||
#include "gnomecc-event-box.h"
|
||||
#include "gnomecc-rounded-rect.h"
|
||||
|
||||
|
@ -72,13 +68,6 @@ typedef struct {
|
|||
|
||||
#define PAD 5 /*when scrolling keep a few pixels above or below if possible */
|
||||
|
||||
static gboolean use_nautilus = FALSE;
|
||||
static struct poptOption cap_options[] = {
|
||||
{"use-nautilus", '\0', POPT_ARG_NONE, &use_nautilus, 0,
|
||||
N_("Use nautilus if it is running."), NULL},
|
||||
{NULL, '\0', 0, NULL, 0}
|
||||
};
|
||||
|
||||
static gboolean
|
||||
single_click_activates (void)
|
||||
{
|
||||
|
@ -206,7 +195,7 @@ relayout_canvas (ControlCenter *cc)
|
|||
/* Do this in several iterations to keep things straight
|
||||
* 0) walk down each column to decide when to wrap */
|
||||
start_again :
|
||||
count = cc->info->count;
|
||||
count = cc->info->n_categories;
|
||||
cc->line_count = 0;
|
||||
keep_going = TRUE;
|
||||
for (i = 0 ; keep_going; i++) {
|
||||
|
@ -224,7 +213,7 @@ start_again :
|
|||
for (j = 0; j < count; j++) {
|
||||
ControlCenterCategory *cat = cc->info->categories[j];
|
||||
PangoLayout *layout;
|
||||
if (line_i >= cat->count)
|
||||
if (line_i >= cat->n_entries)
|
||||
continue;
|
||||
ei = cat->entries[line_i]->user_data;
|
||||
if (ei == NULL)
|
||||
|
@ -262,7 +251,7 @@ start_again :
|
|||
|
||||
for (j = 0; j < count; j++) {
|
||||
ControlCenterCategory *cat = cc->info->categories[j];
|
||||
if (line_i >= cat->count)
|
||||
if (line_i >= cat->n_entries)
|
||||
continue;
|
||||
ei = cat->entries[line_i]->user_data;
|
||||
if (ei != NULL) {
|
||||
|
@ -286,7 +275,7 @@ start_again :
|
|||
|
||||
/* 1.1) find the bounds */
|
||||
max_text_height = max_icon_height = 0.;
|
||||
for (j = 0; j < cat->count; j++) {
|
||||
for (j = 0; j < cat->n_entries; j++) {
|
||||
ei = cat->entries[j]->user_data;
|
||||
if (ei == NULL)
|
||||
continue;
|
||||
|
@ -332,7 +321,7 @@ start_again :
|
|||
cc->line_count ++;
|
||||
|
||||
height = max_text_height + max_icon_height;
|
||||
for (j = 0; j < cat->count; j++) {
|
||||
for (j = 0; j < cat->n_entries; j++) {
|
||||
ei = cat->entries[j]->user_data;
|
||||
ei->line_start = (j == 0);
|
||||
|
||||
|
@ -476,7 +465,7 @@ get_x (ControlCenter *cc, ControlCenterEntry *entry)
|
|||
int x;
|
||||
if (entry != NULL) {
|
||||
ControlCenterCategory *category = entry->category;
|
||||
for (i = 0, x = 0; i < category->count; i++, x++) {
|
||||
for (i = 0, x = 0; i < category->n_entries; i++, x++) {
|
||||
EntryInfo *ei = category->entries[i]->user_data;
|
||||
if (ei->line_start)
|
||||
x = 0;
|
||||
|
@ -494,11 +483,11 @@ get_y (ControlCenter *cc, ControlCenterEntry *entry)
|
|||
int line_count = 0;
|
||||
if (entry != NULL) {
|
||||
ControlCenterCategory *category = entry->category;
|
||||
for (i = 0; i < cc->info->count; i++) {
|
||||
for (i = 0; i < cc->info->n_categories; i++) {
|
||||
CategoryInfo *catinfo = cc->info->categories[i]->user_data;
|
||||
|
||||
if (cc->info->categories[i] == category) {
|
||||
for (i = 0; i < category->count; i++) {
|
||||
for (i = 0; i < category->n_entries; i++) {
|
||||
EntryInfo *ei = category->entries[i]->user_data;
|
||||
if (i > 0 && ei->line_start)
|
||||
line_count ++;
|
||||
|
@ -518,15 +507,15 @@ static ControlCenterEntry *
|
|||
get_entry (ControlCenter *cc, int x, int y)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < cc->info->count; i++) {
|
||||
for (i = 0; i < cc->info->n_categories; i++) {
|
||||
CategoryInfo *catinfo = cc->info->categories[i]->user_data;
|
||||
if (y < catinfo->line_count) {
|
||||
int j;
|
||||
for (j = 0; j < cc->info->categories[i]->count; j++) {
|
||||
for (j = 0; j < cc->info->categories[i]->n_entries; j++) {
|
||||
EntryInfo *ei = cc->info->categories[i]->entries[j]->user_data;
|
||||
if (ei->line_start) {
|
||||
if (y == 0) {
|
||||
g_assert (j + x < cc->info->categories[i]->count);
|
||||
g_assert (j + x < cc->info->categories[i]->n_entries);
|
||||
return cc->info->categories[i]->entries[j + x];
|
||||
} else {
|
||||
y --;
|
||||
|
@ -544,13 +533,13 @@ static int
|
|||
get_line_length (ControlCenter *cc, int y)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < cc->info->count; i++) {
|
||||
for (i = 0; i < cc->info->n_categories; i++) {
|
||||
CategoryInfo *catinfo = cc->info->categories[i]->user_data;
|
||||
if (y < catinfo->line_count) {
|
||||
int j;
|
||||
int last_start = 0;
|
||||
|
||||
for (j = 1; j < cc->info->categories[i]->count; j++) {
|
||||
for (j = 1; j < cc->info->categories[i]->n_entries; j++) {
|
||||
EntryInfo *ei = cc->info->categories[i]->entries[j]->user_data;
|
||||
if (ei->line_start) {
|
||||
if (y == 0) {
|
||||
|
@ -612,9 +601,18 @@ activate_entry (ControlCenterEntry *entry)
|
|||
{
|
||||
EntryInfo *ei = entry->user_data;
|
||||
if (!ei->launching) {
|
||||
GnomeDesktopItem *desktop_item;
|
||||
|
||||
ei->launching = TRUE;
|
||||
gtk_timeout_add (1000, cb_entry_info_reset, ei);
|
||||
gnome_desktop_item_launch (entry->desktop_entry, NULL, 0, NULL);
|
||||
|
||||
desktop_item = gnome_desktop_item_new_from_file (entry->desktop_entry,
|
||||
GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
|
||||
NULL);
|
||||
if (desktop_item != NULL) {
|
||||
gnome_desktop_item_launch (desktop_item, NULL, 0, NULL);
|
||||
gnome_desktop_item_unref (desktop_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,7 +790,7 @@ set_style (ControlCenter *cc, gboolean font_changed)
|
|||
if (!GTK_WIDGET_REALIZED (widget))
|
||||
return;
|
||||
|
||||
for (i = 0; i < cc->info->count; i++) {
|
||||
for (i = 0; i < cc->info->n_categories; i++) {
|
||||
CategoryInfo *catinfo = cc->info->categories[i]->user_data;
|
||||
|
||||
if (LINE_WITHIN || catinfo->line) {
|
||||
|
@ -811,7 +809,7 @@ set_style (ControlCenter *cc, gboolean font_changed)
|
|||
NULL);
|
||||
}
|
||||
|
||||
for (j = 0; j < cc->info->categories[i]->count; j++) {
|
||||
for (j = 0; j < cc->info->categories[i]->n_entries; j++) {
|
||||
ControlCenterEntry *entry = cc->info->categories[i]->entries[j];
|
||||
EntryInfo *entryinfo = entry->user_data;
|
||||
if (font_changed && entryinfo->text)
|
||||
|
@ -843,7 +841,6 @@ canvas_style_set (GtkWidget *canvas, GtkStyle *previous_style, ControlCenter *cc
|
|||
static void
|
||||
rebuild_canvas (ControlCenter *cc, ControlCenterInformation *info)
|
||||
{
|
||||
int count;
|
||||
int i;
|
||||
int j;
|
||||
int vert_pos = BORDERS;
|
||||
|
@ -863,10 +860,8 @@ rebuild_canvas (ControlCenter *cc, ControlCenterInformation *info)
|
|||
"event",
|
||||
G_CALLBACK (cb_canvas_event), cc);
|
||||
|
||||
count = cc->info->count;
|
||||
|
||||
cc->line_count = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
for (i = 0; i < cc->info->n_categories; i++) {
|
||||
CategoryInfo *catinfo;
|
||||
|
||||
if (cc->info->categories[i]->user_data == NULL)
|
||||
|
@ -890,7 +885,7 @@ rebuild_canvas (ControlCenter *cc, ControlCenterInformation *info)
|
|||
NULL);
|
||||
|
||||
catinfo->title = NULL;
|
||||
if (cc->info->categories[i] && (cc->info->count != 1 || cc->info->categories[0]->real_category)) {
|
||||
if (cc->info->categories[i] && (cc->info->n_categories != 1 || cc->info->categories[0]->real_category)) {
|
||||
char *label = g_strdup_printf ("<span weight=\"bold\">%s</span>", cc->info->categories[i]->title);
|
||||
catinfo->title = gnome_canvas_item_new (catinfo->group,
|
||||
gnome_canvas_text_get_type (),
|
||||
|
@ -903,7 +898,7 @@ rebuild_canvas (ControlCenter *cc, ControlCenterInformation *info)
|
|||
|
||||
catinfo->line_count = 1;
|
||||
cc->line_count ++;
|
||||
for (j = 0; j < cc->info->categories[i]->count; j++) {
|
||||
for (j = 0; j < cc->info->categories[i]->n_entries; j++) {
|
||||
EntryInfo *ei;
|
||||
|
||||
if (cc->info->categories[i]->entries[j]->user_data == NULL)
|
||||
|
@ -991,87 +986,6 @@ size_allocate(GtkWidget *widget, GtkAllocation *allocation, ControlCenter *cc)
|
|||
NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_nautilus_running (void)
|
||||
{
|
||||
Atom window_id_atom;
|
||||
Window nautilus_xid;
|
||||
Atom actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *data;
|
||||
int retval;
|
||||
Atom wmclass_atom;
|
||||
gboolean running;
|
||||
gint error;
|
||||
|
||||
window_id_atom = XInternAtom (GDK_DISPLAY (),
|
||||
"NAUTILUS_DESKTOP_WINDOW_ID", True);
|
||||
|
||||
if (window_id_atom == None) return FALSE;
|
||||
|
||||
retval = XGetWindowProperty (GDK_DISPLAY (), GDK_ROOT_WINDOW (),
|
||||
window_id_atom, 0, 1, False, XA_WINDOW,
|
||||
&actual_type, &actual_format, &nitems,
|
||||
&bytes_after, &data);
|
||||
|
||||
if (data != NULL) {
|
||||
nautilus_xid = *(Window *) data;
|
||||
XFree (data);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (actual_type != XA_WINDOW) return FALSE;
|
||||
if (actual_format != 32) return FALSE;
|
||||
|
||||
wmclass_atom = XInternAtom (GDK_DISPLAY (), "WM_CLASS", False);
|
||||
|
||||
gdk_error_trap_push ();
|
||||
|
||||
retval = XGetWindowProperty (GDK_DISPLAY (), nautilus_xid,
|
||||
wmclass_atom, 0, 24, False, XA_STRING,
|
||||
&actual_type, &actual_format, &nitems,
|
||||
&bytes_after, &data);
|
||||
|
||||
error = gdk_error_trap_pop ();
|
||||
|
||||
if (error == BadWindow) return FALSE;
|
||||
|
||||
if (actual_type == XA_STRING &&
|
||||
nitems == 24 &&
|
||||
bytes_after == 0 &&
|
||||
actual_format == 8 &&
|
||||
data != NULL &&
|
||||
!strcmp (data, "desktop_window") &&
|
||||
!strcmp (data + strlen (data) + 1, "Nautilus"))
|
||||
running = TRUE;
|
||||
else
|
||||
running = FALSE;
|
||||
|
||||
if (data != NULL)
|
||||
XFree (data);
|
||||
|
||||
return running;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnome_cc_save_yourself (GnomeClient *client, gint phase, GnomeSaveStyle save_style,
|
||||
gboolean shutdown, GnomeInteractStyle interact_style,
|
||||
gboolean fast, gchar *argv0)
|
||||
{
|
||||
gchar *argv[3];
|
||||
gint argc;
|
||||
|
||||
argv[0] = argv0;
|
||||
argv[1] = "--use-shell";
|
||||
argc = 2;
|
||||
gnome_client_set_clone_command (client, argc, argv);
|
||||
gnome_client_set_restart_command (client, argc, argv);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_cc_die (void)
|
||||
{
|
||||
|
@ -1190,8 +1104,7 @@ cb_focus_changed (ControlCenter *cc)
|
|||
}
|
||||
|
||||
static GtkWindow *
|
||||
create_window (const gchar *appname,
|
||||
const gchar *uri)
|
||||
create_window (void)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GnomeClient *client;
|
||||
|
@ -1200,17 +1113,13 @@ create_window (const gchar *appname,
|
|||
ControlCenterInformation *info;
|
||||
|
||||
client = gnome_master_client ();
|
||||
g_signal_connect (G_OBJECT (client),
|
||||
"save_yourself",
|
||||
G_CALLBACK (gnome_cc_save_yourself), (void *) appname);
|
||||
g_signal_connect (G_OBJECT (client),
|
||||
"die",
|
||||
G_CALLBACK (gnome_cc_die), NULL);
|
||||
|
||||
info = control_center_get_categories (uri);
|
||||
window = gnome_app_new ("gnomecc", info->title);
|
||||
gnome_window_icon_set_from_file (GTK_WINDOW (window),
|
||||
PIXMAP_DIR "/control-center.png");
|
||||
info = control_center_get_information ();
|
||||
window = gnome_app_new ("gnomecc", _("Desktop Preferences"));
|
||||
gtk_window_set_icon_name (GTK_WINDOW (window), "gnome-control-center");
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 760, 530);
|
||||
|
||||
appbar = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_USER);
|
||||
|
@ -1232,61 +1141,6 @@ create_window (const gchar *appname,
|
|||
return GTK_WINDOW (window);
|
||||
}
|
||||
|
||||
static void
|
||||
change_status_view (ControlCenter *cc, const gchar *status, void *data)
|
||||
{
|
||||
NautilusView *view = data;
|
||||
|
||||
if (!status)
|
||||
status = "";
|
||||
|
||||
nautilus_view_report_status (view, status);
|
||||
}
|
||||
|
||||
static void
|
||||
cb_load_location (NautilusView *view,
|
||||
char const *location,
|
||||
ControlCenter *cc)
|
||||
{
|
||||
ControlCenterInformation *info;
|
||||
|
||||
nautilus_view_report_load_underway (view);
|
||||
|
||||
info = control_center_get_categories (location);
|
||||
control_center_set_info (cc, info);
|
||||
control_center_set_status_cb (cc, change_status_view, view);
|
||||
|
||||
gtk_widget_show_all (cc->widget);
|
||||
|
||||
nautilus_view_report_load_complete (view);
|
||||
}
|
||||
|
||||
#define GNOMECC_VIEW_OAFIID "OAFIID:GNOME_ControlCenter_View"
|
||||
#define GNOMECC_FACTORY_OAFIID "OAFIID:GNOME_ControlCenter_Factory"
|
||||
|
||||
static BonoboObject *
|
||||
factory_create_cb (BonoboGenericFactory *factory,
|
||||
gchar const *iid,
|
||||
gpointer closure)
|
||||
{
|
||||
ControlCenter *cc;
|
||||
NautilusView *view;
|
||||
|
||||
if (strcmp (iid, GNOMECC_VIEW_OAFIID) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cc = create_control_center ();
|
||||
view = nautilus_view_new (cc->widget);
|
||||
|
||||
g_signal_connect (view,
|
||||
"load_location",
|
||||
G_CALLBACK (cb_load_location),
|
||||
cc);
|
||||
|
||||
return BONOBO_OBJECT (view);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
@ -1300,57 +1154,11 @@ main (int argc, char *argv[])
|
|||
VERSION, LIBGNOMEUI_MODULE,
|
||||
argc, argv,
|
||||
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
||||
GNOME_PARAM_POPT_TABLE, cap_options,
|
||||
NULL);
|
||||
|
||||
if (use_nautilus && is_nautilus_running ())
|
||||
execlp ("nautilus", "nautilus", "preferences:///", NULL);
|
||||
create_window ();
|
||||
|
||||
if (bonobo_activation_iid_get ()) {
|
||||
/* Look for an existing factory */
|
||||
CORBA_Object existing_factory = bonobo_activation_activate_from_id (
|
||||
GNOMECC_FACTORY_OAFIID, Bonobo_ACTIVATION_FLAG_EXISTING_ONLY,
|
||||
NULL, NULL);
|
||||
|
||||
if (existing_factory == CORBA_OBJECT_NIL) {
|
||||
/* Not started, start now */
|
||||
gchar *registration_id = bonobo_activation_make_registration_id (
|
||||
GNOMECC_FACTORY_OAFIID, DisplayString (gdk_display));
|
||||
BonoboGenericFactory *factory = bonobo_generic_factory_new (
|
||||
registration_id, factory_create_cb, NULL);
|
||||
g_free (registration_id);
|
||||
|
||||
bonobo_running_context_auto_exit_unref (
|
||||
BONOBO_OBJECT (factory));
|
||||
|
||||
bonobo_main ();
|
||||
}
|
||||
} else {
|
||||
const gchar **args;
|
||||
poptContext ctx;
|
||||
GValue context = { 0 };
|
||||
|
||||
g_object_get_property (G_OBJECT (ccprogram),
|
||||
GNOME_PARAM_POPT_CONTEXT,
|
||||
g_value_init (&context, G_TYPE_POINTER));
|
||||
ctx = g_value_get_pointer (&context);
|
||||
|
||||
/* Create a standalone window */
|
||||
args = poptGetArgs (ctx);
|
||||
if (args != NULL) {
|
||||
create_window (argv[0], args[0]);
|
||||
} else {
|
||||
create_window (argv[0], "preferences:///");
|
||||
}
|
||||
poptFreeContext (ctx);
|
||||
|
||||
gtk_main ();
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (gnome_unique_window_create ("gnome-control-center", create_unique_window, argv[0]))
|
||||
gtk_main ();
|
||||
#endif
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 11 KiB |
BIN
control-center/gnome-control-center.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB |
|
@ -1,19 +0,0 @@
|
|||
<Root>
|
||||
<commands>
|
||||
<cmd name="FileClose" stockid="gtk-close"/>
|
||||
<cmd name="HelpContent" _label="_Contents" _tip="Overview of the control center"
|
||||
pixtype="stock" pixname="Help" accel="F1"/>
|
||||
<cmd name="HelpAbout" _label="_About" _tip="About this application"
|
||||
pixtype="stock" pixname="About"/>
|
||||
</commands>
|
||||
|
||||
<menu>
|
||||
<submenu name="File" _label="_File">
|
||||
<menuitem name="FileClose" verb=""/>
|
||||
</submenu>
|
||||
<submenu name="Help" _label="_Help">
|
||||
<menuitem name="HelpContent" verb=""/>
|
||||
<menuitem name="HelpAbout" verb=""/>
|
||||
</submenu>
|
||||
</menu>
|
||||
</Root>
|
|
@ -2,7 +2,7 @@
|
|||
Encoding=UTF-8
|
||||
_Name=GNOME Control Center
|
||||
_Comment=The GNOME configuration tool
|
||||
Icon=control-center2
|
||||
Icon=gnome-control-center
|
||||
Exec=gnome-control-center
|
||||
Terminal=false
|
||||
Type=Application
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
/* XPM */
|
||||
static char * 16_mode_descriptions_xpm[] = {
|
||||
"24 24 75 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #7C90A3",
|
||||
"@ c #5C778F",
|
||||
"# c #4D667E",
|
||||
"$ c #5F798F",
|
||||
"% c #4B6983",
|
||||
"& c #374F64",
|
||||
"* c #FFFFFF",
|
||||
"= c #FCFCFC",
|
||||
"- c #FBFBFB",
|
||||
"; c #FAFAFA",
|
||||
"> c #F9F9F9",
|
||||
", c #F7F7F7",
|
||||
"' c #A4A4A4",
|
||||
") c #990000",
|
||||
"! c #B39169",
|
||||
"~ c #A6A6A6",
|
||||
"{ c #C1C1C1",
|
||||
"] c #CDCDCD",
|
||||
"^ c #E4E4E4",
|
||||
"/ c #C9C9C9",
|
||||
"( c #E0E0E0",
|
||||
"_ c #F6F6F6",
|
||||
": c #A0A0A0",
|
||||
"< c #C2C2C2",
|
||||
"[ c #A3A3A3",
|
||||
"} c #B5B5B5",
|
||||
"| c #BABABA",
|
||||
"1 c #B2B2B2",
|
||||
"2 c #AEAEAE",
|
||||
"3 c #F4F4F4",
|
||||
"4 c #A1A1A1",
|
||||
"5 c #F8F8F8",
|
||||
"6 c #F5F5F5",
|
||||
"7 c #F3F3F3",
|
||||
"8 c #314E6C",
|
||||
"9 c #CFCFCF",
|
||||
"0 c #DCDCDC",
|
||||
"a c #DBDBDB",
|
||||
"b c #F2F2F2",
|
||||
"c c #969696",
|
||||
"d c #A7A7A7",
|
||||
"e c #C7C7C7",
|
||||
"f c #B3B3B3",
|
||||
"g c #B6B6B6",
|
||||
"h c #A8A8A8",
|
||||
"i c #F1F1F1",
|
||||
"j c #8F8F8F",
|
||||
"k c #FEFEFE",
|
||||
"l c #EFEFEF",
|
||||
"m c #909090",
|
||||
"n c #FDFDFD",
|
||||
"o c #267726",
|
||||
"p c #DADADA",
|
||||
"q c #BFBFBF",
|
||||
"r c #E5E5E5",
|
||||
"s c #BEBEBE",
|
||||
"t c #D7D7D7",
|
||||
"u c #EEEEEE",
|
||||
"v c #8C8C8C",
|
||||
"w c #CCCCCC",
|
||||
"x c #A5A5A5",
|
||||
"y c #BDBDBD",
|
||||
"z c #EDEDED",
|
||||
"A c #F0F0F0",
|
||||
"B c #959595",
|
||||
"C c #E2E2E2",
|
||||
"D c #C6C6C6",
|
||||
"E c #9E9E9E",
|
||||
"F c #9D9D9D",
|
||||
"G c #9C9C9C",
|
||||
"H c #9B9B9B",
|
||||
"I c #9F9F9F",
|
||||
"J c #646464",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ................ ",
|
||||
" .+@@@@@@@@@@@@#. ",
|
||||
" .$%%%%%%%%%%%%&. ",
|
||||
" .*=======-;>>,'. ",
|
||||
" .*=)!==~{]^/(_:. ",
|
||||
" .*=))==<[}|1234. ",
|
||||
" .*===-;>>5,_67:. ",
|
||||
" .*=88;>90a]]]bc. ",
|
||||
" .*=!8>5deffghij. ",
|
||||
" .k;>>5,_637bilm. ",
|
||||
" .n>oo_6apqrstuv. ",
|
||||
" .=5oo63wqxsyyzv. ",
|
||||
" .537bbiAluzzzzB. ",
|
||||
" .C<DD~EEFGGHIBJ. ",
|
||||
" ................ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
|
@ -1,11 +0,0 @@
|
|||
killall background-properties-capplet 2>/dev/null
|
||||
killall sound-properties 2>/dev/null
|
||||
killall keyboard-properties 2>/dev/null
|
||||
killall mouse-properties-capplet 2>/dev/null
|
||||
killall bonobo-moniker-archiver 2>/dev/null
|
||||
|
||||
killall -9 background-properties-capplet 2>/dev/null
|
||||
killall -9 sound-properties 2>/dev/null
|
||||
killall -9 keyboard-properties 2>/dev/null
|
||||
killall -9 mouse-properties-capplet 2>/dev/null
|
||||
killall -9 bonobo-moniker-archiver 2>/dev/null
|
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 519 B |
Before Width: | Height: | Size: 763 B |
|
@ -1,77 +0,0 @@
|
|||
/* XPM */
|
||||
static char * 16_mode_tree_xpm[] = {
|
||||
"24 24 50 1",
|
||||
" c None",
|
||||
". c #000000",
|
||||
"+ c #7C90A3",
|
||||
"@ c #5C778F",
|
||||
"# c #4D667E",
|
||||
"$ c #5F798F",
|
||||
"% c #4B6983",
|
||||
"& c #374F64",
|
||||
"* c #FFFFFF",
|
||||
"= c #FCFCFC",
|
||||
"- c #FBFBFB",
|
||||
"; c #FAFAFA",
|
||||
"> c #F9F9F9",
|
||||
", c #F7F7F7",
|
||||
"' c #A4A4A4",
|
||||
") c #ADADAD",
|
||||
"! c #990000",
|
||||
"~ c #B39169",
|
||||
"{ c #F8F8F8",
|
||||
"] c #F6F6F6",
|
||||
"^ c #A0A0A0",
|
||||
"/ c #F4F4F4",
|
||||
"( c #A1A1A1",
|
||||
"_ c #F5F5F5",
|
||||
": c #F3F3F3",
|
||||
"< c #314E6C",
|
||||
"[ c #F2F2F2",
|
||||
"} c #969696",
|
||||
"| c #F1F1F1",
|
||||
"1 c #8F8F8F",
|
||||
"2 c #FEFEFE",
|
||||
"3 c #EFEFEF",
|
||||
"4 c #909090",
|
||||
"5 c #FDFDFD",
|
||||
"6 c #267726",
|
||||
"7 c #F0F0F0",
|
||||
"8 c #EEEEEE",
|
||||
"9 c #8C8C8C",
|
||||
"0 c #EDEDED",
|
||||
"a c #959595",
|
||||
"b c #E2E2E2",
|
||||
"c c #C2C2C2",
|
||||
"d c #C6C6C6",
|
||||
"e c #A6A6A6",
|
||||
"f c #9E9E9E",
|
||||
"g c #9D9D9D",
|
||||
"h c #9C9C9C",
|
||||
"i c #9B9B9B",
|
||||
"j c #9F9F9F",
|
||||
"k c #646464",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ................ ",
|
||||
" .+@@@@@@@@@@@@#. ",
|
||||
" .$%%%%%%%%%%%%&. ",
|
||||
" .*=======-;>>,'. ",
|
||||
" .*=)===!~;>{,]^. ",
|
||||
" .*=)))=!!>{,]/(. ",
|
||||
" .*=)=-;>>{,]_:^. ",
|
||||
" .*=)-;>{,]<</[}. ",
|
||||
" .*=))))))_~<:|1. ",
|
||||
" .2;>>{)]_/:[|34. ",
|
||||
" .5>{,])_/:66789. ",
|
||||
" .={,]_)))[66309. ",
|
||||
" .{/:[[|7380000a. ",
|
||||
" .bcddeffghhijak. ",
|
||||
" ................ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|