Enable the ximian shell at long last
2004-10-15 Jody Goldberg <jody@gnome.org> * configure.in : bump the xklavier version dep. I hope 1.04 is sufficient, rather than cvs head.
This commit is contained in:
parent
690958ade8
commit
eb83cea64a
11 changed files with 35 additions and 2048 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-10-15 Jody Goldberg <jody@gnome.org>
|
||||
|
||||
* configure.in : bump the xklavier version dep. I hope 1.04 is
|
||||
sufficient, rather than cvs head.
|
||||
|
||||
2004-10-14 Jody Goldberg <jody@gnome.org>
|
||||
|
||||
* configure.in : post release bump
|
||||
|
|
|
@ -99,7 +99,7 @@ PKG_CHECK_MODULES(VFS_CAPPLET, $COMMON_MODULES gnome-vfs-module-2.0 gnome-vfs-2.
|
|||
PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-2.0)
|
||||
PKG_CHECK_MODULES(SOUND_CAPPLET, esound)
|
||||
PKG_CHECK_MODULES(METACITY, libmetacity-private)
|
||||
PKG_CHECK_MODULES(LIBXKLAVIER, libxklavier >= 1.02,,
|
||||
PKG_CHECK_MODULES(LIBXKLAVIER, libxklavier >= 1.04,,
|
||||
AC_MSG_ERROR([Upcoming releases of gnome-control-center will depend on libxklavier.
|
||||
The latest release is available from http://prdownloads.sourceforge.net/gswitchit], 1))
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@ 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
|
||||
|
||||
|
@ -20,18 +25,34 @@ INCLUDES = \
|
|||
-DPIXMAP_DIR=\""$(datadir)/pixmaps"\" \
|
||||
-DART_DIR=\""$(splashdir)"\" \
|
||||
-DGNOME_SBINDIR=\""$(sbindir)"\" \
|
||||
$(GNOMECC_CFLAGS)
|
||||
$(GNOMECC_CFLAGS) $(NAUTILUS_CFLAGS)
|
||||
|
||||
bin_PROGRAMS = gnome-control-center
|
||||
|
||||
gnome_control_center_SOURCES = \
|
||||
main.c \
|
||||
capplet-dir.c capplet-dir.h \
|
||||
capplet-dir-view.c capplet-dir-view.h \
|
||||
capplet-dir-view-list.c
|
||||
control-center-categories.c \
|
||||
control-center-categories.h \
|
||||
control-center.c \
|
||||
gnomecc-rounded-rect.c \
|
||||
gnomecc-rounded-rect.h \
|
||||
gnomecc-event-box.c \
|
||||
gnomecc-event-box.h
|
||||
|
||||
gnome_control_center_LDADD = $(GNOMECC_LIBS)
|
||||
gnome_control_center_LDADD = $(GNOMECC_LIBS) $(NAUTILUS_LIBS)
|
||||
|
||||
EXTRA_DIST = gnomecc.desktop.in $(splash_DATA) $(ui_DATA)
|
||||
IMAGES = text-selection-frame.png
|
||||
VARIABLES = \
|
||||
gnomecc_rounded_rect_frame $(srcdir)/text-selection-frame.png
|
||||
|
||||
CLEANFILES = gnomecc.desktop
|
||||
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)
|
||||
|
||||
BUILT_SOURCES = $(pixbuf_file)
|
||||
CLEANFILES = gnomecc.desktop $(noinst_DATA)
|
||||
|
|
|
@ -1,530 +0,0 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* capplet-dir-view-list.c
|
||||
* Copyright (C) 2000, 2001 Ximian, Inc.
|
||||
*
|
||||
* Authors: Jacob Berkman <jacob@ximian.com>
|
||||
* Bradford Hovinen <hovinen@ximian.com>
|
||||
* Rachel Hestilow <hestilow@ximian.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.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "capplet-dir-view.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GnomeIconList *gil;
|
||||
CappletDir *root_dir;
|
||||
CappletDir *current;
|
||||
gboolean ignore_selection;
|
||||
|
||||
/* Header stuff */
|
||||
GtkWidget *header;
|
||||
GdkPixbuf *header_logo;
|
||||
GdkGC *gc1, *gc2;
|
||||
PangoLayout *layout;
|
||||
gchar *header_text;
|
||||
|
||||
/* Sidebar */
|
||||
GtkListStore *sidebar_model;
|
||||
GtkWidget *sidebar;
|
||||
gboolean sidebar_populated;
|
||||
GdkPixbuf *arrow;
|
||||
} ListViewData;
|
||||
|
||||
enum
|
||||
{
|
||||
SIDEBAR_ICON,
|
||||
SIDEBAR_LABEL,
|
||||
SIDEBAR_ACTIVE,
|
||||
SIDEBAR_DATA
|
||||
};
|
||||
|
||||
static void
|
||||
list_clear (CappletDirView *view)
|
||||
{
|
||||
ListViewData *data = view->view_data;
|
||||
|
||||
g_return_if_fail (GNOME_IS_ICON_LIST (data->gil));
|
||||
|
||||
gnome_icon_list_clear (data->gil);
|
||||
}
|
||||
|
||||
static void
|
||||
list_clean (CappletDirView *view)
|
||||
{
|
||||
ListViewData *data = view->view_data;
|
||||
|
||||
g_object_unref (G_OBJECT (data->header_logo));
|
||||
g_object_unref (G_OBJECT (data->arrow));
|
||||
g_object_unref (G_OBJECT (data->gc1));
|
||||
g_object_unref (G_OBJECT (data->gc2));
|
||||
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* Creates a 24-bits RGB value from a GdkColor
|
||||
*/
|
||||
static guint
|
||||
rgb_from_gdk_color (GdkColor *color)
|
||||
{
|
||||
guint a =
|
||||
(((color->red >> 8) << 16) |
|
||||
((color->green >> 8) << 8) |
|
||||
((color->blue >> 8)));
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
static GnomeCanvasItem *
|
||||
flatten_alpha (GdkPixbuf *image, GnomeCanvas *canvas)
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
GtkStyle *style;
|
||||
GdkPixbuf *flat;
|
||||
guint rgb;
|
||||
|
||||
if (!image || !gdk_pixbuf_get_has_alpha (image))
|
||||
return NULL;
|
||||
|
||||
if (!GTK_WIDGET_REALIZED (GTK_WIDGET (canvas)))
|
||||
gtk_widget_realize (GTK_WIDGET (canvas));
|
||||
|
||||
style = gtk_widget_get_style (GTK_WIDGET (canvas));
|
||||
rgb = rgb_from_gdk_color (&style->base[GTK_STATE_NORMAL]);
|
||||
|
||||
flat = gdk_pixbuf_composite_color_simple (
|
||||
image,
|
||||
gdk_pixbuf_get_width (image),
|
||||
gdk_pixbuf_get_height (image),
|
||||
GDK_INTERP_NEAREST,
|
||||
255,
|
||||
32,
|
||||
rgb, rgb);
|
||||
|
||||
item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (canvas->root),
|
||||
GNOME_TYPE_CANVAS_PIXBUF,
|
||||
"pixbuf", flat,
|
||||
"height", (double)gdk_pixbuf_get_height (flat),
|
||||
"width", (double)gdk_pixbuf_get_width (flat),
|
||||
NULL);
|
||||
|
||||
gdk_pixbuf_unref (flat);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static gpointer
|
||||
real_slist_nth_data (GSList *list, guint n, guint type)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (; list; list = list->next)
|
||||
{
|
||||
if (CAPPLET_DIR_ENTRY (list->data)->type != type)
|
||||
continue;
|
||||
if (i == n)
|
||||
return list->data;
|
||||
i++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
sidebar_dummy_foreach (GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, CappletDir **dir)
|
||||
{
|
||||
GValue val = {0, };
|
||||
|
||||
g_return_if_fail (dir != NULL);
|
||||
|
||||
gtk_tree_model_get_value (model, iter, SIDEBAR_DATA, &val);
|
||||
*dir = g_value_get_pointer (&val);
|
||||
}
|
||||
|
||||
static void
|
||||
sidebar_select_cb (GtkTreeSelection *sel, CappletDirView *view)
|
||||
{
|
||||
ListViewData *data = view->view_data;
|
||||
CappletDir *dir;
|
||||
|
||||
if (data->ignore_selection)
|
||||
return;
|
||||
|
||||
gtk_tree_selection_selected_foreach (sel, (GtkTreeSelectionForeachFunc) sidebar_dummy_foreach, &dir);
|
||||
data->current = dir;
|
||||
capplet_dir_entry_activate (CAPPLET_DIR_ENTRY (dir), view);
|
||||
}
|
||||
|
||||
static void
|
||||
sidebar_arrow_update (CappletDirView *view)
|
||||
{
|
||||
ListViewData *data = view->view_data;
|
||||
GSList *list, *root;
|
||||
GtkTreeIter iter;
|
||||
int enabled, i;
|
||||
|
||||
if (!data->arrow)
|
||||
{
|
||||
gchar *file = g_build_filename (ART_DIR, "active.png", NULL);
|
||||
data->arrow = gdk_pixbuf_new_from_file (file, NULL);
|
||||
}
|
||||
|
||||
root = list = g_slist_append (NULL, data->root_dir);
|
||||
list->next = data->root_dir->entries;
|
||||
|
||||
for (enabled = 0; list; list = list->next)
|
||||
{
|
||||
CappletDirEntry *dir = CAPPLET_DIR_ENTRY (list->data);
|
||||
|
||||
if (dir->type != TYPE_CAPPLET_DIR)
|
||||
continue;
|
||||
|
||||
if (CAPPLET_DIR (dir) == data->current)
|
||||
break;
|
||||
|
||||
enabled++;
|
||||
}
|
||||
|
||||
for (i = 0, list = root; list; list = list->next)
|
||||
{
|
||||
CappletDirEntry *dir = CAPPLET_DIR_ENTRY (list->data);
|
||||
|
||||
if (dir->type != TYPE_CAPPLET_DIR)
|
||||
continue;
|
||||
|
||||
gtk_tree_model_iter_nth_child
|
||||
(GTK_TREE_MODEL (data->sidebar_model),
|
||||
&iter, NULL, i);
|
||||
gtk_list_store_set (data->sidebar_model, &iter,
|
||||
SIDEBAR_ACTIVE, (i == enabled) ? data->arrow : NULL,
|
||||
-1);
|
||||
i++;
|
||||
}
|
||||
|
||||
g_slist_free_1 (root);
|
||||
}
|
||||
|
||||
static void
|
||||
sidebar_populate (CappletDirView *view)
|
||||
{
|
||||
ListViewData *data = view->view_data;
|
||||
GSList *list, *root;
|
||||
|
||||
if (data->sidebar_populated)
|
||||
{
|
||||
sidebar_arrow_update (view);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_list_store_clear (data->sidebar_model);
|
||||
|
||||
root = list = g_slist_append (NULL, data->root_dir);
|
||||
list->next = data->root_dir->entries;
|
||||
|
||||
for (; list; list = list->next)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
CappletDirEntry *dir = CAPPLET_DIR_ENTRY (list->data);
|
||||
|
||||
if (dir->type != TYPE_CAPPLET_DIR)
|
||||
continue;
|
||||
|
||||
gtk_list_store_append (data->sidebar_model, &iter);
|
||||
gtk_list_store_set (data->sidebar_model, &iter,
|
||||
SIDEBAR_ICON, dir->icon,
|
||||
SIDEBAR_LABEL, dir->label,
|
||||
SIDEBAR_DATA, dir,
|
||||
SIDEBAR_ACTIVE, NULL,
|
||||
-1);
|
||||
}
|
||||
|
||||
g_slist_free_1 (root); /* Just this first node */
|
||||
data->sidebar_populated = TRUE;
|
||||
|
||||
sidebar_arrow_update (view);
|
||||
}
|
||||
|
||||
static void
|
||||
list_populate (CappletDirView *view)
|
||||
{
|
||||
GSList *list;
|
||||
int i;
|
||||
ListViewData *data = view->view_data;
|
||||
|
||||
g_return_if_fail (GNOME_IS_ICON_LIST (data->gil));
|
||||
|
||||
if (!data->root_dir)
|
||||
data->root_dir = view->capplet_dir;
|
||||
|
||||
data->ignore_selection = TRUE;
|
||||
sidebar_populate (view);
|
||||
|
||||
/* FIXME: Is this triggering a gtk+ bug? */
|
||||
#if 0
|
||||
gtk_tree_model_get_iter_root (GTK_TREE_MODEL (data->sidebar_model),
|
||||
&iter);
|
||||
gtk_tree_selection_select_iter (
|
||||
gtk_tree_view_get_selection (GTK_TREE_VIEW (data->sidebar)),
|
||||
&iter);
|
||||
#endif
|
||||
data->ignore_selection = FALSE;
|
||||
|
||||
gnome_icon_list_freeze (data->gil);
|
||||
|
||||
for (i = 0, list = view->capplet_dir->entries; list; list = list->next)
|
||||
{
|
||||
if (CAPPLET_DIR_ENTRY (list->data)->type == TYPE_CAPPLET_DIR)
|
||||
continue;
|
||||
|
||||
#if 0
|
||||
item = flatten_alpha (CAPPLET_DIR_ENTRY (list->data)->pb,
|
||||
GNOME_CANVAS (view->view_data));
|
||||
gnome_icon_list_insert_item (GNOME_ICON_LIST (view->view_data), i, item,
|
||||
CAPPLET_DIR_ENTRY (list->data)->label);
|
||||
#else
|
||||
gnome_icon_list_insert_pixbuf (data->gil, i++,
|
||||
CAPPLET_DIR_ENTRY (list->data)->icon, NULL,
|
||||
CAPPLET_DIR_ENTRY (list->data)->label);
|
||||
#endif
|
||||
}
|
||||
gnome_icon_list_thaw (data->gil);
|
||||
|
||||
g_free (data->header_text);
|
||||
data->header_text = g_strdup_printf (_("GNOME Control Center: %s"),
|
||||
CAPPLET_DIR_ENTRY (view->capplet_dir)->label);
|
||||
gtk_widget_queue_draw (data->header);
|
||||
}
|
||||
|
||||
static void
|
||||
select_icon_list_cb (GtkWidget *widget, gint arg1, GdkEvent *event,
|
||||
CappletDirView *view)
|
||||
{
|
||||
if (event && event->type == GDK_2BUTTON_PRESS &&
|
||||
((GdkEventButton *) event)->button == 1)
|
||||
{
|
||||
capplet_dir_entry_activate
|
||||
(real_slist_nth_data (view->capplet_dir->entries, arg1, TYPE_CAPPLET), view);
|
||||
view->selected = NULL;
|
||||
} else {
|
||||
view->selected = real_slist_nth_data (view->capplet_dir->entries, arg1, TYPE_CAPPLET);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
cdvl_key_press (GtkWidget *widget, GdkEventKey *event, CappletDirView *view)
|
||||
{
|
||||
if ((event->keyval == GDK_Return) && (view->selected)) {
|
||||
capplet_dir_entry_activate (view->selected, view);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
lighten_color (GdkColor *color)
|
||||
{
|
||||
g_return_if_fail (color != NULL);
|
||||
#define SPLIT_THE_DISTANCE(x, y) ((x) += ((y) - (x)) / 2)
|
||||
SPLIT_THE_DISTANCE (color->red, 1 << 16);
|
||||
SPLIT_THE_DISTANCE (color->green, 1 << 16);
|
||||
SPLIT_THE_DISTANCE (color->blue, 1 << 16);
|
||||
#undef SPLIT_THE_DISTANCE
|
||||
}
|
||||
|
||||
static gint
|
||||
header_expose_cb (GtkWidget *darea, GdkEventExpose *event,
|
||||
CappletDirView *view)
|
||||
{
|
||||
ListViewData *data = view->view_data;
|
||||
int tw, th;
|
||||
|
||||
int i;
|
||||
|
||||
if (!data->gc1)
|
||||
{
|
||||
GdkColor c1, c2;
|
||||
|
||||
c1 = darea->style->bg[GTK_STATE_SELECTED];
|
||||
lighten_color (&c1);
|
||||
c2 = darea->style->black;
|
||||
lighten_color (&c2);
|
||||
|
||||
data->gc1 = gdk_gc_new (darea->window);
|
||||
gdk_gc_copy (data->gc1, darea->style->white_gc);
|
||||
gdk_gc_set_rgb_fg_color (data->gc1, &c1);
|
||||
|
||||
data->gc2 = gdk_gc_new (darea->window);
|
||||
gdk_gc_copy (data->gc2, darea->style->white_gc);
|
||||
gdk_gc_set_rgb_fg_color (data->gc2, &c2);
|
||||
}
|
||||
|
||||
if (!data->layout)
|
||||
{
|
||||
PangoContext *context = gtk_widget_get_pango_context (darea);
|
||||
PangoFontDescription *desc = pango_font_description_copy (darea->style->font_desc);
|
||||
pango_font_description_set_size (desc, 16 * PANGO_SCALE);
|
||||
pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
|
||||
data->layout = pango_layout_new (context);
|
||||
pango_layout_set_font_description (data->layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
}
|
||||
|
||||
for (i = 0; i < event->area.height; i++)
|
||||
{
|
||||
int y = i + event->area.y;
|
||||
GdkGC *gc = (y % 2) ? data->gc2 : data->gc1;
|
||||
gdk_draw_line (darea->window, gc,
|
||||
event->area.x, y,
|
||||
event->area.x + event->area.width,
|
||||
y);
|
||||
}
|
||||
|
||||
if (event->area.x < 48 && event->area.y < 48)
|
||||
gdk_pixbuf_render_to_drawable_alpha (data->header_logo,
|
||||
darea->window,
|
||||
event->area.x, event->area.y,
|
||||
event->area.x, event->area.y,
|
||||
MIN (gdk_pixbuf_get_width (data->header_logo) - event->area.x, event->area.width),
|
||||
MIN (gdk_pixbuf_get_height (data->header_logo) - event->area.y, event->area.height),
|
||||
GDK_PIXBUF_ALPHA_FULL, 255,
|
||||
GDK_RGB_DITHER_MAX,
|
||||
0, 0);
|
||||
|
||||
pango_layout_set_text (data->layout, data->header_text, -1);
|
||||
pango_layout_get_pixel_size (data->layout, &tw, &th);
|
||||
gdk_draw_layout (darea->window, darea->style->white_gc,
|
||||
64, (darea->allocation.height - th) / 2,
|
||||
data->layout);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
list_create (CappletDirView *view)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
GtkWidget *w, *sw, *vbox, *hbox;
|
||||
GtkWidget *darea;
|
||||
ListViewData *data;
|
||||
gchar *title;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeSelection *sel;
|
||||
|
||||
data = view->view_data = g_new0 (ListViewData, 1);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
darea = data->header = gtk_drawing_area_new ();
|
||||
gtk_widget_set_size_request (darea, 48, 48);
|
||||
g_signal_connect (G_OBJECT (darea), "expose_event",
|
||||
(GCallback) header_expose_cb, view);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), darea, FALSE, FALSE, 0);
|
||||
|
||||
hbox = gtk_hpaned_new ();
|
||||
|
||||
data->sidebar_model = gtk_list_store_new (4,
|
||||
GDK_TYPE_PIXBUF, G_TYPE_STRING, GDK_TYPE_PIXBUF,
|
||||
G_TYPE_POINTER);
|
||||
|
||||
data->sidebar = w = gtk_tree_view_new_with_model (GTK_TREE_MODEL (data->sidebar_model));
|
||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (w), FALSE);
|
||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w),
|
||||
-1, "", renderer, "pixbuf", SIDEBAR_ICON, NULL);
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w),
|
||||
-1, "", renderer, "text", SIDEBAR_LABEL, NULL);
|
||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w),
|
||||
-1, "", renderer, "pixbuf", SIDEBAR_ACTIVE, NULL);
|
||||
|
||||
sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (w));
|
||||
gtk_tree_selection_set_mode (sel, GTK_SELECTION_BROWSE);
|
||||
g_signal_connect (G_OBJECT (sel), "changed", (GCallback) sidebar_select_cb, view);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_set_size_request (sw, 200, -1);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_NEVER,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add (GTK_CONTAINER (sw), w);
|
||||
gtk_paned_add1 (GTK_PANED (hbox), sw);
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw));
|
||||
|
||||
w = gnome_icon_list_new (100, NULL, 0);
|
||||
data->gil = GNOME_ICON_LIST (w);
|
||||
|
||||
title = g_build_filename (ART_DIR, "title.png", NULL);
|
||||
data->header_logo = gdk_pixbuf_new_from_file (title, NULL);
|
||||
g_free (title);
|
||||
|
||||
if (view->selected)
|
||||
view->capplet_dir = view->selected->dir;
|
||||
|
||||
#if 0
|
||||
if (view->capplet_dir) populate_icon_list (view);
|
||||
|
||||
if (view->selected) {
|
||||
for (i = 0, list = view->capplet_dir->entries; list; i++, list = list->next) {
|
||||
if (list->data == view->selected) {
|
||||
gnome_icon_list_select_icon (view->u.icon_list, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
g_signal_connect (G_OBJECT (w), "select-icon",
|
||||
(GCallback) select_icon_list_cb,
|
||||
view);
|
||||
|
||||
g_signal_connect (G_OBJECT (w), "key_press_event",
|
||||
G_CALLBACK (cdvl_key_press), view);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw), w);
|
||||
gtk_paned_add2 (GTK_PANED (hbox), sw);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show_all (vbox);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
CappletDirViewImpl capplet_dir_view_list = {
|
||||
list_clear,
|
||||
list_clean,
|
||||
list_populate,
|
||||
list_create
|
||||
};
|
|
@ -1,560 +0,0 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* capplet-dir-view.c
|
||||
* Copyright (C) 2000, 2001 Ximian, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@ximian.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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <libgnomeui/gnome-window-icon.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include "capplet-dir-view.h"
|
||||
|
||||
extern CappletDirViewImpl capplet_dir_view_list;
|
||||
#if 0
|
||||
extern CappletDirViewImpl capplet_dir_view_tree;
|
||||
#endif
|
||||
|
||||
CappletDirViewImpl *capplet_dir_view_impl[] = {
|
||||
NULL,
|
||||
&capplet_dir_view_list,
|
||||
#if 0
|
||||
&capplet_dir_view_tree,
|
||||
#endif
|
||||
};
|
||||
|
||||
static GObjectClass *parent_class;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CAPPLET_DIR,
|
||||
PROP_LAYOUT
|
||||
};
|
||||
|
||||
static GList *window_list;
|
||||
static gboolean authed;
|
||||
|
||||
static void capplet_dir_view_init (CappletDirView *capplet_dir_view,
|
||||
CappletDirViewClass *class);
|
||||
static void capplet_dir_view_class_init (CappletDirViewClass *class);
|
||||
|
||||
static void capplet_dir_view_set_prop (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void capplet_dir_view_get_prop (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void capplet_dir_view_finalize (GObject *object);
|
||||
|
||||
static void close_cb (BonoboUIComponent *uic,
|
||||
gpointer data,
|
||||
const char *cname);
|
||||
static void help_menu_cb (BonoboUIComponent *uic,
|
||||
gpointer data,
|
||||
const char *cname);
|
||||
static void about_menu_cb (BonoboUIComponent *uic,
|
||||
gpointer data,
|
||||
const char *cname);
|
||||
|
||||
GType
|
||||
capplet_dir_view_get_type (void)
|
||||
{
|
||||
static GtkType capplet_dir_view_type = 0;
|
||||
|
||||
if (!capplet_dir_view_type) {
|
||||
static const GTypeInfo capplet_dir_view_info = {
|
||||
sizeof (CappletDirViewClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) capplet_dir_view_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (CappletDirView),
|
||||
0 /* n_preallocs */,
|
||||
(GInstanceInitFunc) capplet_dir_view_init
|
||||
};
|
||||
|
||||
capplet_dir_view_type =
|
||||
g_type_register_static (G_TYPE_OBJECT,
|
||||
"CappletDirView",
|
||||
&capplet_dir_view_info,
|
||||
0);
|
||||
}
|
||||
|
||||
return capplet_dir_view_type;
|
||||
}
|
||||
|
||||
static BonoboUIVerb capplet_dir_view_verbs[] = {
|
||||
BONOBO_UI_VERB ("FileClose", close_cb),
|
||||
BONOBO_UI_VERB ("HelpContent", help_menu_cb),
|
||||
BONOBO_UI_VERB ("HelpAbout", about_menu_cb),
|
||||
BONOBO_UI_VERB_END
|
||||
};
|
||||
|
||||
static void
|
||||
capplet_dir_view_init (CappletDirView *view, CappletDirViewClass *class)
|
||||
{
|
||||
BonoboUIContainer *ui_container;
|
||||
BonoboUIComponent *ui_component;
|
||||
|
||||
window_list = g_list_prepend (window_list, view);
|
||||
|
||||
view->app = BONOBO_WINDOW (bonobo_window_new ("gnomecc", ""));
|
||||
ui_container = bonobo_window_get_ui_container (view->app);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (view->app), 620, 430);
|
||||
gnome_window_icon_set_from_file (GTK_WINDOW (view->app),
|
||||
PIXMAP_DIR "/control-center2.png");
|
||||
|
||||
ui_component = bonobo_ui_component_new ("gnomecc");
|
||||
bonobo_ui_component_set_container (ui_component, bonobo_object_corba_objref (BONOBO_OBJECT (ui_container)), NULL);
|
||||
bonobo_ui_util_set_ui (ui_component,
|
||||
GNOMECC_DATA_DIR, "gnomecc-ui.xml", "gnomecc", NULL);
|
||||
|
||||
g_signal_connect_swapped (G_OBJECT (view->app), "destroy",
|
||||
(GCallback) g_object_unref, view);
|
||||
|
||||
bonobo_ui_component_add_verb_list_with_data (ui_component, capplet_dir_view_verbs, view);
|
||||
}
|
||||
|
||||
static void
|
||||
capplet_dir_view_class_init (CappletDirViewClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = capplet_dir_view_finalize;
|
||||
object_class->set_property = capplet_dir_view_set_prop;
|
||||
object_class->get_property = capplet_dir_view_get_prop;
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_LAYOUT,
|
||||
g_param_spec_int ("layout",
|
||||
_("Layout"),
|
||||
_("Layout to use for this view of the capplets"),
|
||||
0, sizeof (capplet_dir_view_impl) / sizeof (CappletDirViewImpl *), 0,
|
||||
G_PARAM_WRITABLE));
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CAPPLET_DIR,
|
||||
g_param_spec_pointer ("capplet-dir",
|
||||
_("Capplet directory object"),
|
||||
_("Capplet directory that this view is viewing"),
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
parent_class = G_OBJECT_CLASS (g_type_class_ref (G_TYPE_OBJECT));
|
||||
}
|
||||
|
||||
static void
|
||||
capplet_dir_view_set_prop (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
CappletDirView *view;
|
||||
CappletDirViewLayout layout;
|
||||
|
||||
view = CAPPLET_DIR_VIEW (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_CAPPLET_DIR:
|
||||
capplet_dir_view_load_dir (view, g_value_get_pointer (value));
|
||||
break;
|
||||
|
||||
case PROP_LAYOUT:
|
||||
#ifdef USE_HTML
|
||||
layout = CLAMP (g_value_get_int (value), 0, LAYOUT_HTML);
|
||||
#else
|
||||
layout = CLAMP (g_value_get_int (value), 0, LAYOUT_ICON_LIST);
|
||||
#endif
|
||||
|
||||
if (layout == view->layout)
|
||||
break;
|
||||
|
||||
g_assert (!view->changing_layout);
|
||||
view->changing_layout = TRUE;
|
||||
|
||||
if (view->impl && view->impl->clean)
|
||||
view->impl->clean (view);
|
||||
|
||||
view->layout =layout;
|
||||
view->impl = capplet_dir_view_impl[layout];
|
||||
|
||||
if (view->impl && view->impl->create) {
|
||||
view->view = view->impl->create (view);
|
||||
|
||||
bonobo_window_set_contents (view->app, view->view);
|
||||
|
||||
if (view->capplet_dir && view->impl->populate)
|
||||
view->impl->populate (view);
|
||||
|
||||
gtk_widget_show (view->view);
|
||||
}
|
||||
|
||||
view->changing_layout = FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Bad argument set");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
capplet_dir_view_get_prop (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
CappletDirView *view;
|
||||
|
||||
view = CAPPLET_DIR_VIEW (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_CAPPLET_DIR:
|
||||
g_value_set_pointer (value, view->capplet_dir);
|
||||
break;
|
||||
|
||||
case PROP_LAYOUT:
|
||||
g_value_set_uint (value, view->layout);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Bad argument get");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
capplet_dir_view_finalize (GObject *object)
|
||||
{
|
||||
CappletDirView *view;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (IS_CAPPLET_DIR_VIEW (object));
|
||||
|
||||
view = CAPPLET_DIR_VIEW (object);
|
||||
|
||||
view->capplet_dir->view = NULL;
|
||||
|
||||
window_list = g_list_remove (window_list, view);
|
||||
|
||||
if (g_list_length (window_list) == 0)
|
||||
gtk_main_quit ();
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
void
|
||||
capplet_dir_view_update_authenticated (CappletDirView *view, gpointer null)
|
||||
{
|
||||
}
|
||||
|
||||
CappletDirView *
|
||||
capplet_dir_view_new (void)
|
||||
{
|
||||
GObject *view;
|
||||
|
||||
view = g_object_new (capplet_dir_view_get_type (),
|
||||
"layout", LAYOUT_ICON_LIST,
|
||||
NULL);
|
||||
|
||||
capplet_dir_view_update_authenticated
|
||||
(CAPPLET_DIR_VIEW (view), NULL);
|
||||
|
||||
return CAPPLET_DIR_VIEW (view);
|
||||
}
|
||||
|
||||
void
|
||||
capplet_dir_views_set_authenticated (gboolean amiauthedornot)
|
||||
{
|
||||
authed = amiauthedornot;
|
||||
g_list_foreach (window_list, (GFunc)capplet_dir_view_update_authenticated, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
close_cb (BonoboUIComponent *uic, gpointer data, const char *cname)
|
||||
{
|
||||
CappletDirView *view = CAPPLET_DIR_VIEW (data);
|
||||
gtk_widget_destroy (GTK_WIDGET (CAPPLET_DIR_VIEW_W (view)));
|
||||
}
|
||||
|
||||
static void
|
||||
help_menu_cb (BonoboUIComponent *uic, gpointer data, const char *cname)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
gnome_help_display_desktop (NULL,
|
||||
"user-guide",
|
||||
"user-guide.xml",
|
||||
NULL, &error);
|
||||
if (error) {
|
||||
GtkWidget *dialog;
|
||||
dialog = gtk_message_dialog_new (NULL,
|
||||
GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
("There was an error displaying help: \n%s"),
|
||||
error->message);
|
||||
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (gtk_widget_destroy),
|
||||
NULL);
|
||||
|
||||
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
|
||||
gtk_widget_show (dialog);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
about_menu_cb (BonoboUIComponent *uic, gpointer data, const char *cname)
|
||||
{
|
||||
static GtkWidget *about = NULL;
|
||||
static gchar *authors[] = {
|
||||
"Jacob Berkman <jacob@ximian.com>",
|
||||
"Jonathan Blandford <jrb@redhat.com>",
|
||||
"Chema Celorio <chema@ximian.com>",
|
||||
"Rachel Hestilow <hestilow@ximian.com>",
|
||||
"Bradford Hovinen <hovinen@ximian.com>",
|
||||
"Lauris Kaplinski <lauris@ximian.com>",
|
||||
"Seth Nickell <snickell@stanford.edu>",
|
||||
"Jakub Steiner <jimmac@ximian.com>",
|
||||
NULL
|
||||
};
|
||||
|
||||
static gchar *documenters[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
gchar *translator_credits = _("translator_credits");
|
||||
|
||||
if (about != NULL) {
|
||||
gdk_window_show (about->window);
|
||||
gdk_window_raise (about->window);
|
||||
return;
|
||||
}
|
||||
|
||||
about = gnome_about_new
|
||||
(_("GNOME Control Center"), VERSION,
|
||||
"Copyright (C) 2000, 2001 Ximian, Inc.\n"
|
||||
"Copyright (C) 1999 Red Hat Software, Inc.",
|
||||
_("Desktop properties manager."),
|
||||
(const gchar **) authors,
|
||||
(const gchar **) documenters,
|
||||
strcmp (translator_credits, "translator_credits") != 0 ? translator_credits : NULL,
|
||||
NULL);
|
||||
|
||||
g_signal_connect (G_OBJECT (about), "destroy",
|
||||
(GCallback) gtk_widget_destroyed,
|
||||
&about);
|
||||
|
||||
gtk_widget_show (about);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
static void
|
||||
menu_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
|
||||
{
|
||||
if (!GTK_CHECK_MENU_ITEM (w)->active || view->changing_layout)
|
||||
return;
|
||||
|
||||
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_HTML
|
||||
static void
|
||||
html_menu_cb (GtkWidget *w, CappletDirView *view)
|
||||
{
|
||||
menu_cb (w, view, LAYOUT_HTML);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
static void
|
||||
icon_menu_cb (GtkWidget *w, CappletDirView *view)
|
||||
{
|
||||
menu_cb (w, view, LAYOUT_ICON_LIST);
|
||||
}
|
||||
|
||||
static void
|
||||
tree_menu_cb (GtkWidget *w, CappletDirView *view)
|
||||
{
|
||||
menu_cb (w, view, LAYOUT_TREE);
|
||||
}
|
||||
|
||||
static void
|
||||
button_cb (GtkWidget *w, CappletDirView *view, CappletDirViewLayout layout)
|
||||
{
|
||||
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)) || view->changing_layout)
|
||||
return;
|
||||
|
||||
gtk_object_set (GTK_OBJECT (view), "layout", layout, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_HTML
|
||||
static void
|
||||
html_toggle_cb (GtkWidget *w, CappletDirView *view)
|
||||
{
|
||||
button_cb (w, view, LAYOUT_HTML);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
static void
|
||||
list_toggle_cb (GtkWidget *w, CappletDirView *view)
|
||||
{
|
||||
button_cb (w, view, LAYOUT_ICON_LIST);
|
||||
}
|
||||
|
||||
static void
|
||||
tree_toggle_cb (GtkWidget *w, CappletDirView *view)
|
||||
{
|
||||
button_cb (w, view, LAYOUT_TREE);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
prefs_menu_cb (GtkWidget *widget, CappletDirView *view)
|
||||
{
|
||||
gnomecc_preferences_get_config_dialog (prefs);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
back_button_cb (GtkWidget *widget, CappletDirView *view)
|
||||
{
|
||||
if (CAPPLET_DIR_ENTRY (view->capplet_dir)->dir)
|
||||
capplet_dir_view_load_dir
|
||||
(view, CAPPLET_DIR_ENTRY (view->capplet_dir)->dir);
|
||||
}
|
||||
|
||||
static void
|
||||
rootm_button_cb (GtkWidget *w, CappletDirView *view)
|
||||
{
|
||||
gdk_beep ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
option_menu_activate (GtkWidget *w, CappletDirEntry *entry)
|
||||
{
|
||||
CappletDirView *view;
|
||||
|
||||
view = g_object_get_data (G_OBJECT (w), "user_data");
|
||||
if (!IS_CAPPLET_DIR_VIEW (view))
|
||||
return;
|
||||
|
||||
capplet_dir_entry_activate (entry, view);
|
||||
}
|
||||
|
||||
void
|
||||
capplet_dir_view_load_dir (CappletDirView *view, CappletDir *dir)
|
||||
{
|
||||
GtkWidget *menu, *menuitem, *w, *hbox;
|
||||
CappletDirEntry *entry;
|
||||
int parents = 0;
|
||||
gchar *title;
|
||||
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (IS_CAPPLET_DIR_VIEW (view));
|
||||
|
||||
view->capplet_dir = dir;
|
||||
|
||||
if (view->impl && view->impl->clear)
|
||||
view->impl->clear (view);
|
||||
|
||||
if (!dir || view->layout == LAYOUT_NONE) return;
|
||||
|
||||
if (view->impl && view->impl->populate)
|
||||
view->impl->populate (view);
|
||||
|
||||
title = g_strdup_printf (_("Gnome Control Center : %s"), dir->entry.label);
|
||||
gtk_window_set_title (GTK_WINDOW (view->app), title);
|
||||
g_free (title);
|
||||
|
||||
menu = gtk_menu_new ();
|
||||
|
||||
for (entry = CAPPLET_DIR_ENTRY (dir); entry; entry = CAPPLET_DIR_ENTRY (entry->dir), parents++) {
|
||||
GdkPixbuf *pbs;
|
||||
|
||||
menuitem = gtk_menu_item_new ();
|
||||
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
|
||||
|
||||
#if 0
|
||||
w = gnome_pixmap_new_from_file_at_size (entry->icon, 16, 16);
|
||||
#else
|
||||
pbs = gdk_pixbuf_scale_simple (entry->icon, 16, 16, GDK_INTERP_HYPER);
|
||||
w = gtk_image_new_from_pixbuf (pbs);
|
||||
g_object_unref (pbs);
|
||||
#endif
|
||||
gtk_box_pack_start (GTK_BOX (hbox), w,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
w = gtk_label_new (entry->label);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), w,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (menuitem), hbox);
|
||||
|
||||
if (entry != CAPPLET_DIR_ENTRY (dir)) {
|
||||
g_object_set_data (G_OBJECT (menuitem), "user_data", view);
|
||||
g_signal_connect (G_OBJECT (menuitem), "activate",
|
||||
(GCallback) option_menu_activate,
|
||||
entry);
|
||||
}
|
||||
|
||||
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menuitem);
|
||||
}
|
||||
gtk_widget_show_all (menu);
|
||||
}
|
||||
|
||||
void
|
||||
capplet_dir_view_show (CappletDirView *view)
|
||||
{
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (IS_CAPPLET_DIR_VIEW (view));
|
||||
|
||||
gtk_widget_show (GTK_WIDGET (CAPPLET_DIR_VIEW_W (view)));
|
||||
}
|
||||
|
||||
static CappletDirView *
|
||||
get_capplet_dir_view (CappletDir *dir, CappletDirView *launcher)
|
||||
{
|
||||
if (launcher)
|
||||
return launcher;
|
||||
else
|
||||
return CAPPLET_DIR_VIEW (capplet_dir_view_new ());
|
||||
}
|
||||
|
||||
void
|
||||
gnomecc_init (void)
|
||||
{
|
||||
capplet_dir_init (get_capplet_dir_view);
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* capplet-dir-view.h
|
||||
* Copyright (C) 2000, 2001 Ximian, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@ximian.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.
|
||||
*/
|
||||
|
||||
#ifndef __CAPPLET_DIR_VIEW
|
||||
#define __CAPPLET_DIR_VIEW
|
||||
|
||||
#include <gnome.h>
|
||||
#include <libbonoboui.h>
|
||||
|
||||
#include "capplet-dir.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CAPPLET_DIR_VIEW(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, capplet_dir_view_get_type (), CappletDirView)
|
||||
#define CAPPLET_DIR_VIEW_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, capplet_dir_view_get_type (), CappletDirViewClass)
|
||||
#define IS_CAPPLET_DIR_VIEW(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, capplet_dir_view_get_type ())
|
||||
#define CAPPLET_DIR_VIEW_W(obj) (CAPPLET_DIR_VIEW (obj)->app)
|
||||
|
||||
typedef struct _CappletDirViewClass CappletDirViewClass;
|
||||
typedef struct _CappletDirViewImpl CappletDirViewImpl;
|
||||
|
||||
typedef void (*CDVFunc) (CappletDirView *);
|
||||
|
||||
struct _CappletDirViewImpl
|
||||
{
|
||||
/* remove entries from view */
|
||||
CDVFunc clear;
|
||||
|
||||
/* clean up (destroy widgets) */
|
||||
CDVFunc clean;
|
||||
|
||||
CDVFunc populate;
|
||||
|
||||
GtkWidget *(*create) (CappletDirView *);
|
||||
};
|
||||
|
||||
typedef enum _CappletDirViewLayout {
|
||||
LAYOUT_NONE,
|
||||
LAYOUT_ICON_LIST
|
||||
#ifdef USE_HTML
|
||||
, LAYOUT_HTML
|
||||
#endif
|
||||
} CappletDirViewLayout;
|
||||
|
||||
struct _CappletDirView
|
||||
{
|
||||
GObject parent;
|
||||
BonoboWindow *app;
|
||||
|
||||
CappletDir *capplet_dir;
|
||||
CappletDirEntry *selected;
|
||||
|
||||
CappletDirViewImpl *impl;
|
||||
|
||||
GtkWidget *view;
|
||||
gpointer view_data;
|
||||
|
||||
gboolean destroyed;
|
||||
CappletDirViewLayout layout;
|
||||
|
||||
gboolean changing_layout;
|
||||
};
|
||||
|
||||
struct _CappletDirViewClass
|
||||
{
|
||||
GObjectClass parent;
|
||||
};
|
||||
|
||||
GType capplet_dir_view_get_type (void);
|
||||
|
||||
CappletDirView *capplet_dir_view_new (void);
|
||||
void capplet_dir_view_destroy (CappletDirView *view);
|
||||
|
||||
void capplet_dir_view_load_dir (CappletDirView *view,
|
||||
CappletDir *dir);
|
||||
void capplet_dir_view_show (CappletDirView *view);
|
||||
|
||||
void capplet_dir_views_set_authenticated (gboolean authed);
|
||||
|
||||
void gnomecc_init (void);
|
||||
|
||||
#endif /* __CAPPLET_DIR_VIEW */
|
|
@ -1,510 +0,0 @@
|
|||
/* vim: set sw=8: -*- mode: c; style: linux -*- */
|
||||
|
||||
/* capplet-dir.c
|
||||
* Copyright (C) 2000, 2001 Ximian, Inc.
|
||||
* Copyright (C) 1998 Red Hat Software, Inc.
|
||||
*
|
||||
* Written by 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.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "capplet-dir.h"
|
||||
#include "capplet-dir-view.h"
|
||||
|
||||
static void capplet_activate (Capplet *capplet);
|
||||
static void capplet_dir_activate (CappletDir *capplet_dir,
|
||||
CappletDirView *launcher);
|
||||
|
||||
static void capplet_shutdown (Capplet *capplet);
|
||||
static void capplet_dir_shutdown (CappletDir *capplet_dir);
|
||||
|
||||
static GSList *read_entries (CappletDir *dir);
|
||||
|
||||
#ifdef USE_ROOT_MANAGER
|
||||
static void start_capplet_through_root_manager (GnomeDesktopItem *gde);
|
||||
#endif
|
||||
|
||||
CappletDirView *(*get_view_cb) (CappletDir *dir, CappletDirView *launcher);
|
||||
|
||||
/* nice global table for capplet lookup */
|
||||
GHashTable *capplet_hash = NULL;
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
guint i;
|
||||
const char *suffix;
|
||||
static const char *icon_file_name_suffixes[] = { ".svg", ".svgz", ".png", ".jpg", ".xpm" };
|
||||
|
||||
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);
|
||||
}
|
||||
/********************************************************************/
|
||||
|
||||
static GdkPixbuf *
|
||||
find_icon (GnomeDesktopItem *dentry)
|
||||
{
|
||||
GdkPixbuf *res;
|
||||
char const *icon;
|
||||
GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
|
||||
|
||||
icon = gnome_desktop_item_get_string (dentry, GNOME_DESKTOP_ITEM_ICON);
|
||||
|
||||
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);
|
||||
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);
|
||||
g_free (path);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
CappletDirEntry *
|
||||
capplet_new (CappletDir *dir, gchar *desktop_path)
|
||||
{
|
||||
Capplet *capplet;
|
||||
CappletDirEntry *entry;
|
||||
GnomeDesktopItem *dentry;
|
||||
gchar *path, **vec;
|
||||
const gchar *execstr;
|
||||
|
||||
g_return_val_if_fail (desktop_path != NULL, NULL);
|
||||
|
||||
entry = g_hash_table_lookup (capplet_hash, desktop_path);
|
||||
if (entry) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
dentry = gnome_desktop_item_new_from_uri (desktop_path,
|
||||
GNOME_DESKTOP_ITEM_TYPE_NULL,
|
||||
NULL);
|
||||
if (dentry == NULL)
|
||||
return NULL;
|
||||
|
||||
execstr = gnome_desktop_item_get_string (dentry,
|
||||
GNOME_DESKTOP_ITEM_EXEC);
|
||||
/* Perhaps use poptParseArgvString here */
|
||||
vec = g_strsplit (execstr, " ", 0);
|
||||
if (!(execstr && execstr[0]) || !(vec && (path = g_find_program_in_path (vec[0]))))
|
||||
{
|
||||
g_strfreev (vec);
|
||||
gnome_desktop_item_unref (dentry);
|
||||
return NULL;
|
||||
}
|
||||
g_free (path);
|
||||
|
||||
capplet = g_new0 (Capplet, 1);
|
||||
capplet->launching = FALSE;
|
||||
|
||||
entry = CAPPLET_DIR_ENTRY (capplet);
|
||||
|
||||
entry->type = TYPE_CAPPLET;
|
||||
entry->entry = dentry;
|
||||
|
||||
entry->label = g_strdup (gnome_desktop_item_get_localestring (dentry,
|
||||
GNOME_DESKTOP_ITEM_NAME));
|
||||
entry->icon = find_icon (dentry);
|
||||
entry->uri = gnome_vfs_uri_new (desktop_path);
|
||||
entry->exec = vec;
|
||||
entry->dir = dir;
|
||||
|
||||
g_hash_table_insert (capplet_hash, g_strdup (desktop_path), entry);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
CappletDirEntry *
|
||||
capplet_dir_new (CappletDir *dir, gchar *dir_path)
|
||||
{
|
||||
CappletDir *capplet_dir;
|
||||
CappletDirEntry *entry;
|
||||
GnomeVFSURI *desktop_uri;
|
||||
GnomeVFSURI *dir_uri;
|
||||
char *desktop_uri_string;
|
||||
|
||||
g_return_val_if_fail (dir_path != NULL, NULL);
|
||||
|
||||
dir_uri = gnome_vfs_uri_new (dir_path);
|
||||
|
||||
entry = g_hash_table_lookup (capplet_hash, dir_path);
|
||||
if (entry) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
desktop_uri = gnome_vfs_uri_append_file_name (dir_uri, ".directory");
|
||||
desktop_uri_string = gnome_vfs_uri_to_string (desktop_uri, GNOME_VFS_URI_HIDE_NONE);
|
||||
|
||||
capplet_dir = g_new0 (CappletDir, 1);
|
||||
entry = CAPPLET_DIR_ENTRY (capplet_dir);
|
||||
|
||||
entry->type = TYPE_CAPPLET_DIR;
|
||||
entry->entry = gnome_desktop_item_new_from_uri (desktop_uri_string,
|
||||
GNOME_DESKTOP_ITEM_TYPE_NULL,
|
||||
NULL);
|
||||
entry->dir = dir;
|
||||
entry->uri = dir_uri;
|
||||
|
||||
gnome_vfs_uri_unref (desktop_uri);
|
||||
g_free (desktop_uri_string);
|
||||
|
||||
if (entry->entry) {
|
||||
entry->label = g_strdup (gnome_desktop_item_get_localestring (
|
||||
entry->entry,
|
||||
GNOME_DESKTOP_ITEM_NAME));
|
||||
entry->icon = find_icon (entry->entry);
|
||||
} else {
|
||||
/* If the .directory file could not be found or read, abort */
|
||||
g_free (capplet_dir);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
entry->dir = dir;
|
||||
|
||||
g_hash_table_insert (capplet_hash, g_strdup (dir_path), entry);
|
||||
|
||||
capplet_dir_load (CAPPLET_DIR (entry));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
CappletDirEntry *
|
||||
capplet_lookup (const char *path)
|
||||
{
|
||||
return g_hash_table_lookup (capplet_hash, path);
|
||||
}
|
||||
|
||||
void
|
||||
capplet_dir_entry_destroy (CappletDirEntry *entry)
|
||||
{
|
||||
if (entry->type == TYPE_CAPPLET) {
|
||||
capplet_shutdown (CAPPLET (entry));
|
||||
} else {
|
||||
capplet_dir_shutdown (CAPPLET_DIR (entry));
|
||||
}
|
||||
|
||||
g_free (entry->label);
|
||||
g_object_unref (entry->icon);
|
||||
gnome_vfs_uri_unref (entry->uri);
|
||||
g_strfreev (entry->exec);
|
||||
gnome_desktop_item_unref (entry->entry);
|
||||
g_free (entry);
|
||||
}
|
||||
|
||||
void
|
||||
capplet_dir_entry_activate (CappletDirEntry *entry,
|
||||
CappletDirView *launcher)
|
||||
{
|
||||
g_return_if_fail (entry != NULL);
|
||||
|
||||
if (entry->type == TYPE_CAPPLET)
|
||||
capplet_activate (CAPPLET (entry));
|
||||
else if (entry->type == TYPE_CAPPLET_DIR)
|
||||
capplet_dir_activate (CAPPLET_DIR (entry), launcher);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
void
|
||||
capplet_dir_entry_shutdown (CappletDirEntry *entry)
|
||||
{
|
||||
if (entry->type == TYPE_CAPPLET)
|
||||
capplet_shutdown (CAPPLET (entry));
|
||||
else if (entry->type == TYPE_CAPPLET_DIR)
|
||||
capplet_dir_shutdown (CAPPLET_DIR (entry));
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static gint
|
||||
capplet_reset_cb (Capplet *capplet)
|
||||
{
|
||||
capplet->launching = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
capplet_activate (Capplet *capplet)
|
||||
{
|
||||
CappletDirEntry *entry;
|
||||
|
||||
entry = CAPPLET_DIR_ENTRY (capplet);
|
||||
|
||||
if (capplet->launching) {
|
||||
return;
|
||||
} else {
|
||||
capplet->launching = TRUE;
|
||||
gtk_timeout_add (1000, (GtkFunction) capplet_reset_cb, capplet);
|
||||
gnome_desktop_item_launch (entry->entry, NULL, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
capplet_dir_load (CappletDir *capplet_dir)
|
||||
{
|
||||
if (capplet_dir->entries) return;
|
||||
capplet_dir->entries = read_entries (capplet_dir);
|
||||
}
|
||||
|
||||
static void
|
||||
capplet_dir_activate (CappletDir *capplet_dir, CappletDirView *launcher)
|
||||
{
|
||||
capplet_dir_load (capplet_dir);
|
||||
capplet_dir->view = get_view_cb (capplet_dir, launcher);
|
||||
|
||||
capplet_dir_view_load_dir (capplet_dir->view, capplet_dir);
|
||||
capplet_dir_view_show (capplet_dir->view);
|
||||
}
|
||||
|
||||
static void
|
||||
capplet_shutdown (Capplet *capplet)
|
||||
{
|
||||
/* Can't do much here ... :-( */
|
||||
}
|
||||
|
||||
static void
|
||||
cde_destroy (CappletDirEntry *e, gpointer null)
|
||||
{
|
||||
capplet_dir_entry_destroy (e);
|
||||
}
|
||||
|
||||
static void
|
||||
capplet_dir_shutdown (CappletDir *capplet_dir)
|
||||
{
|
||||
if (capplet_dir->view)
|
||||
g_object_unref (G_OBJECT (capplet_dir->view));
|
||||
|
||||
g_slist_foreach (capplet_dir->entries, (GFunc) cde_destroy, NULL);
|
||||
|
||||
g_slist_free (capplet_dir->entries);
|
||||
}
|
||||
|
||||
static gint
|
||||
node_compare (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return strcmp (CAPPLET_DIR_ENTRY (a)->label,
|
||||
CAPPLET_DIR_ENTRY (b)->label);
|
||||
}
|
||||
|
||||
/* Adapted from the original control center... */
|
||||
|
||||
static GSList *
|
||||
read_entries (CappletDir *dir)
|
||||
{
|
||||
GSList *list = NULL;
|
||||
CappletDirEntry *entry;
|
||||
gchar *fullpath, *test;
|
||||
GnomeVFSURI *fulluri;
|
||||
GnomeVFSDirectoryHandle *parent_dir;
|
||||
GnomeVFSResult result;
|
||||
|
||||
GnomeVFSFileInfo *child = gnome_vfs_file_info_new ();
|
||||
|
||||
result = gnome_vfs_directory_open_from_uri (&parent_dir, CAPPLET_DIR_ENTRY (dir)->uri,
|
||||
GNOME_VFS_FILE_INFO_DEFAULT);
|
||||
|
||||
if (result != GNOME_VFS_OK) {
|
||||
gnome_vfs_file_info_unref (child);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ( gnome_vfs_directory_read_next (parent_dir, child) == GNOME_VFS_OK ) {
|
||||
if (child->name[0] == '.')
|
||||
continue;
|
||||
|
||||
fulluri = gnome_vfs_uri_append_path (CAPPLET_DIR_ENTRY (dir)->uri, child->name);
|
||||
fullpath = gnome_vfs_uri_to_string (fulluri, GNOME_VFS_URI_HIDE_NONE);
|
||||
|
||||
entry = NULL;
|
||||
|
||||
if (child->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
|
||||
entry = capplet_dir_new (dir, fullpath);
|
||||
} else {
|
||||
test = strrchr(child->name, '.');
|
||||
|
||||
/* if it's a .desktop file, it's interesting for sure! */
|
||||
if (test && !strcmp (".desktop", test))
|
||||
entry = capplet_new (dir, fullpath);
|
||||
}
|
||||
|
||||
if (entry)
|
||||
list = g_slist_prepend (list, entry);
|
||||
|
||||
g_free (fullpath);
|
||||
}
|
||||
|
||||
gnome_vfs_file_info_unref (child);
|
||||
gnome_vfs_directory_close (parent_dir);
|
||||
|
||||
list = g_slist_sort (list, node_compare);
|
||||
|
||||
/* remove FALSE for parent entry */
|
||||
return FALSE && CAPPLET_DIR_ENTRY (dir)->dir
|
||||
? g_slist_prepend (list, CAPPLET_DIR_ENTRY (dir)->dir)
|
||||
: list;
|
||||
}
|
||||
|
||||
#ifdef USE_ROOT_MANAGER
|
||||
static void
|
||||
start_capplet_through_root_manager (GnomeDesktopItem *gde)
|
||||
{
|
||||
static FILE *output = NULL;
|
||||
pid_t pid;
|
||||
char *cmdline;
|
||||
char *oldexec;
|
||||
|
||||
if (!output) {
|
||||
gint pipe_fd[2];
|
||||
pipe (pipe_fd);
|
||||
|
||||
pid = fork ();
|
||||
|
||||
if (pid == (pid_t) -1) {
|
||||
g_error ("%s", g_strerror (errno));
|
||||
} else if (pid == 0) {
|
||||
char *arg[2];
|
||||
int i;
|
||||
|
||||
dup2 (pipe_fd[0], STDIN_FILENO);
|
||||
|
||||
for (i = 3; i < FOPEN_MAX; i++) close(i);
|
||||
|
||||
arg[0] = gnome_is_program_in_path ("root-manager-helper");
|
||||
arg[1] = NULL;
|
||||
execv (arg[0], arg);
|
||||
} else {
|
||||
output = fdopen(pipe_fd[1], "a");
|
||||
}
|
||||
|
||||
capplet_dir_views_set_authenticated (TRUE);
|
||||
}
|
||||
|
||||
|
||||
oldexec = gde->exec[1];
|
||||
gde->exec[1] = g_concat_dir_and_file (GNOME_SBINDIR, oldexec);
|
||||
|
||||
cmdline = g_strjoinv (" ", gde->exec + 1);
|
||||
|
||||
g_free (gde->exec[1]);
|
||||
gde->exec[1] = oldexec;
|
||||
|
||||
fprintf (output, "%s\n", cmdline);
|
||||
fflush (output);
|
||||
g_free (cmdline);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
capplet_dir_init (CappletDirView *(*cb) (CappletDir *, CappletDirView *))
|
||||
{
|
||||
get_view_cb = cb;
|
||||
capplet_hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
}
|
||||
|
||||
CappletDir *
|
||||
get_root_capplet_dir (void)
|
||||
{
|
||||
static CappletDir *root_dir = NULL;
|
||||
|
||||
if (root_dir == NULL) {
|
||||
CappletDirEntry *entry;
|
||||
|
||||
entry = capplet_dir_new (NULL, "preferences:///");
|
||||
|
||||
if (entry)
|
||||
root_dir = CAPPLET_DIR (entry);
|
||||
if (!root_dir)
|
||||
g_warning ("Could not find directory of control panels [%s]", "preferences:///");
|
||||
}
|
||||
|
||||
return root_dir;
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* capplet-dir.h
|
||||
* Copyright (C) 2000, 2001 Ximian, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@ximian.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.
|
||||
*/
|
||||
|
||||
#ifndef __CAPPLET_DIR_H
|
||||
#define __CAPPLET_DIR_H
|
||||
|
||||
#include <gnome.h>
|
||||
#include <libgnome/gnome-desktop-item.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <libgnomevfs/gnome-vfs.h>
|
||||
|
||||
#define CAPPLET_DIR_ENTRY(obj) ((CappletDirEntry *) obj)
|
||||
#define CAPPLET_DIR(obj) ((CappletDir *) obj)
|
||||
#define CAPPLET(obj) ((Capplet *) obj)
|
||||
|
||||
#define IS_CAPPLET(obj) (((CappletDirEntry *) obj)->type == TYPE_CAPPLET)
|
||||
#define IS_CAPPLET_DIR(obj) (((CappletDirEntry *) obj)->type == TYPE_CAPPLET_DIR)
|
||||
|
||||
typedef struct _CappletDirEntry CappletDirEntry;
|
||||
typedef struct _CappletDir CappletDir;
|
||||
typedef struct _Capplet Capplet;
|
||||
|
||||
typedef struct _CappletDirView CappletDirView;
|
||||
|
||||
typedef enum {
|
||||
TYPE_CAPPLET,
|
||||
TYPE_CAPPLET_DIR
|
||||
} CappletEntryType;
|
||||
|
||||
struct _CappletDirEntry
|
||||
{
|
||||
CappletEntryType type;
|
||||
GnomeDesktopItem *entry;
|
||||
gchar **exec;
|
||||
gchar *label;
|
||||
GnomeVFSURI *uri;
|
||||
GdkPixbuf *icon;
|
||||
CappletDir *dir;
|
||||
};
|
||||
|
||||
struct _CappletDir
|
||||
{
|
||||
CappletDirEntry entry;
|
||||
GSList *entries;
|
||||
CappletDirView *view;
|
||||
};
|
||||
|
||||
struct _Capplet
|
||||
{
|
||||
CappletDirEntry entry;
|
||||
gboolean launching;
|
||||
};
|
||||
|
||||
CappletDirEntry *capplet_new (CappletDir *dir,
|
||||
gchar *desktop_path);
|
||||
CappletDirEntry *capplet_dir_new (CappletDir *dir, gchar *dir_path);
|
||||
|
||||
CappletDirEntry *capplet_lookup (const char *path);
|
||||
|
||||
char *capplet_dir_entry_get_html (CappletDirEntry *entry);
|
||||
|
||||
void capplet_dir_entry_destroy (CappletDirEntry *entry);
|
||||
|
||||
void capplet_dir_entry_activate (CappletDirEntry *entry,
|
||||
CappletDirView *launcher);
|
||||
void capplet_dir_entry_shutdown (CappletDirEntry *entry);
|
||||
|
||||
void capplet_dir_load (CappletDir *dir);
|
||||
|
||||
void capplet_dir_init (CappletDirView *(*cb)
|
||||
(CappletDir *,
|
||||
CappletDirView *));
|
||||
|
||||
CappletDir *get_root_capplet_dir (void);
|
||||
|
||||
GtkWidget *capplet_control_launch (const gchar *capplet_name,
|
||||
gchar *window_title);
|
||||
|
||||
#endif /* __CAPPLET_DIR_H */
|
|
@ -1,172 +0,0 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* main.c
|
||||
* Copyright (C) 2000, 2001 Ximian, Inc.
|
||||
*
|
||||
* Written by Bradford Hovinen <hovinen@ximian.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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <gnome.h>
|
||||
#include <glade/glade.h>
|
||||
#include <gconf/gconf.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#include "capplet-dir.h"
|
||||
#include "capplet-dir-view.h"
|
||||
|
||||
static gint use_shell = 0;
|
||||
|
||||
static struct poptOption cap_options[] = {
|
||||
{"use-shell", '\0', POPT_ARG_NONE, &use_shell, 0,
|
||||
N_("Use shell even if nautilus is running."), NULL},
|
||||
{NULL, '\0', 0, NULL, 0}
|
||||
};
|
||||
|
||||
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 (GnomeClient *client, gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
CappletDirEntry *entry;
|
||||
CappletDir *dir;
|
||||
GnomeClient *client;
|
||||
|
||||
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
|
||||
gnome_program_init ("control-center", VERSION, LIBGNOMEUI_MODULE,
|
||||
argc, argv,
|
||||
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
||||
GNOME_PARAM_POPT_TABLE, cap_options,
|
||||
NULL);
|
||||
|
||||
if (!use_shell && is_nautilus_running ())
|
||||
execlp ("nautilus", "nautilus", "preferences:///", NULL);
|
||||
|
||||
gnomecc_init ();
|
||||
dir = get_root_capplet_dir ();
|
||||
if (dir == NULL)
|
||||
return -1;
|
||||
entry = CAPPLET_DIR_ENTRY (dir);
|
||||
if (entry == NULL)
|
||||
return -1;
|
||||
capplet_dir_entry_activate (entry, NULL);
|
||||
|
||||
client = gnome_master_client ();
|
||||
g_signal_connect (G_OBJECT (client), "save_yourself",
|
||||
G_CALLBACK (gnome_cc_save_yourself), argv[0]);
|
||||
g_signal_connect (G_OBJECT (client), "die",
|
||||
G_CALLBACK (gnome_cc_die), NULL);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
Index: Makefile.am
|
||||
===================================================================
|
||||
RCS file: /cvs/gnome/gnome-control-center/control-center/Makefile.am,v
|
||||
retrieving revision 1.46
|
||||
diff -u -w -r1.46 Makefile.am
|
||||
--- Makefile.am 7 May 2003 18:55:08 -0000 1.46
|
||||
+++ Makefile.am 1 Jun 2004 13:00:15 -0000
|
||||
@@ -10,6 +10,11 @@
|
||||
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
|
||||
|
||||
@@ -20,18 +25,34 @@
|
||||
-DPIXMAP_DIR=\""$(datadir)/pixmaps"\" \
|
||||
-DART_DIR=\""$(splashdir)"\" \
|
||||
-DGNOME_SBINDIR=\""$(sbindir)"\" \
|
||||
- $(GNOMECC_CFLAGS)
|
||||
+ $(GNOMECC_CFLAGS) $(NAUTILUS_CFLAGS)
|
||||
|
||||
bin_PROGRAMS = gnome-control-center
|
||||
|
||||
gnome_control_center_SOURCES = \
|
||||
- main.c \
|
||||
- capplet-dir.c capplet-dir.h \
|
||||
- capplet-dir-view.c capplet-dir-view.h \
|
||||
- capplet-dir-view-list.c
|
||||
+ control-center-categories.c \
|
||||
+ control-center-categories.h \
|
||||
+ control-center.c \
|
||||
+ gnomecc-rounded-rect.c \
|
||||
+ gnomecc-rounded-rect.h \
|
||||
+ gnomecc-event-box.c \
|
||||
+ gnomecc-event-box.h
|
||||
+
|
||||
+gnome_control_center_LDADD = $(GNOMECC_LIBS) $(NAUTILUS_LIBS)
|
||||
+
|
||||
+IMAGES = text-selection-frame.png
|
||||
+VARIABLES = \
|
||||
+ gnomecc_rounded_rect_frame $(srcdir)/text-selection-frame.png
|
||||
+
|
||||
+pixbuf_file = $(top_builddir)/control-center/gnomecc-rounded-rect-pixbuf.h
|
||||
+pixbuf_file = gnomecc-rounded-rect-pixbuf.h
|
||||
+noinst_DATA = $(pixbuf_file)
|
||||
|
||||
-gnome_control_center_LDADD = $(GNOMECC_LIBS)
|
||||
+$(pixbuf_file) : $(IMAGES)
|
||||
+ $(GDK_PIXBUF_CSOURCE) --raw --build-list $(VARIABLES) > $@
|
||||
|
||||
-EXTRA_DIST = gnomecc.desktop.in $(splash_DATA) $(ui_DATA)
|
||||
+EXTRA_DIST = gnomecc.desktop.in $(splash_DATA) $(ui_DATA) $(server_DATA) \
|
||||
+ $(IMAGES)
|
||||
|
||||
-CLEANFILES = gnomecc.desktop
|
||||
+BUILT_SOURCES = $(pixbuf_file)
|
||||
+CLEANFILES = gnomecc.desktop $(noinst_DATA)
|
|
@ -71,14 +71,10 @@ capplets/windows/gnome-window-properties.c
|
|||
capplets/windows/gnome-window-properties.glade
|
||||
capplets/windows/window-properties.desktop.in
|
||||
control-center/GNOME_ControlCenter.server.in
|
||||
control-center/capplet-dir-view-list.c
|
||||
control-center/capplet-dir-view.c
|
||||
control-center/capplet-dir.c
|
||||
control-center/control-center-categories.c
|
||||
control-center/control-center.c
|
||||
control-center/gnomecc-ui.xml
|
||||
control-center/gnomecc.desktop.in
|
||||
control-center/main.c
|
||||
gnome-settings-daemon/actions/acme.glade
|
||||
gnome-settings-daemon/factory.c
|
||||
gnome-settings-daemon/gnome-settings-accessibility-keyboard.c
|
||||
|
|
Loading…
Add table
Reference in a new issue