Merging of my tree.
This contains: * a few capplets were redone UI wise: ui-properties keyboard background-properties * splitting of libcapplet out of this modules (into libcapplet) * new html-based view in the control-center * initial import of functional root-manager This stuff isn't all done yet, but I wanted to get it in. TODO files will hopefully follow.
This commit is contained in:
parent
2749ba455b
commit
d42affc965
73 changed files with 6567 additions and 3322 deletions
175
control-center/capplet-dir-view-list.c
Normal file
175
control-center/capplet-dir-view-list.c
Normal file
|
@ -0,0 +1,175 @@
|
|||
/* -*- mode: c; style: linux -*- */
|
||||
|
||||
/* capplet-dir-view-list.c
|
||||
* Copyright (C) 2000 Helix Code, Inc.
|
||||
*
|
||||
* Authors: Jacob Berkman <jacob@helixcode.com>
|
||||
* Bradford Hovinen <hovinen@helixcode.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 <gdk-pixbuf/gnome-canvas-pixbuf.h>
|
||||
|
||||
#include "capplet-dir-view.h"
|
||||
|
||||
static void
|
||||
list_clear (CappletDirView *view)
|
||||
{
|
||||
g_return_if_fail (GNOME_IS_ICON_LIST (view->view));
|
||||
|
||||
gnome_icon_list_clear (GNOME_ICON_LIST (view->view));
|
||||
}
|
||||
|
||||
static void
|
||||
list_clean (CappletDirView *view)
|
||||
{
|
||||
g_return_if_fail (GNOME_IS_ICON_LIST (view->view));
|
||||
|
||||
gtk_object_destroy (GTK_OBJECT (view->view));
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
||||
static void
|
||||
list_populate (CappletDirView *view)
|
||||
{
|
||||
GSList *list;
|
||||
int i;
|
||||
GnomeCanvasItem *item;
|
||||
|
||||
g_return_if_fail (GNOME_IS_ICON_LIST (view->view));
|
||||
|
||||
gnome_icon_list_freeze (GNOME_ICON_LIST (view->view));
|
||||
|
||||
for (i = 0, list = view->capplet_dir->entries; list; list = list->next, i++) {
|
||||
item = flatten_alpha (CAPPLET_DIR_ENTRY (list->data)->pb,
|
||||
GNOME_CANVAS (view->view));
|
||||
gnome_icon_list_insert_item (GNOME_ICON_LIST (view->view), i, item,
|
||||
CAPPLET_DIR_ENTRY (list->data)->label);
|
||||
}
|
||||
gnome_icon_list_thaw (GNOME_ICON_LIST (view->view));
|
||||
}
|
||||
|
||||
static void
|
||||
select_icon_list_cb (GtkWidget *widget, gint arg1, GdkEvent *event,
|
||||
CappletDirView *view)
|
||||
{
|
||||
if (event->type == GDK_2BUTTON_PRESS &&
|
||||
((GdkEventButton *) event)->button == 1)
|
||||
{
|
||||
capplet_dir_entry_activate
|
||||
(g_slist_nth_data (view->capplet_dir->entries, arg1), view);
|
||||
view->selected = NULL;
|
||||
} else {
|
||||
view->selected = g_slist_nth_data (view->capplet_dir->entries, arg1);
|
||||
}
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
list_create (CappletDirView *view)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
GtkWidget *w;
|
||||
GSList *list;
|
||||
int i;
|
||||
|
||||
adjustment = gtk_scrolled_window_get_vadjustment
|
||||
(GTK_SCROLLED_WINDOW (view->scrolled_win));
|
||||
|
||||
|
||||
w = gnome_icon_list_new (72, adjustment, 0);
|
||||
|
||||
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
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (w), "select-icon",
|
||||
GTK_SIGNAL_FUNC (select_icon_list_cb),
|
||||
view);
|
||||
return w;
|
||||
}
|
||||
|
||||
CappletDirViewImpl capplet_dir_view_list = {
|
||||
list_clear,
|
||||
list_clean,
|
||||
list_populate,
|
||||
list_create
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue