Commit b22bfa64 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

set the mini icon. (nautilus_window_class_init): init parent_class and

1999-12-17  Havoc Pennington  <hp@redhat.com>

* src/ntl-window.c (nautilus_window_realize): set the mini icon.
(nautilus_window_class_init): init parent_class and install
realize method

* src/ntl-miniicon.c: new files, to set mini icon
parent edc7a195
1999-12-17 Havoc Pennington <hp@redhat.com>
* src/ntl-window.c (nautilus_window_realize): set the mini icon.
(nautilus_window_class_init): init parent_class and install
realize method
* src/ntl-miniicon.c: new files, to set mini icon
1999-12-16 Elliot Lee <sopwith@redhat.com>
* libnautilus/{gdk-extensions.c,gnome-icon-container.c}: Fix warnings
* libnautilus/gnome-icon-container.c: Try (unsuccessfully) to get
......
/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*-
* Nautilus shell - mini icon setting routine
*
* Copyright (C) 1999 Anders Carlsson
*
* 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 of the
* License, 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 "ntl-miniicon.h"
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
void
nautilus_set_mini_icon(GdkWindow *window,
GdkPixmap *pixmap,
GdkBitmap *mask)
{
GdkAtom icon_atom;
long data[2];
g_return_if_fail (window != NULL);
g_return_if_fail (pixmap != NULL);
data[0] = ((GdkPixmapPrivate *)pixmap)->xwindow;
if (mask)
data[1] = ((GdkPixmapPrivate *)mask)->xwindow;
else
data[1] = 0;
icon_atom = gdk_atom_intern ("KWM_WIN_ICON", FALSE);
gdk_property_change (window, icon_atom, icon_atom,
32,GDK_PROP_MODE_REPLACE,
(guchar *)data, 2);
}
/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*-
* Nautilus shell - mini icon setting routine
*
* Copyright (C) 1999 Anders Carlsson
*
* 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 of the
* License, 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 NTL_MINIICON_H
#define NTL_MINIICON_H
#include <gdk/gdk.h>
/* In GNOME 2.0 this function will be in the libraries */
void
nautilus_set_mini_icon(GdkWindow *window,
GdkPixmap *pixmap,
GdkBitmap *mask);
#endif
/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*-
* Nautilus shell - mini icon setting routine
*
* Copyright (C) 1999 Anders Carlsson
*
* 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 of the
* License, 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 "ntl-miniicon.h"
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
void
nautilus_set_mini_icon(GdkWindow *window,
GdkPixmap *pixmap,
GdkBitmap *mask)
{
GdkAtom icon_atom;
long data[2];
g_return_if_fail (window != NULL);
g_return_if_fail (pixmap != NULL);
data[0] = ((GdkPixmapPrivate *)pixmap)->xwindow;
if (mask)
data[1] = ((GdkPixmapPrivate *)mask)->xwindow;
else
data[1] = 0;
icon_atom = gdk_atom_intern ("KWM_WIN_ICON", FALSE);
gdk_property_change (window, icon_atom, icon_atom,
32,GDK_PROP_MODE_REPLACE,
(guchar *)data, 2);
}
/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*-
* Nautilus shell - mini icon setting routine
*
* Copyright (C) 1999 Anders Carlsson
*
* 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 of the
* License, 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 NTL_MINIICON_H
#define NTL_MINIICON_H
#include <gdk/gdk.h>
/* In GNOME 2.0 this function will be in the libraries */
void
nautilus_set_mini_icon(GdkWindow *window,
GdkPixmap *pixmap,
GdkBitmap *mask);
#endif
......@@ -25,6 +25,8 @@ nautilus_SOURCES= \
ntl-main.c \
ntl-meta-view.h \
ntl-meta-view.c \
ntl-miniicon.h \
ntl-miniicon.c \
ntl-types.h \
ntl-uri-map.h \
ntl-uri-map.c \
......
......@@ -168,6 +168,8 @@ desktop_canvas_size_allocate(GtkWidget *widget,
allocation->width,
allocation->height);
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget,
allocation);
......
......@@ -25,6 +25,7 @@
#include <libgnome/gnome-defs.h>
#include <libgnomeui/gnome-canvas.h>
#include "desktop-layout.h"
BEGIN_GNOME_DECLS
......@@ -88,6 +89,8 @@ struct _DesktopCanvas {
guint background_update_idle;
GtkWidget *popup;
DesktopLayout *layout;
};
struct _DesktopCanvasClass {
......
......@@ -363,6 +363,7 @@ layout_rows_left_to_right(DesktopLayout *layout,
void
desktop_layout_arrange (DesktopLayout *layout, gboolean ignore_position_requests)
{
/* FIXME */
/* Testing */
layout_rows_left_to_right(layout, FALSE);
}
......@@ -29,8 +29,13 @@
#include "nautilus.h"
#include "explorer-location-bar.h"
#include "ntl-window-private.h"
#include "ntl-miniicon.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
static void nautilus_window_realize (GtkWidget *widget);
static int window_count = 0;
static GnomeAppClass *parent_class = NULL;
/* Stuff for handling the CORBA interface */
typedef struct {
......@@ -296,6 +301,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
GtkWidgetClass *widget_class;
int i;
parent_class = gtk_type_class(gnome_app_get_type());
object_class = (GtkObjectClass*) klass;
object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy;
object_class->get_arg = nautilus_window_get_arg;
......@@ -338,6 +345,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
GTK_ARG_READWRITE,
ARG_CONTENT_VIEW);
impl_Nautilus_ViewWindow_vepv.GNOME_Unknown_epv = gnome_object_get_epv();
widget_class->realize = nautilus_window_realize;
}
static gboolean
......@@ -617,6 +626,104 @@ nautilus_window_new(const char *app_id)
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, NULL));
}
static void
would_be_in_gdk_pixbuf_if_federico_wasnt_stubborn_pixbuf_render(GdkPixbuf *pixbuf,
GdkPixmap **pixmap,
GdkBitmap **mask_retval,
gint alpha_threshold)
{
GdkBitmap *mask = NULL;
g_return_if_fail(pixbuf != NULL);
/* generate mask */
if (gdk_pixbuf_get_has_alpha(pixbuf)) {
mask = gdk_pixmap_new(NULL,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
1);
gdk_pixbuf_render_threshold_alpha(pixbuf, mask,
0, 0, 0, 0,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
alpha_threshold);
}
/* Draw to pixmap */
if (pixmap != NULL) {
GdkGC* gc;
*pixmap = gdk_pixmap_new(NULL,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
gdk_rgb_get_visual()->depth);
gc = gdk_gc_new(*pixmap);
gdk_gc_set_clip_mask(gc, mask);
gdk_pixbuf_render_to_drawable(pixbuf, *pixmap,
gc,
0, 0, 0, 0,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
GDK_RGB_DITHER_NORMAL,
0, 0);
gdk_gc_unref(gc);
}
if (mask_retval)
*mask_retval = mask;
else
gdk_bitmap_unref(mask);
}
static void
nautilus_window_realize (GtkWidget *widget)
{
GdkPixmap *pixmap = NULL;
GdkBitmap *mask = NULL;
gchar *filename;
/* Create our GdkWindow */
if (GTK_WIDGET_CLASS(parent_class)->realize)
(* GTK_WIDGET_CLASS(parent_class)->realize) (widget);
/* Set the mini icon */
/* FIXME draw a real icon */
/* FIXME The icon should be 16x16, we get garbage on the edges
since it's 12x12 */
filename = gnome_pixmap_file("panel-arrow-down.png");
if (filename != NULL) {
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_file(filename);
if (pixbuf != NULL) {
would_be_in_gdk_pixbuf_if_federico_wasnt_stubborn_pixbuf_render(pixbuf,
&pixmap,
&mask,
128);
}
}
if (pixmap != NULL)
nautilus_set_mini_icon(widget->window,
pixmap,
mask);
/* FIXME I think we are leaking the pixmap/mask here */
}
/*
* Main API
*/
static gboolean
nautilus_window_send_show_properties(GtkWidget *dockitem, GdkEventButton *event, NautilusView *meta_view)
{
......
......@@ -29,8 +29,13 @@
#include "nautilus.h"
#include "explorer-location-bar.h"
#include "ntl-window-private.h"
#include "ntl-miniicon.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
static void nautilus_window_realize (GtkWidget *widget);
static int window_count = 0;
static GnomeAppClass *parent_class = NULL;
/* Stuff for handling the CORBA interface */
typedef struct {
......@@ -296,6 +301,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
GtkWidgetClass *widget_class;
int i;
parent_class = gtk_type_class(gnome_app_get_type());
object_class = (GtkObjectClass*) klass;
object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy;
object_class->get_arg = nautilus_window_get_arg;
......@@ -338,6 +345,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
GTK_ARG_READWRITE,
ARG_CONTENT_VIEW);
impl_Nautilus_ViewWindow_vepv.GNOME_Unknown_epv = gnome_object_get_epv();
widget_class->realize = nautilus_window_realize;
}
static gboolean
......@@ -617,6 +626,104 @@ nautilus_window_new(const char *app_id)
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, NULL));
}
static void
would_be_in_gdk_pixbuf_if_federico_wasnt_stubborn_pixbuf_render(GdkPixbuf *pixbuf,
GdkPixmap **pixmap,
GdkBitmap **mask_retval,
gint alpha_threshold)
{
GdkBitmap *mask = NULL;
g_return_if_fail(pixbuf != NULL);
/* generate mask */
if (gdk_pixbuf_get_has_alpha(pixbuf)) {
mask = gdk_pixmap_new(NULL,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
1);
gdk_pixbuf_render_threshold_alpha(pixbuf, mask,
0, 0, 0, 0,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
alpha_threshold);
}
/* Draw to pixmap */
if (pixmap != NULL) {
GdkGC* gc;
*pixmap = gdk_pixmap_new(NULL,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
gdk_rgb_get_visual()->depth);
gc = gdk_gc_new(*pixmap);
gdk_gc_set_clip_mask(gc, mask);
gdk_pixbuf_render_to_drawable(pixbuf, *pixmap,
gc,
0, 0, 0, 0,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
GDK_RGB_DITHER_NORMAL,
0, 0);
gdk_gc_unref(gc);
}
if (mask_retval)
*mask_retval = mask;
else
gdk_bitmap_unref(mask);
}
static void
nautilus_window_realize (GtkWidget *widget)
{
GdkPixmap *pixmap = NULL;
GdkBitmap *mask = NULL;
gchar *filename;
/* Create our GdkWindow */
if (GTK_WIDGET_CLASS(parent_class)->realize)
(* GTK_WIDGET_CLASS(parent_class)->realize) (widget);
/* Set the mini icon */
/* FIXME draw a real icon */
/* FIXME The icon should be 16x16, we get garbage on the edges
since it's 12x12 */
filename = gnome_pixmap_file("panel-arrow-down.png");
if (filename != NULL) {
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_file(filename);
if (pixbuf != NULL) {
would_be_in_gdk_pixbuf_if_federico_wasnt_stubborn_pixbuf_render(pixbuf,
&pixmap,
&mask,
128);
}
}
if (pixmap != NULL)
nautilus_set_mini_icon(widget->window,
pixmap,
mask);
/* FIXME I think we are leaking the pixmap/mask here */
}
/*
* Main API
*/
static gboolean
nautilus_window_send_show_properties(GtkWidget *dockitem, GdkEventButton *event, NautilusView *meta_view)
{
......
......@@ -29,8 +29,13 @@
#include "nautilus.h"
#include "explorer-location-bar.h"
#include "ntl-window-private.h"
#include "ntl-miniicon.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
static void nautilus_window_realize (GtkWidget *widget);
static int window_count = 0;
static GnomeAppClass *parent_class = NULL;
/* Stuff for handling the CORBA interface */
typedef struct {
......@@ -296,6 +301,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
GtkWidgetClass *widget_class;
int i;
parent_class = gtk_type_class(gnome_app_get_type());
object_class = (GtkObjectClass*) klass;
object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy;
object_class->get_arg = nautilus_window_get_arg;
......@@ -338,6 +345,8 @@ nautilus_window_class_init (NautilusWindowClass *klass)
GTK_ARG_READWRITE,
ARG_CONTENT_VIEW);
impl_Nautilus_ViewWindow_vepv.GNOME_Unknown_epv = gnome_object_get_epv();
widget_class->realize = nautilus_window_realize;
}
static gboolean
......@@ -617,6 +626,104 @@ nautilus_window_new(const char *app_id)
return GTK_WIDGET (gtk_object_new (nautilus_window_get_type(), "app_id", app_id, NULL));
}
static void
would_be_in_gdk_pixbuf_if_federico_wasnt_stubborn_pixbuf_render(GdkPixbuf *pixbuf,
GdkPixmap **pixmap,
GdkBitmap **mask_retval,
gint alpha_threshold)
{
GdkBitmap *mask = NULL;
g_return_if_fail(pixbuf != NULL);
/* generate mask */
if (gdk_pixbuf_get_has_alpha(pixbuf)) {
mask = gdk_pixmap_new(NULL,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
1);
gdk_pixbuf_render_threshold_alpha(pixbuf, mask,
0, 0, 0, 0,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
alpha_threshold);
}
/* Draw to pixmap */
if (pixmap != NULL) {
GdkGC* gc;
*pixmap = gdk_pixmap_new(NULL,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
gdk_rgb_get_visual()->depth);
gc = gdk_gc_new(*pixmap);
gdk_gc_set_clip_mask(gc, mask);
gdk_pixbuf_render_to_drawable(pixbuf, *pixmap,
gc,
0, 0, 0, 0,
gdk_pixbuf_get_width(pixbuf),
gdk_pixbuf_get_height(pixbuf),
GDK_RGB_DITHER_NORMAL,
0, 0);
gdk_gc_unref(gc);
}
if (mask_retval)
*mask_retval = mask;
else
gdk_bitmap_unref(mask);
}
static void
nautilus_window_realize (GtkWidget *widget)
{
GdkPixmap *pixmap = NULL;
GdkBitmap *mask = NULL;
gchar *filename;
/* Create our GdkWindow */
if (GTK_WIDGET_CLASS(parent_class)->realize)
(* GTK_WIDGET_CLASS(parent_class)->realize) (widget);
/* Set the mini icon */
/* FIXME draw a real icon */
/* FIXME The icon should be 16x16, we get garbage on the edges
since it's 12x12 */
filename = gnome_pixmap_file("panel-arrow-down.png");
if (filename != NULL) {
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_file(filename);
if (pixbuf != NULL) {
would_be_in_gdk_pixbuf_if_federico_wasnt_stubborn_pixbuf_render(pixbuf,
&pixmap,
&mask,
128);
}
}