mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 02:36:07 +00:00
Add arlo's services title icons.
* components/services/startup/nautilus-view/icons/Makefile.am, eazel-services-logo.png, eazel-services-logo-tile.png: Add arlo's services title icons. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-graphic.c: (nautilus_graphic_initialize_class), (nautilus_graphic_initialize), (nautilus_graphic_destroy), (nautilus_graphic_set_arg), (nautilus_graphic_get_arg), (nautilus_graphic_realize), (nautilus_graphic_unrealize), (nautilus_graphic_draw), (nautilus_graphic_size_allocate), (nautilus_graphic_size_request), (nautilus_graphic_map), (nautilus_graphic_unmap), (nautilus_graphic_expose), (ensure_buffer_size), (create_child_window), (nautilus_gdk_create_copy_area_gc), (nautilus_gdk_pixbuf_render_to_drawable), (nautilus_gdk_pixbuf_render_to_pixbuf), (nautilus_gdk_pixbuf_render_to_pixbuf_alpha), (gdk_string_dimensions), (nautilus_gdk_pixbuf_set_to_color), (nautilus_gdk_pixbuf_tile), (nautilus_gdk_pixbuf_tile_alpha), (nautilus_graphic_new), (nautilus_graphic_set_background_pixbuf), (nautilus_graphic_get_background_pixbuf), (nautilus_graphic_set_background_type), (nautilus_graphic_get_background_type), (nautilus_graphic_set_background_color), (nautilus_graphic_get_background_color), (nautilus_graphic_set_placement_type), (nautilus_graphic_get_placement_type), (nautilus_graphic_set_pixbuf), (nautilus_graphic_get_pixbuf), (nautilus_graphic_set_overall_alpha), (nautilus_graphic_set_label_text), (nautilus_graphic_get_label_text), (nautilus_graphic_set_label_font), (nautilus_graphic_get_label_font): * libnautilus-extensions/nautilus-graphic.h: Add NautilusGraphic widget to build. * test/.cvsignore: * test/Makefile.am: * test/test-nautilus-graphic.c: (create_background), (create_pixbuf), (create_graphic), (alpha_scale_value_changed), (red_color_value_changed), (green_color_value_changed), (blue_color_value_changed), (toggle_background_type_callback), (create_color_scale), (main): Add test for NautilusGraphic widget.
This commit is contained in:
parent
33d57594f3
commit
747245d712
|
@ -8,6 +8,8 @@ icon_DATA = \
|
|||
eazel-cloud-logo.png \
|
||||
startup-logo.png \
|
||||
service-watch.png \
|
||||
eazel-services-logo.png \
|
||||
eazel-services-logo-tile.png \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST = $(icon_DATA)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 202 B |
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
|
@ -54,6 +54,7 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-glib-extensions.c \
|
||||
nautilus-global-preferences.c \
|
||||
nautilus-gnome-extensions.c \
|
||||
nautilus-graphic.c \
|
||||
nautilus-graphic-effects.c \
|
||||
nautilus-gtk-extensions.c \
|
||||
nautilus-horizontal-splitter.c \
|
||||
|
@ -129,6 +130,7 @@ noinst_HEADERS = \
|
|||
nautilus-global-preferences.h \
|
||||
nautilus-gnome-extensions.h \
|
||||
nautilus-graphic-effects.h \
|
||||
nautilus-graphic.h \
|
||||
nautilus-gtk-extensions.h \
|
||||
nautilus-gtk-macros.h \
|
||||
nautilus-horizontal-splitter.h \
|
||||
|
|
1414
libnautilus-extensions/nautilus-graphic.c
Normal file
1414
libnautilus-extensions/nautilus-graphic.c
Normal file
File diff suppressed because it is too large
Load diff
118
libnautilus-extensions/nautilus-graphic.h
Normal file
118
libnautilus-extensions/nautilus-graphic.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-graphic.h - A widget to display a composited pixbuf.
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_GRAPHIC_H
|
||||
#define NAUTILUS_GRAPHIC_H
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
/* NautilusGraphic is GtkWidget that can display a GdkPixbuf. This pixbuf
|
||||
* will be composited with full alpha support on wither a solid background
|
||||
* or a background pixbuf.
|
||||
*/
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
#define NAUTILUS_TYPE_GRAPHIC (nautilus_graphic_get_type ())
|
||||
#define NAUTILUS_GRAPHIC(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_GRAPHIC, NautilusGraphic))
|
||||
#define NAUTILUS_GRAPHIC_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_GRAPHIC, NautilusGraphicClass))
|
||||
#define NAUTILUS_IS_GRAPHIC(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_GRAPHIC))
|
||||
#define NAUTILUS_IS_GRAPHIC_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_GRAPHIC))
|
||||
|
||||
typedef struct _NautilusGraphic NautilusGraphic;
|
||||
typedef struct _NautilusGraphicClass NautilusGraphicClass;
|
||||
typedef struct _NautilusGraphicDetail NautilusGraphicDetail;
|
||||
|
||||
struct _NautilusGraphic
|
||||
{
|
||||
/* Superclass */
|
||||
GtkWidget widget;
|
||||
|
||||
/* Private things */
|
||||
NautilusGraphicDetail *detail;
|
||||
};
|
||||
|
||||
struct _NautilusGraphicClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_GRAPHIC_PLACEMENT_TILE,
|
||||
NAUTILUS_GRAPHIC_PLACEMENT_CENTER
|
||||
} NautilusGraphicPlacementType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_GRAPHIC_BACKGROUND_PIXBUF,
|
||||
NAUTILUS_GRAPHIC_BACKGROUND_SOLID,
|
||||
} NautilusGraphicBackgroundType;
|
||||
|
||||
/* Pack RGBA components */
|
||||
#define NAUTILUS_RGBA_COLOR_PACK(_r, _g, _b, _a) \
|
||||
( ((_a) << 24) | \
|
||||
((_r) << 16) | \
|
||||
((_g) << 8) | \
|
||||
((_b) << 0) )
|
||||
|
||||
/* Access RGBA components */
|
||||
#define NAUTILUS_RGBA_COLOR_GET_R(_color) (((_color) >> 16) & 0xff)
|
||||
#define NAUTILUS_RGBA_COLOR_GET_G(_color) (((_color) >> 8) & 0xff)
|
||||
#define NAUTILUS_RGBA_COLOR_GET_B(_color) (((_color) >> 0) & 0xff)
|
||||
#define NAUTILUS_RGBA_COLOR_GET_A(_color) (((_color) >> 24) & 0xff)
|
||||
|
||||
GtkType nautilus_graphic_get_type (void);
|
||||
GtkWidget * nautilus_graphic_new (void);
|
||||
void nautilus_graphic_set_background_pixbuf (NautilusGraphic *graphic,
|
||||
GdkPixbuf *background);
|
||||
GdkPixbuf* nautilus_graphic_get_background_pixbuf (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_background_type (NautilusGraphic *graphic,
|
||||
NautilusGraphicBackgroundType background_type);
|
||||
NautilusGraphicBackgroundType nautilus_graphic_get_background_type (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_placement_type (NautilusGraphic *graphic,
|
||||
NautilusGraphicPlacementType placement);
|
||||
NautilusGraphicPlacementType nautilus_graphic_get_placement_type (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_background_color (NautilusGraphic *graphic,
|
||||
guint32 color);
|
||||
guint32 nautilus_graphic_get_background_color (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_pixbuf (NautilusGraphic *graphic,
|
||||
GdkPixbuf *pixbuf);
|
||||
GdkPixbuf* nautilus_graphic_get_pixbuf (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_overall_alpha (NautilusGraphic *graphic,
|
||||
guchar pixbuf_alpha);
|
||||
void nautilus_graphic_set_label_text (NautilusGraphic *graphic,
|
||||
const gchar *text);
|
||||
gchar* nautilus_graphic_get_label_text (NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_label_font (NautilusGraphic *graphic,
|
||||
GdkFont *font);
|
||||
GdkFont* nautilus_graphic_get_label_font (NautilusGraphic *graphic);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* NAUTILUS_GRAPHIC_H */
|
||||
|
||||
|
|
@ -54,6 +54,7 @@ libnautilus_extensions_la_SOURCES = \
|
|||
nautilus-glib-extensions.c \
|
||||
nautilus-global-preferences.c \
|
||||
nautilus-gnome-extensions.c \
|
||||
nautilus-graphic.c \
|
||||
nautilus-graphic-effects.c \
|
||||
nautilus-gtk-extensions.c \
|
||||
nautilus-horizontal-splitter.c \
|
||||
|
@ -129,6 +130,7 @@ noinst_HEADERS = \
|
|||
nautilus-global-preferences.h \
|
||||
nautilus-gnome-extensions.h \
|
||||
nautilus-graphic-effects.h \
|
||||
nautilus-graphic.h \
|
||||
nautilus-gtk-extensions.h \
|
||||
nautilus-gtk-macros.h \
|
||||
nautilus-horizontal-splitter.h \
|
||||
|
|
1414
libnautilus-private/nautilus-graphic.c
Normal file
1414
libnautilus-private/nautilus-graphic.c
Normal file
File diff suppressed because it is too large
Load diff
118
libnautilus-private/nautilus-graphic.h
Normal file
118
libnautilus-private/nautilus-graphic.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
||||
|
||||
/* nautilus-graphic.h - A widget to display a composited pixbuf.
|
||||
|
||||
Copyright (C) 1999, 2000 Eazel, Inc.
|
||||
|
||||
The Gnome Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
The Gnome Library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Ramiro Estrugo <ramiro@eazel.com>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_GRAPHIC_H
|
||||
#define NAUTILUS_GRAPHIC_H
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
#include <libgnome/gnome-defs.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
/* NautilusGraphic is GtkWidget that can display a GdkPixbuf. This pixbuf
|
||||
* will be composited with full alpha support on wither a solid background
|
||||
* or a background pixbuf.
|
||||
*/
|
||||
|
||||
BEGIN_GNOME_DECLS
|
||||
|
||||
#define NAUTILUS_TYPE_GRAPHIC (nautilus_graphic_get_type ())
|
||||
#define NAUTILUS_GRAPHIC(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_GRAPHIC, NautilusGraphic))
|
||||
#define NAUTILUS_GRAPHIC_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_GRAPHIC, NautilusGraphicClass))
|
||||
#define NAUTILUS_IS_GRAPHIC(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_GRAPHIC))
|
||||
#define NAUTILUS_IS_GRAPHIC_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_GRAPHIC))
|
||||
|
||||
typedef struct _NautilusGraphic NautilusGraphic;
|
||||
typedef struct _NautilusGraphicClass NautilusGraphicClass;
|
||||
typedef struct _NautilusGraphicDetail NautilusGraphicDetail;
|
||||
|
||||
struct _NautilusGraphic
|
||||
{
|
||||
/* Superclass */
|
||||
GtkWidget widget;
|
||||
|
||||
/* Private things */
|
||||
NautilusGraphicDetail *detail;
|
||||
};
|
||||
|
||||
struct _NautilusGraphicClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_GRAPHIC_PLACEMENT_TILE,
|
||||
NAUTILUS_GRAPHIC_PLACEMENT_CENTER
|
||||
} NautilusGraphicPlacementType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NAUTILUS_GRAPHIC_BACKGROUND_PIXBUF,
|
||||
NAUTILUS_GRAPHIC_BACKGROUND_SOLID,
|
||||
} NautilusGraphicBackgroundType;
|
||||
|
||||
/* Pack RGBA components */
|
||||
#define NAUTILUS_RGBA_COLOR_PACK(_r, _g, _b, _a) \
|
||||
( ((_a) << 24) | \
|
||||
((_r) << 16) | \
|
||||
((_g) << 8) | \
|
||||
((_b) << 0) )
|
||||
|
||||
/* Access RGBA components */
|
||||
#define NAUTILUS_RGBA_COLOR_GET_R(_color) (((_color) >> 16) & 0xff)
|
||||
#define NAUTILUS_RGBA_COLOR_GET_G(_color) (((_color) >> 8) & 0xff)
|
||||
#define NAUTILUS_RGBA_COLOR_GET_B(_color) (((_color) >> 0) & 0xff)
|
||||
#define NAUTILUS_RGBA_COLOR_GET_A(_color) (((_color) >> 24) & 0xff)
|
||||
|
||||
GtkType nautilus_graphic_get_type (void);
|
||||
GtkWidget * nautilus_graphic_new (void);
|
||||
void nautilus_graphic_set_background_pixbuf (NautilusGraphic *graphic,
|
||||
GdkPixbuf *background);
|
||||
GdkPixbuf* nautilus_graphic_get_background_pixbuf (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_background_type (NautilusGraphic *graphic,
|
||||
NautilusGraphicBackgroundType background_type);
|
||||
NautilusGraphicBackgroundType nautilus_graphic_get_background_type (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_placement_type (NautilusGraphic *graphic,
|
||||
NautilusGraphicPlacementType placement);
|
||||
NautilusGraphicPlacementType nautilus_graphic_get_placement_type (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_background_color (NautilusGraphic *graphic,
|
||||
guint32 color);
|
||||
guint32 nautilus_graphic_get_background_color (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_pixbuf (NautilusGraphic *graphic,
|
||||
GdkPixbuf *pixbuf);
|
||||
GdkPixbuf* nautilus_graphic_get_pixbuf (const NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_overall_alpha (NautilusGraphic *graphic,
|
||||
guchar pixbuf_alpha);
|
||||
void nautilus_graphic_set_label_text (NautilusGraphic *graphic,
|
||||
const gchar *text);
|
||||
gchar* nautilus_graphic_get_label_text (NautilusGraphic *graphic);
|
||||
void nautilus_graphic_set_label_font (NautilusGraphic *graphic,
|
||||
GdkFont *font);
|
||||
GdkFont* nautilus_graphic_get_label_font (NautilusGraphic *graphic);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
#endif /* NAUTILUS_GRAPHIC_H */
|
||||
|
||||
|
|
@ -8,3 +8,5 @@ test-nautilus-mime-actions
|
|||
test-nautilus-mime-actions-set
|
||||
test-nautilus-widgets
|
||||
test-nautilus-preferences
|
||||
test-nautilus-graphic
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ noinst_PROGRAMS =\
|
|||
test-nautilus-mime-actions-set \
|
||||
test-nautilus-widgets \
|
||||
test-nautilus-preferences \
|
||||
test-nautilus-graphic \
|
||||
$(NULL)
|
||||
|
||||
test_nautilus_mime_actions_SOURCES = test-nautilus-mime-actions.c
|
||||
|
@ -45,6 +46,8 @@ test_nautilus_widgets_SOURCES = test-nautilus-widgets.c
|
|||
|
||||
test_nautilus_preferences_SOURCES = test-nautilus-preferences.c
|
||||
|
||||
test_nautilus_graphic_SOURCES = test-nautilus-graphic.c
|
||||
|
||||
#libleakcheck_la_SOURCES = \
|
||||
# nautilus-leak-checker.c \
|
||||
# nautilus-leak-checker.h \
|
||||
|
|
350
test/test-nautilus-graphic.c
Normal file
350
test/test-nautilus-graphic.c
Normal file
|
@ -0,0 +1,350 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <libnautilus-extensions/nautilus-graphic.h>
|
||||
#include <libnautilus-extensions/nautilus-icon-factory.h>
|
||||
#include <libnautilus-extensions/nautilus-file-utilities.h>
|
||||
|
||||
static GdkPixbuf*
|
||||
create_background (void)
|
||||
{
|
||||
GdkPixbuf *background;
|
||||
|
||||
background = gdk_pixbuf_new_from_file ("/gnome/share/nautilus/backgrounds/pale_coins.png");
|
||||
|
||||
g_assert (background != NULL);
|
||||
|
||||
return background;
|
||||
}
|
||||
|
||||
static GdkPixbuf*
|
||||
create_pixbuf (const char *name)
|
||||
{
|
||||
char *icon_path;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
||||
g_assert (name != NULL);
|
||||
|
||||
icon_path = nautilus_pixmap_file (name);
|
||||
g_assert (icon_path != NULL);
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file (icon_path);
|
||||
|
||||
g_assert (pixbuf != NULL);
|
||||
|
||||
g_free (icon_path);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
create_graphic (const char *name, GdkPixbuf *background)
|
||||
{
|
||||
GtkWidget *graphic;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
g_assert (background != NULL);
|
||||
|
||||
graphic = nautilus_graphic_new ();
|
||||
g_assert (graphic != NULL);
|
||||
|
||||
nautilus_graphic_set_background_type (NAUTILUS_GRAPHIC (graphic), NAUTILUS_GRAPHIC_BACKGROUND_PIXBUF);
|
||||
nautilus_graphic_set_background_pixbuf (NAUTILUS_GRAPHIC (graphic), background);
|
||||
|
||||
if (name != NULL)
|
||||
{
|
||||
pixbuf = create_pixbuf (name);
|
||||
g_assert (pixbuf != NULL);
|
||||
|
||||
nautilus_graphic_set_pixbuf (NAUTILUS_GRAPHIC (graphic), pixbuf);
|
||||
|
||||
gdk_pixbuf_unref (pixbuf);
|
||||
}
|
||||
|
||||
return graphic;
|
||||
}
|
||||
|
||||
static void
|
||||
alpha_scale_value_changed (GtkAdjustment *adjustment, gpointer client_data)
|
||||
{
|
||||
GList *graphic_list;
|
||||
|
||||
g_return_if_fail (adjustment != NULL);
|
||||
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (client_data != NULL);
|
||||
|
||||
graphic_list = (GList *) client_data;
|
||||
|
||||
while (graphic_list)
|
||||
{
|
||||
g_assert (graphic_list->data != NULL);
|
||||
g_assert (NAUTILUS_IS_GRAPHIC (graphic_list->data));
|
||||
|
||||
nautilus_graphic_set_overall_alpha (NAUTILUS_GRAPHIC (graphic_list->data), (guchar) adjustment->value);
|
||||
|
||||
graphic_list = graphic_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
red_color_value_changed (GtkAdjustment *adjustment, gpointer client_data)
|
||||
{
|
||||
GList *graphic_list;
|
||||
|
||||
g_return_if_fail (adjustment != NULL);
|
||||
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (client_data != NULL);
|
||||
|
||||
graphic_list = (GList *) client_data;
|
||||
|
||||
while (graphic_list)
|
||||
{
|
||||
NautilusGraphic *graphic;
|
||||
guint32 color;
|
||||
|
||||
g_assert (graphic_list->data != NULL);
|
||||
g_assert (NAUTILUS_IS_GRAPHIC (graphic_list->data));
|
||||
|
||||
graphic = NAUTILUS_GRAPHIC (graphic_list->data);
|
||||
|
||||
color = nautilus_graphic_get_background_color (graphic);
|
||||
|
||||
color = NAUTILUS_RGBA_COLOR_PACK ((guchar) adjustment->value,
|
||||
NAUTILUS_RGBA_COLOR_GET_G (color),
|
||||
NAUTILUS_RGBA_COLOR_GET_B (color),
|
||||
NAUTILUS_RGBA_COLOR_GET_A (color));
|
||||
|
||||
nautilus_graphic_set_background_color (graphic, color);
|
||||
|
||||
graphic_list = graphic_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
green_color_value_changed (GtkAdjustment *adjustment, gpointer client_data)
|
||||
{
|
||||
GList *graphic_list;
|
||||
|
||||
g_return_if_fail (adjustment != NULL);
|
||||
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (client_data != NULL);
|
||||
|
||||
graphic_list = (GList *) client_data;
|
||||
|
||||
while (graphic_list)
|
||||
{
|
||||
NautilusGraphic *graphic;
|
||||
guint32 color;
|
||||
|
||||
g_assert (graphic_list->data != NULL);
|
||||
g_assert (NAUTILUS_IS_GRAPHIC (graphic_list->data));
|
||||
|
||||
graphic = NAUTILUS_GRAPHIC (graphic_list->data);
|
||||
|
||||
color = nautilus_graphic_get_background_color (graphic);
|
||||
|
||||
color = NAUTILUS_RGBA_COLOR_PACK (NAUTILUS_RGBA_COLOR_GET_R (color),
|
||||
(guchar) adjustment->value,
|
||||
NAUTILUS_RGBA_COLOR_GET_B (color),
|
||||
NAUTILUS_RGBA_COLOR_GET_A (color));
|
||||
|
||||
nautilus_graphic_set_background_color (graphic, color);
|
||||
|
||||
graphic_list = graphic_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
blue_color_value_changed (GtkAdjustment *adjustment, gpointer client_data)
|
||||
{
|
||||
GList *graphic_list;
|
||||
|
||||
g_return_if_fail (adjustment != NULL);
|
||||
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (client_data != NULL);
|
||||
|
||||
graphic_list = (GList *) client_data;
|
||||
|
||||
while (graphic_list)
|
||||
{
|
||||
NautilusGraphic *graphic;
|
||||
guint32 color;
|
||||
|
||||
g_assert (graphic_list->data != NULL);
|
||||
g_assert (NAUTILUS_IS_GRAPHIC (graphic_list->data));
|
||||
|
||||
graphic = NAUTILUS_GRAPHIC (graphic_list->data);
|
||||
|
||||
color = nautilus_graphic_get_background_color (graphic);
|
||||
|
||||
color = NAUTILUS_RGBA_COLOR_PACK (NAUTILUS_RGBA_COLOR_GET_R (color),
|
||||
NAUTILUS_RGBA_COLOR_GET_G (color),
|
||||
(guchar) adjustment->value,
|
||||
NAUTILUS_RGBA_COLOR_GET_A (color));
|
||||
|
||||
nautilus_graphic_set_background_color (graphic, color);
|
||||
|
||||
graphic_list = graphic_list->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toggle_background_type_callback (GtkWidget *widget, gpointer client_data)
|
||||
{
|
||||
NautilusGraphic *graphic;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_BUTTON (widget));
|
||||
g_return_if_fail (client_data != NULL);
|
||||
g_return_if_fail (NAUTILUS_IS_GRAPHIC (client_data));
|
||||
|
||||
graphic = NAUTILUS_GRAPHIC (client_data);
|
||||
|
||||
if (nautilus_graphic_get_background_type (graphic) == NAUTILUS_GRAPHIC_BACKGROUND_PIXBUF)
|
||||
{
|
||||
nautilus_graphic_set_background_type (graphic, NAUTILUS_GRAPHIC_BACKGROUND_SOLID);
|
||||
}
|
||||
else
|
||||
{
|
||||
nautilus_graphic_set_background_type (graphic, NAUTILUS_GRAPHIC_BACKGROUND_PIXBUF);
|
||||
}
|
||||
}
|
||||
|
||||
static GtkWidget*
|
||||
create_color_scale (guint num_colors, GtkSignalFunc callback, gpointer callback_data)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
GtkWidget *scale;
|
||||
|
||||
g_assert (num_colors > 0);
|
||||
g_assert (callback > 0);
|
||||
|
||||
adjustment = (GtkAdjustment *) gtk_adjustment_new (num_colors,
|
||||
0,
|
||||
num_colors,
|
||||
1,
|
||||
num_colors / 10,
|
||||
0);
|
||||
|
||||
scale = gtk_hscale_new (adjustment);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", callback, callback_data);
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char* argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *main_box;
|
||||
GtkWidget *graphic_box;
|
||||
GtkWidget *tool_box;
|
||||
GtkWidget *toggle_background_type;
|
||||
|
||||
GtkWidget *alpha_scale;
|
||||
|
||||
GtkWidget *red_scale;
|
||||
GtkWidget *green_scale;
|
||||
GtkWidget *blue_scale;
|
||||
|
||||
GdkPixbuf *background;
|
||||
|
||||
GtkWidget *graphic1;
|
||||
GtkWidget *graphic2;
|
||||
GtkWidget *graphic3;
|
||||
|
||||
GtkWidget *background_graphic;
|
||||
|
||||
GList *graphic_list = NULL;
|
||||
|
||||
const char *file_name1 = "eazel-services-logo.png";
|
||||
const char *file_name2 = "eazel-services-logo-tile.png";
|
||||
const char *file_name3 = "eazel-services-logo-tile.png";
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gdk_rgb_init ();
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window), "Graphic Test");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
||||
|
||||
main_box = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), main_box);
|
||||
|
||||
background = create_background ();
|
||||
|
||||
graphic1 = create_graphic (file_name1, background);
|
||||
graphic2 = create_graphic (file_name2, background);
|
||||
graphic3 = create_graphic (file_name3, background);
|
||||
background_graphic = create_graphic (NULL, background);
|
||||
|
||||
graphic_list = g_list_append (graphic_list, graphic1);
|
||||
graphic_list = g_list_append (graphic_list, graphic2);
|
||||
graphic_list = g_list_append (graphic_list, graphic3);
|
||||
graphic_list = g_list_append (graphic_list, background_graphic);
|
||||
|
||||
nautilus_graphic_set_placement_type (NAUTILUS_GRAPHIC (graphic2), NAUTILUS_GRAPHIC_PLACEMENT_TILE);
|
||||
nautilus_graphic_set_placement_type (NAUTILUS_GRAPHIC (graphic3), NAUTILUS_GRAPHIC_PLACEMENT_TILE);
|
||||
|
||||
{
|
||||
GdkFont *font;
|
||||
|
||||
font = gdk_font_load ("-adobe-helvetica-medium-r-normal--20-140-*");
|
||||
|
||||
nautilus_graphic_set_label_text (NAUTILUS_GRAPHIC (graphic3), "Welcome Back, Arlo!");
|
||||
nautilus_graphic_set_label_font (NAUTILUS_GRAPHIC (graphic3), font);
|
||||
|
||||
gdk_font_unref (font);
|
||||
}
|
||||
|
||||
graphic_box = gtk_hbox_new (FALSE, 0);
|
||||
tool_box = gtk_hbox_new (FALSE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (main_box), graphic_box, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (main_box), background_graphic, TRUE, TRUE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (main_box), tool_box, FALSE, FALSE, 10);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (graphic_box), graphic1, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (graphic_box), graphic2, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (graphic_box), graphic3, FALSE, FALSE, 0);
|
||||
|
||||
alpha_scale = create_color_scale (255, alpha_scale_value_changed, graphic_list);
|
||||
|
||||
toggle_background_type = gtk_button_new_with_label ("Toggle Background Type");
|
||||
red_scale = create_color_scale (255, red_color_value_changed, graphic_list);
|
||||
green_scale = create_color_scale (255, green_color_value_changed, graphic_list);
|
||||
blue_scale = create_color_scale (255, blue_color_value_changed, graphic_list);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (tool_box), alpha_scale, FALSE, FALSE, 5);
|
||||
gtk_box_pack_start (GTK_BOX (tool_box), toggle_background_type, FALSE, FALSE, 5);
|
||||
gtk_box_pack_start (GTK_BOX (tool_box), red_scale, FALSE, FALSE, 5);
|
||||
gtk_box_pack_start (GTK_BOX (tool_box), green_scale, FALSE, FALSE, 5);
|
||||
gtk_box_pack_start (GTK_BOX (tool_box), blue_scale, FALSE, FALSE, 5);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (toggle_background_type),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (toggle_background_type_callback),
|
||||
(gpointer) graphic1);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (toggle_background_type),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (toggle_background_type_callback),
|
||||
(gpointer) graphic2);
|
||||
gtk_signal_connect (GTK_OBJECT (toggle_background_type),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (toggle_background_type_callback),
|
||||
(gpointer) graphic3);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (toggle_background_type),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC (toggle_background_type_callback),
|
||||
(gpointer) background_graphic);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue