diff options
author | George Lebl <jirka@5z.com> | 2000-08-30 03:42:41 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2000-08-30 03:42:41 +0000 |
commit | 604906df19912e590c7f357e8f8c973b6b2bebe7 (patch) | |
tree | 37f3aeb1e284cbe4ae8235e21db6fc832ecd3896 /cut-n-paste-code | |
parent | 10792fdfe69b54289ff50920f98f1fac34851dc3 (diff) | |
download | nautilus-604906df19912e590c7f357e8f8c973b6b2bebe7.tar.gz |
This should close bug #1361
Tue Aug 29 22:43:15 2000 George Lebl <jirka@5z.com>
This should close bug #1361
* configure.in, cut-n-paste-code/widgets/Makefile.am,
cut-n-paste-code/widgets/nautilus-druid/*,
po/POTFILES.in:
Remove the nautilus druid hack from here. We can do all
that we need from libnautilus extensions without need of
cut and paste code.
* libnautilus-extensions/nautilus-druid.[ch],
libnautilus-extensions/nautilus-druid-page-eazel.[ch],
po/POTFILES.in:
Make NautilusDruid be a derivation of GnomeDruid and
the NautilusDruidPageEazel of GnomeDruidPage. Also make
use of more of the nautilus style of coding in both. Federico
will kill me for using remove/add to move a file, but it's more
then just a move anyway.
* src/nautilus-first-time-druid.c (set_up_proxy_config_page)
(next_update_page_callback) (next_update_feedback_page_callback)
(next_proxy_configuration_page_callback)
(finish_page_back_callback) (nautilus_first_time_druid_show)
(download_callback) (initiate_file_download):
Use the new nautilus druid and the new eazel druid page everywhere.
Also fix one case of double adding things to a GtkBox.
Diffstat (limited to 'cut-n-paste-code')
13 files changed, 0 insertions, 3247 deletions
diff --git a/cut-n-paste-code/widgets/Makefile.am b/cut-n-paste-code/widgets/Makefile.am index e7e7c5560..f482961a6 100644 --- a/cut-n-paste-code/widgets/Makefile.am +++ b/cut-n-paste-code/widgets/Makefile.am @@ -2,5 +2,4 @@ NULL= SUBDIRS =\ e-paned \ - nautilus-druid \ $(NULL) diff --git a/cut-n-paste-code/widgets/nautilus-druid/.cvsignore b/cut-n-paste-code/widgets/nautilus-druid/.cvsignore deleted file mode 100644 index 799fc9785..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -*.lo -*.la -Makefile -Makefile.in diff --git a/cut-n-paste-code/widgets/nautilus-druid/Makefile.am b/cut-n-paste-code/widgets/nautilus-druid/Makefile.am deleted file mode 100644 index c9df74417..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -NULL= - -noinst_LTLIBRARIES = libnautilus-druid.la - -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/cut-n-paste-code \ - $(VFS_CFLAGS) \ - $(GNOME_CFLAGS) \ - $(GDK_PIXBUF_CFLAGS) \ - $(NULL) - -libnautilus_druid_la_LDFLAGS = -static - -libnautilus_druid_la_SOURCES = \ - nautilus-druid-page-edge.c \ - nautilus-druid-page-standard.c \ - nautilus-druid-page-eazel.c \ - nautilus-druid-page.c \ - nautilus-druid.c \ - $(NULL) - -# Everything is private for now -noinst_HEADERS =\ - nautilus-druid-page-edge.h \ - nautilus-druid-page-standard.h \ - nautilus-druid-page-eazel.h \ - nautilus-druid-page.h \ - nautilus-druid.h \ - $(NULL) diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-eazel.c b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-eazel.c deleted file mode 100644 index 7fe9b06ad..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-eazel.c +++ /dev/null @@ -1,612 +0,0 @@ -/* gnome-druid-page-eazel.c - * Copyright (C) 1999 Red Hat, Inc. - * Copyright (C) 2000 Eazel, Inc. - * - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ - -#include <config.h> - -#include "nautilus-druid-page-eazel.h" - -#include <libgnomeui/gnome-uidefs.h> -#include <libgnomeui/libgnomeui.h> -#include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include "nautilus-druid.h" -#include <libgnome/gnome-i18n.h> - -#include <libnautilus-extensions/nautilus-file-utilities.h> - -struct _NautilusDruidPageEazelPrivate -{ - GnomeCanvasItem *background_item; - GnomeCanvasItem *background_image_item; - GnomeCanvasItem *topbar_image_item; - int topbar_image_width; - GnomeCanvasItem *topbar_image_stretch_item; - GnomeCanvasItem *title_item; - GnomeCanvasItem *text_item; - GnomeCanvasItem *sidebar_image_item; - GnomeCanvasItem *title_image_item; - GnomeCanvasItem *widget_item; -}; - -static void nautilus_druid_page_eazel_init (NautilusDruidPageEazel *druid_page_eazel); -static void nautilus_druid_page_eazel_class_init (NautilusDruidPageEazelClass *klass); -static void nautilus_druid_page_eazel_destroy (GtkObject *object); -static void nautilus_druid_page_eazel_construct (NautilusDruidPageEazel *druid_page_eazel); -static void nautilus_druid_page_eazel_configure_size(NautilusDruidPageEazel *druid_page_eazel, - gint width, - gint height); -static void nautilus_druid_page_eazel_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void nautilus_druid_page_eazel_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void nautilus_druid_page_eazel_prepare (NautilusDruidPage *page, - GtkWidget *druid, - gpointer *data); -static NautilusDruidPageClass *parent_class = NULL; - -#define TITLE_X 34.0 -#define TITLE_Y 60.0 -#define CONTENT_PADDING 15.0 -#define DEFAULT_CONTENT_X 34.0 -#define DRUID_PAGE_HEIGHT 322 -#define DRUID_PAGE_WIDTH 516 - - -GtkType -nautilus_druid_page_eazel_get_type (void) -{ - static GtkType druid_page_eazel_type = 0; - - if (!druid_page_eazel_type) - { - static const GtkTypeInfo druid_page_eazel_info = - { - "NautilusDruidPageEazel", - sizeof (NautilusDruidPageEazel), - sizeof (NautilusDruidPageEazelClass), - (GtkClassInitFunc) nautilus_druid_page_eazel_class_init, - (GtkObjectInitFunc) nautilus_druid_page_eazel_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - druid_page_eazel_type = gtk_type_unique (nautilus_druid_page_get_type (), &druid_page_eazel_info); - } - - return druid_page_eazel_type; -} - -static void -nautilus_druid_page_eazel_class_init (NautilusDruidPageEazelClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) klass; - object_class->destroy = nautilus_druid_page_eazel_destroy; - widget_class = (GtkWidgetClass*) klass; - widget_class->size_allocate = nautilus_druid_page_eazel_size_allocate; - widget_class->size_request = nautilus_druid_page_eazel_size_request; - parent_class = gtk_type_class (nautilus_druid_page_get_type ()); -} - -static void -nautilus_druid_page_eazel_init (NautilusDruidPageEazel *druid_page_eazel) -{ - druid_page_eazel->_priv = g_new0(NautilusDruidPageEazelPrivate, 1); - - /* Set up the canvas */ - gtk_container_set_border_width (GTK_CONTAINER (druid_page_eazel), 0); - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - druid_page_eazel->canvas = gnome_canvas_new_aa (); - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); - gtk_widget_set_usize (druid_page_eazel->canvas, DRUID_PAGE_WIDTH, DRUID_PAGE_HEIGHT); - gtk_widget_show (druid_page_eazel->canvas); - gnome_canvas_set_scroll_region (GNOME_CANVAS (druid_page_eazel->canvas), 0.0, 0.0, DRUID_PAGE_WIDTH, DRUID_PAGE_HEIGHT); - gtk_container_add (GTK_CONTAINER (druid_page_eazel), druid_page_eazel->canvas); - -} - -static void -nautilus_druid_page_eazel_destroy(GtkObject *object) -{ - NautilusDruidPageEazel *druid_page_eazel = NAUTILUS_DRUID_PAGE_EAZEL(object); - - druid_page_eazel->canvas = NULL; - druid_page_eazel->widget = NULL; - - g_free (druid_page_eazel->title); - druid_page_eazel->title = NULL; - g_free (druid_page_eazel->text); - druid_page_eazel->text = NULL; - - if (druid_page_eazel->title_image != NULL) - gdk_pixbuf_unref (druid_page_eazel->title_image); - druid_page_eazel->title_image = NULL; - if (druid_page_eazel->sidebar_image != NULL) - gdk_pixbuf_unref (druid_page_eazel->sidebar_image); - druid_page_eazel->sidebar_image = NULL; - - if (druid_page_eazel->widget != NULL) - gtk_widget_unref (druid_page_eazel->widget); - druid_page_eazel->widget = NULL; - - g_free(druid_page_eazel->_priv); - druid_page_eazel->_priv = NULL; - - if(GTK_OBJECT_CLASS(parent_class)->destroy) - (* GTK_OBJECT_CLASS(parent_class)->destroy)(object); -} - -static void -get_content_xy (NautilusDruidPageEazel *druid_page_eazel, - double *content_x, double *content_y) -{ - double title_height; - - if (druid_page_eazel->sidebar_image) { - *content_x = gdk_pixbuf_get_width (druid_page_eazel->sidebar_image); - } else { - *content_x = DEFAULT_CONTENT_X; - } - - if (druid_page_eazel->title_image) { - *content_y = gdk_pixbuf_get_height (druid_page_eazel->title_image) + TITLE_Y + CONTENT_PADDING; - } else { - *content_y = TITLE_Y; - } - - title_height = 0.0; - if (druid_page_eazel->title != NULL - && druid_page_eazel->title[0] != '\0') { - gtk_object_get (GTK_OBJECT (druid_page_eazel->_priv->title_item), - "text_height", &title_height, - NULL); - title_height += CONTENT_PADDING; - } - - if (*content_y < title_height + TITLE_Y) { - *content_y = title_height + TITLE_Y; - } -} - - -static void -nautilus_druid_page_eazel_configure_size (NautilusDruidPageEazel *druid_page_eazel, gint width, gint height) -{ - double content_x; - double content_y; - - g_return_if_fail (druid_page_eazel != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EAZEL (druid_page_eazel)); - - gnome_canvas_item_set (druid_page_eazel->_priv->background_item, - "x1", 0.0, - "y1", 0.0, - "x2", (gfloat) width, - "y2", (gfloat) height, - NULL); - - gnome_canvas_item_set (druid_page_eazel->_priv->topbar_image_stretch_item, - "width", (double) (width - druid_page_eazel->_priv->topbar_image_width), - NULL); - - get_content_xy (druid_page_eazel, &content_x, &content_y); - - if (druid_page_eazel->_priv->widget_item != NULL) - gnome_canvas_item_set (druid_page_eazel->_priv->widget_item, - "x", content_x, - "y", content_y, - "width", width - content_x, - "height", height - content_y, - NULL); - - gnome_canvas_item_set (druid_page_eazel->_priv->text_item, - "x", content_x, - "y", content_y, - NULL); - - -} - -static void -set_image (GnomeCanvasItem *item, const char *file, - int *width, int *height) -{ - char *fullname; - - if (width != NULL) - *width = 0; - if (height != NULL) - *height = 0; - - fullname = nautilus_pixmap_file (file); - if (fullname != NULL) { - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (fullname); - if (pixbuf != NULL) { - if (width != NULL) - *width = gdk_pixbuf_get_width (pixbuf); - if (height != NULL) - *height = gdk_pixbuf_get_height (pixbuf); - gnome_canvas_item_set (item, - "pixbuf", pixbuf, - NULL); - gdk_pixbuf_unref (pixbuf); - } - g_free (fullname); - } -} - -static void -nautilus_druid_page_eazel_construct (NautilusDruidPageEazel *druid_page_eazel) -{ - druid_page_eazel->_priv->background_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_rect_get_type (), - "x1", 0.0, - "y1", 0.0, - "fill_color", "white", - NULL); - - druid_page_eazel->_priv->background_image_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_pixbuf_get_type (), - "x", 0.0, - "y", 0.0, - "x_in_pixels", TRUE, - "y_in_pixels", TRUE, - NULL); - if (druid_page_eazel->background_image) - gnome_canvas_item_set (druid_page_eazel->_priv->background_image_item, - "pixbuf", druid_page_eazel->background_image, - NULL); - - druid_page_eazel->_priv->sidebar_image_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_pixbuf_get_type (), - "x", 0.0, - "y", 0.0, - "x_in_pixels", TRUE, - "y_in_pixels", TRUE, - NULL); - if (druid_page_eazel->sidebar_image) - gnome_canvas_item_set (druid_page_eazel->_priv->sidebar_image_item, - "pixbuf", druid_page_eazel->sidebar_image, - NULL); - - druid_page_eazel->_priv->topbar_image_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_pixbuf_get_type (), - "x", 0.0, - "y", 0.0, - "x_in_pixels", TRUE, - "y_in_pixels", TRUE, - NULL); - set_image (druid_page_eazel->_priv->topbar_image_item, - "druid_header.png", - &druid_page_eazel->_priv->topbar_image_width, - NULL); - - druid_page_eazel->_priv->topbar_image_stretch_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_pixbuf_get_type (), - "x", (double)druid_page_eazel->_priv->topbar_image_width, - "y", 0.0, - "width", (double)(DRUID_PAGE_WIDTH - druid_page_eazel->_priv->topbar_image_width), - "width_set", TRUE, - "x_in_pixels", TRUE, - "y_in_pixels", TRUE, - NULL); - set_image (druid_page_eazel->_priv->topbar_image_stretch_item, - "druid_header_stretch.png", NULL, NULL); - - druid_page_eazel->_priv->title_image_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_pixbuf_get_type (), - "x", TITLE_X, - "y", TITLE_Y, - "x_in_pixels", TRUE, - "y_in_pixels", TRUE, - NULL); - if (druid_page_eazel->title_image) - gnome_canvas_item_set (druid_page_eazel->_priv->title_image_item, - "pixbuf", druid_page_eazel->title_image, - NULL); - - druid_page_eazel->_priv->title_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_text_get_type (), - "x", TITLE_X, - "y", TITLE_Y, - "text", druid_page_eazel->title, - "fill_color", "black", - "fontset", _("-adobe-helvetica-bold-r-normal-*-*-180-*-*-p-*-*-*,*-r-*"), - "anchor", GTK_ANCHOR_NW, - NULL); - - druid_page_eazel->_priv->text_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_text_get_type (), - "text", druid_page_eazel->text, - "fill_color", "black", - "fontset", _("-adobe-helvetica-bold-r-normal-*-*-120-*-*-p-*-*-*,*-r-*"), - "anchor", GTK_ANCHOR_NW, - NULL); - - nautilus_druid_page_eazel_configure_size (druid_page_eazel, DRUID_PAGE_WIDTH, DRUID_PAGE_HEIGHT); - gtk_signal_connect (GTK_OBJECT (druid_page_eazel), - "prepare", - nautilus_druid_page_eazel_prepare, - NULL); -} - -static void -nautilus_druid_page_eazel_prepare (NautilusDruidPage *page, - GtkWidget *druid, - gpointer *data) -{ - switch (NAUTILUS_DRUID_PAGE_EAZEL (page)->position) { - case NAUTILUS_DRUID_START: - nautilus_druid_set_buttons_sensitive (NAUTILUS_DRUID (druid), FALSE, TRUE, TRUE); - nautilus_druid_set_show_finish (NAUTILUS_DRUID (druid), FALSE); - gtk_widget_grab_default (NAUTILUS_DRUID (druid)->next); - break; - case NAUTILUS_DRUID_FINISH: - nautilus_druid_set_buttons_sensitive (NAUTILUS_DRUID (druid), TRUE, FALSE, TRUE); - nautilus_druid_set_show_finish (NAUTILUS_DRUID (druid), TRUE); - gtk_widget_grab_default (NAUTILUS_DRUID (druid)->finish); - break; - case NAUTILUS_DRUID_OTHER: - nautilus_druid_set_buttons_sensitive (NAUTILUS_DRUID (druid), TRUE, TRUE, TRUE); - nautilus_druid_set_show_finish (NAUTILUS_DRUID (druid), FALSE); - default: - break; - } -} - - -static void -nautilus_druid_page_eazel_size_allocate(GtkWidget *widget, - GtkAllocation *allocation) -{ - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); - gnome_canvas_set_scroll_region (GNOME_CANVAS (NAUTILUS_DRUID_PAGE_EAZEL (widget)->canvas), - 0.0, 0.0, - allocation->width, - allocation->height); - nautilus_druid_page_eazel_configure_size (NAUTILUS_DRUID_PAGE_EAZEL (widget), - allocation->width, - allocation->height); -} - -static void -nautilus_druid_page_eazel_size_request(GtkWidget *widget, - GtkRequisition *requisition) -{ - NautilusDruidPageEazel *druid_page_eazel; - - druid_page_eazel = NAUTILUS_DRUID_PAGE_EAZEL (widget); - - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); - - if (druid_page_eazel->widget) { - GtkRequisition child_requisition; - double x, y; - - g_assert (druid_page_eazel->_priv->widget_item != NULL); - - gtk_object_get (GTK_OBJECT (druid_page_eazel->_priv->widget_item), - "x", &x, - "y", &y, - NULL); - - gtk_widget_get_child_requisition (druid_page_eazel->widget, - &child_requisition); - - if (child_requisition.width + x > requisition->width) { - requisition->width = child_requisition.width + x; - } - if (child_requisition.height + y > requisition->height) { - requisition->height = child_requisition.height + y; - } - - } -} - - -/** - * nautilus_druid_page_eazel_new: - * - * Creates a new NautilusDruidPageEazel widget. - * - * Return value: Pointer to new NautilusDruidPageEazel - **/ -/* Public functions */ -GtkWidget * -nautilus_druid_page_eazel_new (NautilusDruidPosition position) -{ - GtkWidget *retval = GTK_WIDGET (gtk_type_new (nautilus_druid_page_eazel_get_type ())); - - NAUTILUS_DRUID_PAGE_EAZEL (retval)->position = position; - NAUTILUS_DRUID_PAGE_EAZEL (retval)->title = g_strdup (""); - NAUTILUS_DRUID_PAGE_EAZEL (retval)->text = g_strdup (""); - NAUTILUS_DRUID_PAGE_EAZEL (retval)->title_image = NULL; - NAUTILUS_DRUID_PAGE_EAZEL (retval)->sidebar_image = NULL; - NAUTILUS_DRUID_PAGE_EAZEL (retval)->background_image = NULL; - nautilus_druid_page_eazel_construct (NAUTILUS_DRUID_PAGE_EAZEL (retval)); - return retval; -} -/** - * nautilus_druid_page_eazel_new_with_vals: - * @title: The title. - * @text: The introduction text. - * @logo: The logo in the upper right corner. - * @watermark: The watermark on the left. - * - * This will create a new GNOME Druid Eazel page, with the values - * given. It is acceptable for any of them to be %NULL. - * - * Return value: GtkWidget pointer to new NautilusDruidPageEazel. - **/ -GtkWidget * -nautilus_druid_page_eazel_new_with_vals (NautilusDruidPosition position, - const gchar *title, - const gchar* text, - GdkPixbuf *title_image, - GdkPixbuf *sidebar_image, - GdkPixbuf *background_image) -{ - GtkWidget *retval = GTK_WIDGET (gtk_type_new (nautilus_druid_page_eazel_get_type ())); - - NAUTILUS_DRUID_PAGE_EAZEL (retval)->position = position; - NAUTILUS_DRUID_PAGE_EAZEL (retval)->title = g_strdup (title ? title : ""); - NAUTILUS_DRUID_PAGE_EAZEL (retval)->text = g_strdup (text ? text : ""); - - if (title_image) - gdk_pixbuf_ref (title_image); - NAUTILUS_DRUID_PAGE_EAZEL (retval)->title_image = title_image; - - if (sidebar_image) - gdk_pixbuf_ref (sidebar_image); - NAUTILUS_DRUID_PAGE_EAZEL (retval)->sidebar_image = sidebar_image; - - if (background_image) - gdk_pixbuf_ref (background_image); - NAUTILUS_DRUID_PAGE_EAZEL (retval)->background_image = background_image; - - nautilus_druid_page_eazel_construct (NAUTILUS_DRUID_PAGE_EAZEL (retval)); - return retval; -} - -void -nautilus_druid_page_eazel_set_text (NautilusDruidPageEazel *druid_page_eazel, - const gchar *text) -{ - g_return_if_fail (druid_page_eazel != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EAZEL (druid_page_eazel)); - - g_free (druid_page_eazel->text); - druid_page_eazel->text = g_strdup (text ? text : ""); - gnome_canvas_item_set (druid_page_eazel->_priv->text_item, - "text", druid_page_eazel->text, - NULL); -} -void -nautilus_druid_page_eazel_set_title (NautilusDruidPageEazel *druid_page_eazel, - const gchar *title) -{ - g_return_if_fail (druid_page_eazel != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EAZEL (druid_page_eazel)); - - g_free (druid_page_eazel->title); - druid_page_eazel->title = g_strdup (title ? title : ""); - gnome_canvas_item_set (druid_page_eazel->_priv->title_item, - "text", druid_page_eazel->title, - NULL); -} -void -nautilus_druid_page_eazel_set_title_image (NautilusDruidPageEazel *druid_page_eazel, - GdkPixbuf *title_image) -{ - g_return_if_fail (druid_page_eazel != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EAZEL (druid_page_eazel)); - - if (druid_page_eazel->title_image) - gdk_pixbuf_unref (druid_page_eazel->title_image); - - druid_page_eazel->title_image = title_image; - if (title_image != NULL) - gdk_pixbuf_ref (title_image); - gnome_canvas_item_set (druid_page_eazel->_priv->title_image_item, - "pixbuf", druid_page_eazel->title_image, NULL); -} - -void -nautilus_druid_page_eazel_set_sidebar_image (NautilusDruidPageEazel *druid_page_eazel, - GdkPixbuf *sidebar_image) -{ - g_return_if_fail (druid_page_eazel != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EAZEL (druid_page_eazel)); - - if (druid_page_eazel->sidebar_image) - gdk_pixbuf_unref (druid_page_eazel->sidebar_image); - - druid_page_eazel->sidebar_image = sidebar_image; - if (sidebar_image != NULL) - gdk_pixbuf_ref (sidebar_image); - gnome_canvas_item_set (druid_page_eazel->_priv->sidebar_image_item, - "pixbuf", druid_page_eazel->sidebar_image, NULL); -} - -void -nautilus_druid_page_eazel_set_background_image (NautilusDruidPageEazel *druid_page_eazel, - GdkPixbuf *background_image) -{ - g_return_if_fail (druid_page_eazel != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EAZEL (druid_page_eazel)); - - if (druid_page_eazel->background_image) - gdk_pixbuf_unref (druid_page_eazel->background_image); - - druid_page_eazel->background_image = background_image; - if (background_image != NULL) - gdk_pixbuf_ref (background_image); - gnome_canvas_item_set (druid_page_eazel->_priv->background_image_item, - "pixbuf", druid_page_eazel->background_image, NULL); -} - -void -nautilus_druid_page_eazel_put_widget(NautilusDruidPageEazel *druid_page_eazel, GtkWidget *widget) -{ - double content_x; - double content_y; - - g_return_if_fail (druid_page_eazel != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EAZEL (druid_page_eazel)); - - get_content_xy (druid_page_eazel, &content_x, &content_y); - - if (druid_page_eazel->_priv->widget_item != NULL) - gtk_object_destroy (GTK_OBJECT (druid_page_eazel->_priv->widget_item)); - if (druid_page_eazel->widget != NULL) - gtk_widget_unref (druid_page_eazel->widget); - druid_page_eazel->widget = widget; - if (widget != NULL) - gtk_widget_ref (widget); - - druid_page_eazel->_priv->widget_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_eazel->canvas)), - gnome_canvas_widget_get_type (), - "x", content_x, - "y", content_y, - "width", DRUID_PAGE_WIDTH - content_x, - "height", DRUID_PAGE_HEIGHT - content_y, - "widget", widget, - NULL); - - gtk_widget_queue_resize (GTK_WIDGET (druid_page_eazel)); -} diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-eazel.h b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-eazel.h deleted file mode 100644 index 020b9acd0..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-eazel.h +++ /dev/null @@ -1,99 +0,0 @@ -/* nautilus-druid-page-eazel.h - * Copyright (C) 1999 Red Hat, Inc. - * - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ -#ifndef NAUTILUS_DRUID_PAGE_EAZEL_H -#define NAUTILUS_DRUID_PAGE_EAZEL_H - -#include <gtk/gtk.h> -#include <libgnomeui/gnome-canvas.h> -#include <widgets/nautilus-druid/nautilus-druid-page.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -BEGIN_GNOME_DECLS - -#define NAUTILUS_TYPE_DRUID_PAGE_EAZEL (nautilus_druid_page_eazel_get_type ()) -#define NAUTILUS_DRUID_PAGE_EAZEL(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_DRUID_PAGE_EAZEL, NautilusDruidPageEazel)) -#define NAUTILUS_DRUID_PAGE_EAZEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_DRUID_PAGE_EAZEL, NautilusDruidPageEazelClass)) -#define NAUTILUS_IS_DRUID_PAGE_EAZEL(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_DRUID_PAGE_EAZEL)) -#define NAUTILUS_IS_DRUID_PAGE_EAZEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DRUID_PAGE_EAZEL)) - -typedef enum { - /* update structure when adding enums */ - NAUTILUS_DRUID_START, - NAUTILUS_DRUID_FINISH, - NAUTILUS_DRUID_OTHER -} NautilusDruidPosition; - - -typedef struct _NautilusDruidPageEazel NautilusDruidPageEazel; -typedef struct _NautilusDruidPageEazelPrivate NautilusDruidPageEazelPrivate; -typedef struct _NautilusDruidPageEazelClass NautilusDruidPageEazelClass; - -struct _NautilusDruidPageEazel -{ - NautilusDruidPage parent; - - GtkWidget *canvas; - char *title; - char *text; - GdkPixbuf *title_image; - GdkPixbuf *sidebar_image; - GdkPixbuf *background_image; - - GtkWidget *widget; - - NautilusDruidPosition position : 2; - - /*< private >*/ - NautilusDruidPageEazelPrivate *_priv; -}; - -struct _NautilusDruidPageEazelClass -{ - NautilusDruidPageClass parent_class; -}; - -GtkType nautilus_druid_page_eazel_get_type (void); -GtkWidget *nautilus_druid_page_eazel_new (NautilusDruidPosition position); -GtkWidget *nautilus_druid_page_eazel_new_with_vals (NautilusDruidPosition position, - const gchar *title, - const gchar *text, - GdkPixbuf *title_image, - GdkPixbuf *sidebar_image, - GdkPixbuf *background_image); -void nautilus_druid_page_eazel_put_widget (NautilusDruidPageEazel *druid_page_eazel, - GtkWidget *widget); -void nautilus_druid_page_eazel_set_text (NautilusDruidPageEazel *druid_page_eazel, - const gchar *text); -void nautilus_druid_page_eazel_set_title (NautilusDruidPageEazel *druid_page_eazel, - const gchar *title); -void nautilus_druid_page_eazel_set_title_image (NautilusDruidPageEazel *druid_page_eazel, - GdkPixbuf *title_image); -void nautilus_druid_page_eazel_set_sidebar_image (NautilusDruidPageEazel *druid_page_eazel, - GdkPixbuf *sidebar_image); -void nautilus_druid_page_eazel_set_background_image(NautilusDruidPageEazel *druid_page_eazel, - GdkPixbuf *background_image); - -END_GNOME_DECLS - -#endif /* NAUTILUS_DRUID_PAGE_EAZEL_H */ diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-edge.c b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-edge.c deleted file mode 100644 index fde5b0e4d..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-edge.c +++ /dev/null @@ -1,561 +0,0 @@ -/* gnome-druid-page-edge.c - * Copyright (C) 1999 Red Hat, Inc. - * - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ - -#include <config.h> - -#include "nautilus-druid-page-edge.h" - -#include <libgnomeui/gnome-uidefs.h> -#include <libgnomeui/libgnomeui.h> -#include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include "nautilus-druid.h" -#include <libgnome/gnome-i18n.h> - - -struct _NautilusDruidPageEdgePrivate -{ - GtkWidget *canvas; - GnomeCanvasItem *background_item; - GnomeCanvasItem *textbox_item; - GnomeCanvasItem *text_item; - GnomeCanvasItem *logo_item; - GnomeCanvasItem *logoframe_item; - GnomeCanvasItem *watermark_item; - GnomeCanvasItem *title_item; -}; - -static void nautilus_druid_page_edge_init (NautilusDruidPageEdge *druid_page_edge); -static void nautilus_druid_page_edge_class_init (NautilusDruidPageEdgeClass *klass); -static void nautilus_druid_page_edge_destroy (GtkObject *object); -static void nautilus_druid_page_edge_construct (NautilusDruidPageEdge *druid_page_edge); -static void nautilus_druid_page_edge_configure_size(NautilusDruidPageEdge *druid_page_edge, - gint width, - gint height); -static void nautilus_druid_page_edge_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void nautilus_druid_page_edge_prepare (NautilusDruidPage *page, - GtkWidget *druid, - gpointer *data); -static NautilusDruidPageClass *parent_class = NULL; - -#define LOGO_WIDTH 50.0 -#define DRUID_PAGE_HEIGHT 318 -#define DRUID_PAGE_WIDTH 516 -#define DRUID_PAGE_LEFT_WIDTH 100.0 -#define GDK_COLOR_TO_RGBA(color) GNOME_CANVAS_COLOR (color.red/256, color.green/256, color.blue/256) - - -GtkType -nautilus_druid_page_edge_get_type (void) -{ - static GtkType druid_page_edge_type = 0; - - if (!druid_page_edge_type) - { - static const GtkTypeInfo druid_page_edge_info = - { - "NautilusDruidPageEdge", - sizeof (NautilusDruidPageEdge), - sizeof (NautilusDruidPageEdgeClass), - (GtkClassInitFunc) nautilus_druid_page_edge_class_init, - (GtkObjectInitFunc) nautilus_druid_page_edge_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - druid_page_edge_type = gtk_type_unique (nautilus_druid_page_get_type (), &druid_page_edge_info); - } - - return druid_page_edge_type; -} - -static void -nautilus_druid_page_edge_class_init (NautilusDruidPageEdgeClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) klass; - object_class->destroy = nautilus_druid_page_edge_destroy; - widget_class = (GtkWidgetClass*) klass; - widget_class->size_allocate = nautilus_druid_page_edge_size_allocate; - parent_class = gtk_type_class (nautilus_druid_page_get_type ()); -} - -static void -nautilus_druid_page_edge_init (NautilusDruidPageEdge *druid_page_edge) -{ - druid_page_edge->_priv = g_new0(NautilusDruidPageEdgePrivate, 1); - - /* initialize the color values */ - druid_page_edge->background_color.red = 6400; /* midnight blue */ - druid_page_edge->background_color.green = 6400; - druid_page_edge->background_color.blue = 28672; - druid_page_edge->textbox_color.red = 65280; /* white */ - druid_page_edge->textbox_color.green = 65280; - druid_page_edge->textbox_color.blue = 65280; - druid_page_edge->logo_background_color.red = 65280; /* white */ - druid_page_edge->logo_background_color.green = 65280; - druid_page_edge->logo_background_color.blue = 65280; - druid_page_edge->title_color.red = 65280; /* white */ - druid_page_edge->title_color.green = 65280; - druid_page_edge->title_color.blue = 65280; - druid_page_edge->text_color.red = 0; /* black */ - druid_page_edge->text_color.green = 0; - druid_page_edge->text_color.blue = 0; - - /* Set up the canvas */ - gtk_container_set_border_width (GTK_CONTAINER (druid_page_edge), 0); - druid_page_edge->_priv->canvas = gnome_canvas_new (); - gtk_widget_set_usize (druid_page_edge->_priv->canvas, DRUID_PAGE_WIDTH, DRUID_PAGE_HEIGHT); - gtk_widget_show (druid_page_edge->_priv->canvas); - gnome_canvas_set_scroll_region (GNOME_CANVAS (druid_page_edge->_priv->canvas), 0.0, 0.0, DRUID_PAGE_WIDTH, DRUID_PAGE_HEIGHT); - gtk_container_add (GTK_CONTAINER (druid_page_edge), druid_page_edge->_priv->canvas); - -} - -static void -nautilus_druid_page_edge_destroy(GtkObject *object) -{ - NautilusDruidPageEdge *druid_page_edge = NAUTILUS_DRUID_PAGE_EDGE(object); - - g_free(druid_page_edge->_priv); - druid_page_edge->_priv = NULL; - - if(GTK_OBJECT_CLASS(parent_class)->destroy) - (* GTK_OBJECT_CLASS(parent_class)->destroy)(object); -} - - -static void -nautilus_druid_page_edge_configure_size (NautilusDruidPageEdge *druid_page_edge, gint width, gint height) -{ - gfloat watermark_width = DRUID_PAGE_LEFT_WIDTH; - gfloat watermark_height = (gfloat) height - LOGO_WIDTH + GNOME_PAD * 2.0; - gfloat watermark_ypos = LOGO_WIDTH + GNOME_PAD * 2.0; - - if (druid_page_edge->watermark_image) { - watermark_width = gdk_pixbuf_get_width (druid_page_edge->watermark_image); - watermark_height = gdk_pixbuf_get_height (druid_page_edge->watermark_image); - watermark_ypos = (gfloat) height - watermark_height; - if (watermark_width < 1) - watermark_width = 1.0; - if (watermark_height < 1) - watermark_height = 1.0; - } - - gnome_canvas_item_set (druid_page_edge->_priv->background_item, - "x1", 0.0, - "y1", 0.0, - "x2", (gfloat) width, - "y2", (gfloat) height, - "width_units", 1.0, NULL); - gnome_canvas_item_set (druid_page_edge->_priv->textbox_item, - "x1", watermark_width, - "y1", LOGO_WIDTH + GNOME_PAD * 2.0, - "x2", (gfloat) width, - "y2", (gfloat) height, - "width_units", 1.0, NULL); - gnome_canvas_item_set (druid_page_edge->_priv->logoframe_item, - "x1", (gfloat) width - LOGO_WIDTH -GNOME_PAD, - "y1", (gfloat) GNOME_PAD, - "x2", (gfloat) width - GNOME_PAD, - "y2", (gfloat) GNOME_PAD + LOGO_WIDTH, - "width_units", 1.0, NULL); - gnome_canvas_item_set (druid_page_edge->_priv->logo_item, - "x", (gfloat) width - GNOME_PAD - LOGO_WIDTH, - "y", (gfloat) GNOME_PAD, - "width", (gfloat) LOGO_WIDTH, - "height", (gfloat) LOGO_WIDTH, NULL); - gnome_canvas_item_set (druid_page_edge->_priv->watermark_item, - "x", 0.0, - "y", watermark_ypos, - "width", watermark_width, - "height", watermark_height, - NULL); - gnome_canvas_item_set (druid_page_edge->_priv->title_item, - "x", 15.0, - "y", (gfloat) GNOME_PAD + LOGO_WIDTH / 2.0, - "anchor", GTK_ANCHOR_WEST, - NULL); - gnome_canvas_item_set (druid_page_edge->_priv->text_item, - "x", ((width - watermark_width) * 0.5) + watermark_width, - "y", LOGO_WIDTH + GNOME_PAD * 2.0 + (height - (LOGO_WIDTH + GNOME_PAD * 2.0))/ 2.0, - "anchor", GTK_ANCHOR_CENTER, - NULL); -} - -static void -nautilus_druid_page_edge_construct (NautilusDruidPageEdge *druid_page_edge) -{ - guint32 fill_color, outline_color; - - /* set up the rest of the page */ - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->background_color); - druid_page_edge->_priv->background_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_edge->_priv->canvas)), - gnome_canvas_rect_get_type (), - "fill_color_rgba", fill_color, - NULL); - - outline_color = fill_color; - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->textbox_color); - druid_page_edge->_priv->textbox_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_edge->_priv->canvas)), - gnome_canvas_rect_get_type (), - "fill_color_rgba", fill_color, - "outline_color_rgba", outline_color, - NULL); - - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->logo_background_color); - druid_page_edge->_priv->logoframe_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_edge->_priv->canvas)), - gnome_canvas_rect_get_type (), - "fill_color_rgba", fill_color, - NULL); - - druid_page_edge->_priv->logo_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_edge->_priv->canvas)), - gnome_canvas_pixbuf_get_type (), - "x_in_pixels", TRUE, "y_in_pixels", TRUE, - NULL); - - if (druid_page_edge->logo_image != NULL) - gnome_canvas_item_set (druid_page_edge->_priv->logo_item, - "pixbuf", druid_page_edge->logo_image, NULL); - - druid_page_edge->_priv->watermark_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_edge->_priv->canvas)), - gnome_canvas_pixbuf_get_type (), - "x_in_pixels", TRUE, "y_in_pixels", TRUE, - NULL); - - if (druid_page_edge->watermark_image != NULL) - gnome_canvas_item_set (druid_page_edge->_priv->watermark_item, - "pixbuf", druid_page_edge->watermark_image, NULL); - - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->title_color); - druid_page_edge->_priv->title_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_edge->_priv->canvas)), - gnome_canvas_text_get_type (), - "text", druid_page_edge->title, - "fill_color_rgba", fill_color, - "font", _("-adobe-helvetica-bold-r-normal-*-*-180-*-*-p-*-*-*"), - NULL); - - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->text_color); - druid_page_edge->_priv->text_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_edge->_priv->canvas)), - gnome_canvas_text_get_type (), - "text", druid_page_edge->text, - "justification", GTK_JUSTIFY_LEFT, - "font", _("-adobe-helvetica-medium-r-normal-*-*-120-*-*-p-*-*-*"), - "fill_color_rgba", fill_color, - NULL); - - nautilus_druid_page_edge_configure_size (druid_page_edge, DRUID_PAGE_WIDTH, DRUID_PAGE_HEIGHT); - gtk_signal_connect (GTK_OBJECT (druid_page_edge), - "prepare", - nautilus_druid_page_edge_prepare, - NULL); -} -static void -nautilus_druid_page_edge_prepare (NautilusDruidPage *page, - GtkWidget *druid, - gpointer *data) -{ - switch (NAUTILUS_DRUID_PAGE_EDGE (page)->position) { - case GNOME_EDGE_START: - nautilus_druid_set_buttons_sensitive (NAUTILUS_DRUID (druid), FALSE, TRUE, TRUE); - nautilus_druid_set_show_finish (NAUTILUS_DRUID (druid), FALSE); - gtk_widget_grab_default (NAUTILUS_DRUID (druid)->next); - break; - case GNOME_EDGE_FINISH: - nautilus_druid_set_buttons_sensitive (NAUTILUS_DRUID (druid), TRUE, FALSE, TRUE); - nautilus_druid_set_show_finish (NAUTILUS_DRUID (druid), TRUE); - gtk_widget_grab_default (NAUTILUS_DRUID (druid)->finish); - break; - case GNOME_EDGE_OTHER: - default: - break; - } -} - - -static void -nautilus_druid_page_edge_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); - gnome_canvas_set_scroll_region (GNOME_CANVAS (NAUTILUS_DRUID_PAGE_EDGE (widget)->_priv->canvas), - 0.0, 0.0, - allocation->width, - allocation->height); - nautilus_druid_page_edge_configure_size (NAUTILUS_DRUID_PAGE_EDGE (widget), - allocation->width, - allocation->height); -} - -#if 0 -{ -/* Fragment left behind by CVS. Don't get it. */ -gnome_canvas_item_set (druid_page_edge->_priv->background_item, - "fill_color_gdk", &(druid_page_edge->background_color), - NULL); -gnome_canvas_item_set (druid_page_edge->_priv->textbox_item, - "fill_color_gdk", &(druid_page_edge->textbox_color), - "outline_color_gdk", &(druid_page_edge->background_color), - NULL); -gnome_canvas_item_set (druid_page_edge->_priv->logoframe_item, - "fill_color_gdk", &druid_page_edge->logo_background_color, - NULL); -gnome_canvas_item_set (druid_page_edge->_priv->title_item, - "fill_color_gdk", &druid_page_edge->title_color, - NULL); -gnome_canvas_item_set (druid_page_edge->_priv->text_item, - "fill_color_gdk", &druid_page_edge->text_color, - NULL); -GTK_WIDGET_CLASS (parent_class)->realize (widget); -} -#endif - -/** - * nautilus_druid_page_edge_new: - * - * Creates a new NautilusDruidPageEdge widget. - * - * Return value: Pointer to new NautilusDruidPageEdge - **/ -/* Public functions */ -GtkWidget * -nautilus_druid_page_edge_new (GnomeEdgePosition position) -{ - GtkWidget *retval = GTK_WIDGET (gtk_type_new (nautilus_druid_page_edge_get_type ())); - - NAUTILUS_DRUID_PAGE_EDGE (retval)->position = position; - NAUTILUS_DRUID_PAGE_EDGE (retval)->title = g_strdup (""); - NAUTILUS_DRUID_PAGE_EDGE (retval)->text = g_strdup (""); - NAUTILUS_DRUID_PAGE_EDGE (retval)->logo_image = NULL; - NAUTILUS_DRUID_PAGE_EDGE (retval)->watermark_image = NULL; - nautilus_druid_page_edge_construct (NAUTILUS_DRUID_PAGE_EDGE (retval)); - return retval; -} -/** - * nautilus_druid_page_edge_new_with_vals: - * @title: The title. - * @text: The introduction text. - * @logo: The logo in the upper right corner. - * @watermark: The watermark on the left. - * - * This will create a new GNOME Druid Edge page, with the values - * given. It is acceptable for any of them to be %NULL. - * - * Return value: GtkWidget pointer to new NautilusDruidPageEdge. - **/ -GtkWidget * -nautilus_druid_page_edge_new_with_vals (GnomeEdgePosition position, - const gchar *title, - const gchar* text, - GdkPixbuf *logo, - GdkPixbuf *watermark) -{ - GtkWidget *retval = GTK_WIDGET (gtk_type_new (nautilus_druid_page_edge_get_type ())); - - NAUTILUS_DRUID_PAGE_EDGE (retval)->position = position; - NAUTILUS_DRUID_PAGE_EDGE (retval)->title = g_strdup (title); - NAUTILUS_DRUID_PAGE_EDGE (retval)->text = g_strdup (text); - - if (logo) - gdk_pixbuf_ref (logo); - NAUTILUS_DRUID_PAGE_EDGE (retval)->logo_image = logo; - - if (watermark) - gdk_pixbuf_ref (watermark); - NAUTILUS_DRUID_PAGE_EDGE (retval)->watermark_image = watermark; - nautilus_druid_page_edge_construct (NAUTILUS_DRUID_PAGE_EDGE (retval)); - return retval; -} - -/** - * nautilus_druid_page_edge_set_bg_color: - * @druid_page_edge: A DruidPageEdge. - * @color: The new background color. - * - * This will set the background color to be the @color. You do not - * need to allocate the color, as the @druid_page_edge will do it for - * you. - **/ -void -nautilus_druid_page_edge_set_bg_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color) -{ - guint fill_color; - - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - druid_page_edge->background_color.red = color->red; - druid_page_edge->background_color.green = color->green; - druid_page_edge->background_color.blue = color->blue; - - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->background_color); - - gnome_canvas_item_set (druid_page_edge->_priv->textbox_item, - "outline_color_rgba", fill_color, - NULL); - gnome_canvas_item_set (druid_page_edge->_priv->background_item, - "fill_color_rgba", fill_color, - NULL); -} - -void -nautilus_druid_page_edge_set_textbox_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color) -{ - guint fill_color; - - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - druid_page_edge->textbox_color.red = color->red; - druid_page_edge->textbox_color.green = color->green; - druid_page_edge->textbox_color.blue = color->blue; - - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->textbox_color); - gnome_canvas_item_set (druid_page_edge->_priv->textbox_item, - "fill_color_rgba", fill_color, - NULL); -} - -void -nautilus_druid_page_edge_set_logo_bg_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color) -{ - guint fill_color; - - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - druid_page_edge->logo_background_color.red = color->red; - druid_page_edge->logo_background_color.green = color->green; - druid_page_edge->logo_background_color.blue = color->blue; - - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->logo_background_color); - gnome_canvas_item_set (druid_page_edge->_priv->logoframe_item, - "fill_color_rgba", fill_color, - NULL); -} -void -nautilus_druid_page_edge_set_title_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color) -{ - guint32 fill_color; - - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - druid_page_edge->title_color.red = color->red; - druid_page_edge->title_color.green = color->green; - druid_page_edge->title_color.blue = color->blue; - - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->title_color); - gnome_canvas_item_set (druid_page_edge->_priv->title_item, - "fill_color_rgba", fill_color, - NULL); -} -void -nautilus_druid_page_edge_set_text_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color) -{ - guint32 fill_color; - - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - druid_page_edge->text_color.red = color->red; - druid_page_edge->text_color.green = color->green; - druid_page_edge->text_color.blue = color->blue; - - fill_color = GDK_COLOR_TO_RGBA (druid_page_edge->text_color); - gnome_canvas_item_set (druid_page_edge->_priv->text_item, - "fill_color_rgba", fill_color, - NULL); -} -void -nautilus_druid_page_edge_set_text (NautilusDruidPageEdge *druid_page_edge, - const gchar *text) -{ - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - g_free (druid_page_edge->text); - druid_page_edge->text = g_strdup (text); - gnome_canvas_item_set (druid_page_edge->_priv->text_item, - "text", druid_page_edge->text, - NULL); -} -void -nautilus_druid_page_edge_set_title (NautilusDruidPageEdge *druid_page_edge, - const gchar *title) -{ - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - g_free (druid_page_edge->title); - druid_page_edge->title = g_strdup (title); - gnome_canvas_item_set (druid_page_edge->_priv->title_item, - "text", druid_page_edge->title, - NULL); -} -void -nautilus_druid_page_edge_set_logo (NautilusDruidPageEdge *druid_page_edge, - GdkPixbuf *logo_image) -{ - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - if (druid_page_edge->logo_image) - gdk_pixbuf_unref (druid_page_edge->logo_image); - - druid_page_edge->logo_image = logo_image; - gdk_pixbuf_ref (logo_image); - gnome_canvas_item_set (druid_page_edge->_priv->logo_item, - "pixbuf", druid_page_edge->logo_image, NULL); -} -void -nautilus_druid_page_edge_set_watermark (NautilusDruidPageEdge *druid_page_edge, - GdkPixbuf *watermark) -{ - g_return_if_fail (druid_page_edge != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_EDGE (druid_page_edge)); - - if (druid_page_edge->watermark_image) - gdk_pixbuf_unref (druid_page_edge->watermark_image); - - druid_page_edge->watermark_image = watermark; - gdk_pixbuf_ref (watermark); - gnome_canvas_item_set (druid_page_edge->_priv->watermark_item, - "pixbuf", druid_page_edge->watermark_image, NULL); -} diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-edge.h b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-edge.h deleted file mode 100644 index 60d95fe71..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-edge.h +++ /dev/null @@ -1,104 +0,0 @@ -/* nautilus-druid-page-edge.h - * Copyright (C) 1999 Red Hat, Inc. - * - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ -#ifndef __NAUTILUS_DRUID_PAGE_EDGE_H__ -#define __NAUTILUS_DRUID_PAGE_EDGE_H__ - -#include <gtk/gtk.h> -#include <libgnomeui/gnome-canvas.h> -#include <widgets/nautilus-druid/nautilus-druid-page.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -BEGIN_GNOME_DECLS - -#define NAUTILUS_TYPE_DRUID_PAGE_EDGE (nautilus_druid_page_edge_get_type ()) -#define NAUTILUS_DRUID_PAGE_EDGE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_DRUID_PAGE_EDGE, NautilusDruidPageEdge)) -#define NAUTILUS_DRUID_PAGE_EDGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_DRUID_PAGE_EDGE, NautilusDruidPageEdgeClass)) -#define NAUTILUS_IS_DRUID_PAGE_EDGE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_DRUID_PAGE_EDGE)) -#define NAUTILUS_IS_DRUID_PAGE_EDGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DRUID_PAGE_EDGE)) - -typedef enum { - /* update structure when adding enums */ - GNOME_EDGE_START, - GNOME_EDGE_FINISH, - GNOME_EDGE_OTHER -} GnomeEdgePosition; - - -typedef struct _NautilusDruidPageEdge NautilusDruidPageEdge; -typedef struct _NautilusDruidPageEdgePrivate NautilusDruidPageEdgePrivate; -typedef struct _NautilusDruidPageEdgeClass NautilusDruidPageEdgeClass; - -struct _NautilusDruidPageEdge -{ - NautilusDruidPage parent; - gchar *title; - gchar *text; - GdkPixbuf *logo_image; - GdkPixbuf *watermark_image; - - GdkColor background_color; - GdkColor textbox_color; - GdkColor logo_background_color; - GdkColor title_color; - GdkColor text_color; - - GnomeEdgePosition position : 2; - - /*< private >*/ - NautilusDruidPageEdgePrivate *_priv; -}; - -struct _NautilusDruidPageEdgeClass -{ - NautilusDruidPageClass parent_class; -}; - -GtkType nautilus_druid_page_edge_get_type (void); -GtkWidget *nautilus_druid_page_edge_new (GnomeEdgePosition position); -GtkWidget *nautilus_druid_page_edge_new_with_vals (GnomeEdgePosition position, - const gchar *title, - const gchar *text, - GdkPixbuf *logo, - GdkPixbuf *watermark); -void nautilus_druid_page_edge_set_bg_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color); -void nautilus_druid_page_edge_set_textbox_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color); -void nautilus_druid_page_edge_set_logo_bg_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color); -void nautilus_druid_page_edge_set_title_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color); -void nautilus_druid_page_edge_set_text_color (NautilusDruidPageEdge *druid_page_edge, - GdkColor *color); -void nautilus_druid_page_edge_set_text (NautilusDruidPageEdge *druid_page_edge, - const gchar *text); -void nautilus_druid_page_edge_set_title (NautilusDruidPageEdge *druid_page_edge, - const gchar *title); -void nautilus_druid_page_edge_set_logo (NautilusDruidPageEdge *druid_page_edge, - GdkPixbuf *logo_image); -void nautilus_druid_page_edge_set_watermark (NautilusDruidPageEdge *druid_page_edge, - GdkPixbuf *watermark); - -END_GNOME_DECLS - -#endif /* __NAUTILUS_DRUID_PAGE_EDGE_H__ */ diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-standard.c b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-standard.c deleted file mode 100644 index ed6be5713..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-standard.c +++ /dev/null @@ -1,433 +0,0 @@ -/* gnome-druid-page-standard.c - * Copyright (C) 1999 Red Hat, Inc. - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ - -#include <config.h> - -#include "nautilus-druid-page-standard.h" - -#include <libgnomeui/gnome-uidefs.h> -#include <libgnomeui/libgnomeui.h> -#include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include "nautilus-druid.h" -#include <libgnome/gnome-i18n.h> - -struct _NautilusDruidPageStandardPrivate -{ - GtkWidget *canvas; - GtkWidget *side_bar; - GnomeCanvasItem *logoframe_item; - GnomeCanvasItem *logo_item; - GnomeCanvasItem *title_item; - GnomeCanvasItem *background_item; - GtkWidget *bottom_bar; - GtkWidget *right_bar; -}; - - -static void nautilus_druid_page_standard_init (NautilusDruidPageStandard *druid_page_standard); -static void nautilus_druid_page_standard_class_init (NautilusDruidPageStandardClass *klass); -static void nautilus_druid_page_standard_destroy (GtkObject *object); -static void nautilus_druid_page_standard_construct (NautilusDruidPageStandard *druid_page_standard); -static void nautilus_druid_page_standard_configure_size(NautilusDruidPageStandard *druid_page_standard, - gint width, - gint height); -static void nautilus_druid_page_standard_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void nautilus_druid_page_standard_prepare (NautilusDruidPage *page, - GtkWidget *druid, - gpointer *data); - - -static NautilusDruidPageClass *parent_class = NULL; - -#define LOGO_WIDTH 50.0 -#define LOGO_HEIGHT 50.0 - -#define DRUID_PAGE_WIDTH 516 -#define GDK_COLOR_TO_RGBA(color) GNOME_CANVAS_COLOR (color.red/256, color.green/256, color.blue/256) - -GtkType -nautilus_druid_page_standard_get_type (void) -{ - static GtkType druid_page_standard_type = 0; - - if (!druid_page_standard_type) - { - static const GtkTypeInfo druid_page_standard_info = - { - "NautilusDruidPageStandard", - sizeof (NautilusDruidPageStandard), - sizeof (NautilusDruidPageStandardClass), - (GtkClassInitFunc) nautilus_druid_page_standard_class_init, - (GtkObjectInitFunc) nautilus_druid_page_standard_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - druid_page_standard_type = gtk_type_unique (nautilus_druid_page_get_type (), &druid_page_standard_info); - } - - return druid_page_standard_type; -} - -static void -nautilus_druid_page_standard_class_init (NautilusDruidPageStandardClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) klass; - object_class->destroy = nautilus_druid_page_standard_destroy; - widget_class = (GtkWidgetClass*) klass; - widget_class->size_allocate = nautilus_druid_page_standard_size_allocate; - - parent_class = gtk_type_class (nautilus_druid_page_get_type ()); - -} -static void -nautilus_druid_page_standard_init (NautilusDruidPageStandard *druid_page_standard) -{ - GtkRcStyle *rc_style; - GtkWidget *vbox; - GtkWidget *hbox; - - druid_page_standard->_priv = g_new0(NautilusDruidPageStandardPrivate, 1); - - /* initialize the color values */ - druid_page_standard->background_color.red = 6400; /* midnight blue */ - druid_page_standard->background_color.green = 6400; - druid_page_standard->background_color.blue = 28672; - druid_page_standard->logo_background_color.red = 65280; /* white */ - druid_page_standard->logo_background_color.green = 65280; - druid_page_standard->logo_background_color.blue = 65280; - druid_page_standard->title_color.red = 65280; /* white */ - druid_page_standard->title_color.green = 65280; - druid_page_standard->title_color.blue = 65280; - - /* Set up the widgets */ - vbox = gtk_vbox_new (FALSE, 0); - hbox = gtk_hbox_new (FALSE, 0); - druid_page_standard->vbox = gtk_vbox_new (FALSE, 0); - druid_page_standard->_priv->canvas = gnome_canvas_new_aa (); - druid_page_standard->_priv->side_bar = gtk_drawing_area_new (); - druid_page_standard->_priv->bottom_bar = gtk_drawing_area_new (); - druid_page_standard->_priv->right_bar = gtk_drawing_area_new (); - gtk_drawing_area_size (GTK_DRAWING_AREA (druid_page_standard->_priv->side_bar), - 15, 10); - gtk_drawing_area_size (GTK_DRAWING_AREA (druid_page_standard->_priv->bottom_bar), - 10, 1); - gtk_drawing_area_size (GTK_DRAWING_AREA (druid_page_standard->_priv->right_bar), - 1, 10); - rc_style = gtk_rc_style_new (); - rc_style->bg[GTK_STATE_NORMAL].red = 6400; - rc_style->bg[GTK_STATE_NORMAL].green = 6400; - rc_style->bg[GTK_STATE_NORMAL].blue = 28672; - rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_BG; - gtk_rc_style_ref (rc_style); - gtk_widget_modify_style (druid_page_standard->_priv->side_bar, rc_style); - gtk_rc_style_ref (rc_style); - gtk_widget_modify_style (druid_page_standard->_priv->bottom_bar, rc_style); - gtk_rc_style_ref (rc_style); - gtk_widget_modify_style (druid_page_standard->_priv->right_bar, rc_style); - - /* FIXME bugzilla.eazel.com 2552: can I just ref the old style? */ - rc_style = gtk_rc_style_new (); - rc_style->bg[GTK_STATE_NORMAL].red = 6400; - rc_style->bg[GTK_STATE_NORMAL].green = 6400; - rc_style->bg[GTK_STATE_NORMAL].blue = 28672; - rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_BG; - gtk_widget_modify_style (druid_page_standard->_priv->canvas, rc_style); - gtk_box_pack_start (GTK_BOX (vbox), druid_page_standard->_priv->canvas, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); - gtk_box_pack_end (GTK_BOX (vbox), druid_page_standard->_priv->bottom_bar, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), druid_page_standard->_priv->side_bar, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), druid_page_standard->vbox, TRUE, TRUE, 0); - gtk_box_pack_end (GTK_BOX (hbox), druid_page_standard->_priv->right_bar, FALSE, FALSE, 0); - gtk_widget_set_usize (druid_page_standard->_priv->canvas, 508, LOGO_HEIGHT + GNOME_PAD * 2); - gtk_container_set_border_width (GTK_CONTAINER (druid_page_standard), 0); - gtk_container_add (GTK_CONTAINER (druid_page_standard), vbox); - gtk_widget_show_all (vbox); -} - -static void -nautilus_druid_page_standard_destroy(GtkObject *object) -{ - NautilusDruidPageStandard *druid_page_standard = NAUTILUS_DRUID_PAGE_STANDARD(object); - - g_free(druid_page_standard->_priv); - druid_page_standard->_priv = NULL; - - if(GTK_OBJECT_CLASS(parent_class)->destroy) - (* GTK_OBJECT_CLASS(parent_class)->destroy)(object); -} - -static void -nautilus_druid_page_standard_configure_size (NautilusDruidPageStandard *druid_page_standard, gint width, gint height) -{ - gfloat cur_logo_width, cur_logo_height; - - if (druid_page_standard->logo_image) { - cur_logo_width = gdk_pixbuf_get_width (druid_page_standard->logo_image); - cur_logo_height = gdk_pixbuf_get_height (druid_page_standard->logo_image); - } else { - cur_logo_width = LOGO_WIDTH; - cur_logo_height = LOGO_HEIGHT; - } - - gnome_canvas_item_set (druid_page_standard->_priv->background_item, - "x1", 0.0, - "y1", 0.0, - "x2", (gfloat) width, - "y2", (gfloat) cur_logo_height + GNOME_PAD * 2, - "width_units", 1.0, NULL); - gnome_canvas_item_set (druid_page_standard->_priv->logoframe_item, - "x1", (gfloat) width - cur_logo_width - GNOME_PAD, - "y1", (gfloat) GNOME_PAD, - "x2", (gfloat) width - GNOME_PAD, - "y2", (gfloat) GNOME_PAD + cur_logo_height, - "width_units", 1.0, NULL); - gnome_canvas_item_set (druid_page_standard->_priv->logo_item, - "x", (gfloat) width - GNOME_PAD - cur_logo_width, - "y", (gfloat) GNOME_PAD, - "width", (gfloat) cur_logo_width, - "height", (gfloat) cur_logo_height, NULL); - gnome_canvas_item_set (druid_page_standard->_priv->title_item, - "x", 15.0, - "y", (gfloat) GNOME_PAD + cur_logo_height / 2.0, - "anchor", GTK_ANCHOR_WEST, - NULL); - -} - -static void -nautilus_druid_page_standard_construct (NautilusDruidPageStandard *druid_page_standard) -{ - static guint32 fill_color = 0; - - /* set up the rest of the page */ - fill_color = GDK_COLOR_TO_RGBA (druid_page_standard->background_color); - druid_page_standard->_priv->background_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_standard->_priv->canvas)), - gnome_canvas_rect_get_type (), - "fill_color_rgba", fill_color, - NULL); - - fill_color = GDK_COLOR_TO_RGBA (druid_page_standard->logo_background_color); - druid_page_standard->_priv->logoframe_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_standard->_priv->canvas)), - gnome_canvas_rect_get_type (), - "fill_color_rgba", fill_color, - NULL); - - druid_page_standard->_priv->logo_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_standard->_priv->canvas)), - gnome_canvas_pixbuf_get_type (), - "x_in_pixels", TRUE, "y_in_pixels", TRUE, - NULL); - - if (druid_page_standard->logo_image != NULL) { - gnome_canvas_item_set (druid_page_standard->_priv->logo_item, - "pixbuf", druid_page_standard->logo_image, NULL); - } - - fill_color = GDK_COLOR_TO_RGBA (druid_page_standard->title_color); - druid_page_standard->_priv->title_item = - gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (druid_page_standard->_priv->canvas)), - gnome_canvas_text_get_type (), - "text", druid_page_standard->title, - "font", _("-adobe-helvetica-bold-r-normal-*-*-180-*-*-p-*-*-*"), - "fill_color_rgba", fill_color, - NULL); - - nautilus_druid_page_standard_configure_size (druid_page_standard, DRUID_PAGE_WIDTH, GNOME_PAD * 2 + LOGO_HEIGHT); - gtk_signal_connect (GTK_OBJECT (druid_page_standard), - "prepare", - nautilus_druid_page_standard_prepare, - NULL); - -} -static void -nautilus_druid_page_standard_prepare (NautilusDruidPage *page, - GtkWidget *druid, - gpointer *data) -{ - nautilus_druid_set_buttons_sensitive (NAUTILUS_DRUID (druid), TRUE, TRUE, TRUE); - nautilus_druid_set_show_finish (NAUTILUS_DRUID (druid), FALSE); - gtk_widget_grab_default (NAUTILUS_DRUID (druid)->next); -} - -static void -nautilus_druid_page_standard_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); - gnome_canvas_set_scroll_region (GNOME_CANVAS (NAUTILUS_DRUID_PAGE_STANDARD (widget)->_priv->canvas), - 0.0, 0.0, - allocation->width, - allocation->height); - nautilus_druid_page_standard_configure_size (NAUTILUS_DRUID_PAGE_STANDARD (widget), - allocation->width, - allocation->height); -} - -GtkWidget * -nautilus_druid_page_standard_new (void) -{ - GtkWidget *retval = GTK_WIDGET (gtk_type_new (nautilus_druid_page_standard_get_type ())); - NAUTILUS_DRUID_PAGE_STANDARD (retval)->title = g_strdup (""); - NAUTILUS_DRUID_PAGE_STANDARD (retval)->logo_image = NULL; - nautilus_druid_page_standard_construct (NAUTILUS_DRUID_PAGE_STANDARD (retval)); - return retval; -} -GtkWidget * -nautilus_druid_page_standard_new_with_vals (const gchar *title, GdkPixbuf *logo) -{ - GtkWidget *retval = GTK_WIDGET (gtk_type_new (nautilus_druid_page_standard_get_type ())); - NAUTILUS_DRUID_PAGE_STANDARD (retval)->title = g_strdup (title); - NAUTILUS_DRUID_PAGE_STANDARD (retval)->logo_image = logo; - nautilus_druid_page_standard_construct (NAUTILUS_DRUID_PAGE_STANDARD (retval)); - return retval; -} -void -nautilus_druid_page_standard_set_bg_color (NautilusDruidPageStandard *druid_page_standard, - GdkColor *color) -{ - guint32 fill_color; - - g_return_if_fail (druid_page_standard != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_STANDARD (druid_page_standard)); - - druid_page_standard->background_color.red = color->red; - druid_page_standard->background_color.green = color->green; - druid_page_standard->background_color.blue = color->blue; - - fill_color = GDK_COLOR_TO_RGBA (druid_page_standard->background_color); - - gnome_canvas_item_set (druid_page_standard->_priv->background_item, - "fill_color_rgba", fill_color, - NULL); - - if (GTK_WIDGET_REALIZED (druid_page_standard)) { - - GtkStyle *style; - - style = gtk_style_copy (gtk_widget_get_style (druid_page_standard->_priv->side_bar)); - style->bg[GTK_STATE_NORMAL].red = color->red; - style->bg[GTK_STATE_NORMAL].green = color->green; - style->bg[GTK_STATE_NORMAL].blue = color->blue; - gtk_widget_set_style (druid_page_standard->_priv->side_bar, style); - gtk_widget_set_style (druid_page_standard->_priv->bottom_bar, style); - gtk_widget_set_style (druid_page_standard->_priv->right_bar, style); - } else { - GtkRcStyle *rc_style; - - rc_style = gtk_rc_style_new (); - rc_style->bg[GTK_STATE_NORMAL].red = color->red; - rc_style->bg[GTK_STATE_NORMAL].green = color->green; - rc_style->bg[GTK_STATE_NORMAL].blue = color->blue; - rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_BG; - gtk_rc_style_ref (rc_style); - gtk_widget_modify_style (druid_page_standard->_priv->side_bar, rc_style); - gtk_rc_style_ref (rc_style); - gtk_widget_modify_style (druid_page_standard->_priv->bottom_bar, rc_style); - gtk_rc_style_ref (rc_style); - gtk_widget_modify_style (druid_page_standard->_priv->right_bar, rc_style); - } -} - -void -nautilus_druid_page_standard_set_logo_bg_color (NautilusDruidPageStandard *druid_page_standard, - GdkColor *color) -{ - guint32 fill_color; - - g_return_if_fail (druid_page_standard != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_STANDARD (druid_page_standard)); - - druid_page_standard->logo_background_color.red = color->red; - druid_page_standard->logo_background_color.green = color->green; - druid_page_standard->logo_background_color.blue = color->blue; - - fill_color = GDK_COLOR_TO_RGBA (druid_page_standard->logo_background_color); - gnome_canvas_item_set (druid_page_standard->_priv->logoframe_item, - "fill_color_rgba", fill_color, - NULL); -} -void -nautilus_druid_page_standard_set_title_color (NautilusDruidPageStandard *druid_page_standard, - GdkColor *color) -{ - guint32 fill_color; - - g_return_if_fail (druid_page_standard != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_STANDARD (druid_page_standard)); - - druid_page_standard->title_color.red = color->red; - druid_page_standard->title_color.green = color->green; - druid_page_standard->title_color.blue = color->blue; - - fill_color = GDK_COLOR_TO_RGBA (druid_page_standard->title_color); - gnome_canvas_item_set (druid_page_standard->_priv->title_item, - "fill_color_rgba", fill_color, - NULL); -} - -void -nautilus_druid_page_standard_set_title (NautilusDruidPageStandard *druid_page_standard, - const gchar *title) -{ - g_return_if_fail (druid_page_standard != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_STANDARD (druid_page_standard)); - - g_free (druid_page_standard->title); - druid_page_standard->title = g_strdup (title); - gnome_canvas_item_set (druid_page_standard->_priv->title_item, - "text", druid_page_standard->title, - NULL); -} -void -nautilus_druid_page_standard_set_logo (NautilusDruidPageStandard *druid_page_standard, - GdkPixbuf*logo_image) -{ - GtkWidget *widget; - - g_return_if_fail (druid_page_standard != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE_STANDARD (druid_page_standard)); - - widget = GTK_WIDGET (druid_page_standard); - - if (druid_page_standard->logo_image) - gdk_pixbuf_unref (druid_page_standard->logo_image); - - druid_page_standard->logo_image = logo_image; - gdk_pixbuf_ref (logo_image); - gnome_canvas_item_set (druid_page_standard->_priv->logo_item, - "pixbuf", druid_page_standard->logo_image, NULL); - - nautilus_druid_page_standard_configure_size (druid_page_standard, - widget->allocation.width, - widget->allocation.height); - -} - diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-standard.h b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-standard.h deleted file mode 100644 index aff4fccb7..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page-standard.h +++ /dev/null @@ -1,82 +0,0 @@ -/* nautilus-druid-page-standard.h - * Copyright (C) 1999 Red Hat, Inc. - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ -#ifndef __NAUTILUS_DRUID_PAGE_STANDARD_H__ -#define __NAUTILUS_DRUID_PAGE_STANDARD_H__ - -#include <gtk/gtk.h> -#include <libgnomeui/gnome-canvas.h> -#include <widgets/nautilus-druid/nautilus-druid-page.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -BEGIN_GNOME_DECLS - -#define NAUTILUS_TYPE_DRUID_PAGE_STANDARD (nautilus_druid_page_standard_get_type ()) -#define NAUTILUS_DRUID_PAGE_STANDARD(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_DRUID_PAGE_STANDARD, NautilusDruidPageStandard)) -#define NAUTILUS_DRUID_PAGE_STANDARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_DRUID_PAGE_STANDARD, NautilusDruidPageStandardClass)) -#define NAUTILUS_IS_DRUID_PAGE_STANDARD(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_DRUID_PAGE_STANDARD)) -#define NAUTILUS_IS_DRUID_PAGE_STANDARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DRUID_PAGE_STANDARD)) - - -typedef struct _NautilusDruidPageStandard NautilusDruidPageStandard; -typedef struct _NautilusDruidPageStandardPrivate NautilusDruidPageStandardPrivate; -typedef struct _NautilusDruidPageStandardClass NautilusDruidPageStandardClass; - -struct _NautilusDruidPageStandard -{ - NautilusDruidPage parent; - - GtkWidget *vbox; - GdkPixbuf *logo_image; - - gchar *title; - - GdkColor background_color; - GdkColor logo_background_color; - GdkColor title_color; - - /*< private >*/ - NautilusDruidPageStandardPrivate *_priv; -}; -struct _NautilusDruidPageStandardClass -{ - NautilusDruidPageClass parent_class; -}; - - -GtkType nautilus_druid_page_standard_get_type (void); -GtkWidget *nautilus_druid_page_standard_new (void); -GtkWidget *nautilus_druid_page_standard_new_with_vals (const gchar *title, GdkPixbuf *logo); -void nautilus_druid_page_standard_set_bg_color (NautilusDruidPageStandard *druid_page_standard, - GdkColor *color); -void nautilus_druid_page_standard_set_logo_bg_color (NautilusDruidPageStandard *druid_page_standard, - GdkColor *color); -void nautilus_druid_page_standard_set_title_color (NautilusDruidPageStandard *druid_page_standard, - GdkColor *color); -void nautilus_druid_page_standard_set_title (NautilusDruidPageStandard *druid_page_standard, - const gchar *title); -void nautilus_druid_page_standard_set_logo (NautilusDruidPageStandard *druid_page_standard, - GdkPixbuf *logo_image); - -END_GNOME_DECLS - -#endif /* __NAUTILUS_DRUID_PAGE_STANDARD_H__ */ - diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page.c b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page.c deleted file mode 100644 index f7b8c303e..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page.c +++ /dev/null @@ -1,377 +0,0 @@ -/* gnome-druid-page.c - * Copyright (C) 1999 Red Hat, Inc. - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ - -#include <config.h> - -#include "nautilus-druid-page.h" - -enum { - NEXT, - PREPARE, - BACK, - FINISH, - CANCEL, - LAST_SIGNAL -}; - -static void nautilus_druid_page_init (NautilusDruidPage *druid_page); -static void nautilus_druid_page_class_init (NautilusDruidPageClass *klass); -static void nautilus_druid_page_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void nautilus_druid_page_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void nautilus_druid_page_draw (GtkWidget *widget, - GdkRectangle *area); -static gint nautilus_druid_page_expose (GtkWidget *widget, - GdkEventExpose *event); -static void nautilus_druid_page_realize (GtkWidget *widget); - -static GtkBinClass *parent_class = NULL; -static guint druid_page_signals[LAST_SIGNAL] = { 0 }; - - -GtkType -nautilus_druid_page_get_type (void) -{ - static GtkType druid_page_type = 0; - - if (!druid_page_type) { - static const GtkTypeInfo druid_page_info = - { - "NautilusDruidPage", - sizeof (NautilusDruidPage), - sizeof (NautilusDruidPageClass), - (GtkClassInitFunc) nautilus_druid_page_class_init, - (GtkObjectInitFunc) nautilus_druid_page_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - druid_page_type = gtk_type_unique (gtk_bin_get_type (), &druid_page_info); - } - - return druid_page_type; -} - -static void -nautilus_druid_page_class_init (NautilusDruidPageClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) klass; - widget_class = (GtkWidgetClass*) klass; - parent_class = gtk_type_class (gtk_bin_get_type ()); - - druid_page_signals[NEXT] = - gtk_signal_new ("next", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusDruidPageClass, next), - gtk_marshal_BOOL__POINTER, - GTK_TYPE_BOOL, 1, - GTK_TYPE_POINTER); - druid_page_signals[PREPARE] = - gtk_signal_new ("prepare", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusDruidPageClass, prepare), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - druid_page_signals[BACK] = - gtk_signal_new ("back", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusDruidPageClass, back), - gtk_marshal_BOOL__POINTER, - GTK_TYPE_BOOL, 1, - GTK_TYPE_POINTER); - druid_page_signals[FINISH] = - gtk_signal_new ("finish", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusDruidPageClass, finish), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - druid_page_signals[CANCEL] = - gtk_signal_new ("cancel", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusDruidPageClass, cancel), - gtk_marshal_BOOL__POINTER, - GTK_TYPE_BOOL, 1, - GTK_TYPE_POINTER); - - - gtk_object_class_add_signals (object_class, druid_page_signals, LAST_SIGNAL); - - widget_class->size_request = nautilus_druid_page_size_request; - widget_class->size_allocate = nautilus_druid_page_size_allocate; - widget_class->draw = nautilus_druid_page_draw; - widget_class->expose_event = nautilus_druid_page_expose; - widget_class->realize = nautilus_druid_page_realize; -} - - -static void -nautilus_druid_page_init (NautilusDruidPage *druid_page) -{ - druid_page->_priv = NULL; - /* Note: If you add any privates make sure to add a destroy method and - * free the private struct */ - GTK_WIDGET_UNSET_FLAGS (druid_page, GTK_NO_WINDOW); -} -static void -nautilus_druid_page_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkBin *bin; - - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (widget)); - g_return_if_fail (requisition != NULL); - bin = GTK_BIN (widget); - requisition->width = GTK_CONTAINER (widget)->border_width * 2; - requisition->height = GTK_CONTAINER (widget)->border_width * 2; - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - GtkRequisition child_requisition; - - gtk_widget_size_request (bin->child, &child_requisition); - - requisition->width += child_requisition.width; - requisition->height += child_requisition.height; - } -} -static void -nautilus_druid_page_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBin *bin; - GtkAllocation child_allocation; - - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (widget)); - g_return_if_fail (allocation != NULL); - widget->allocation = *allocation; - bin = GTK_BIN (widget); - - child_allocation.x = 0; - child_allocation.y = 0; - child_allocation.width = MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0); - child_allocation.height = MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0); - - if (GTK_WIDGET_REALIZED (widget)) { - gdk_window_move_resize (widget->window, - allocation->x + GTK_CONTAINER (widget)->border_width, - allocation->y + GTK_CONTAINER (widget)->border_width, - child_allocation.width, - child_allocation.height); - } - if (bin->child) { - gtk_widget_size_allocate (bin->child, &child_allocation); - } -} -static void -nautilus_druid_page_paint (GtkWidget *widget, - GdkRectangle *area) -{ - gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, area, widget, "base", 0, 0, -1, -1); -} - -static void -nautilus_druid_page_draw (GtkWidget *widget, - GdkRectangle *area) -{ - GdkRectangle child_area; - - if (!GTK_WIDGET_APP_PAINTABLE (widget)) - nautilus_druid_page_paint (widget, area); - - if (GTK_WIDGET_DRAWABLE (widget)) { - GdkRectangle tmp_area; - - tmp_area = *area; - tmp_area.x -= GTK_CONTAINER (widget)->border_width; - tmp_area.y -= GTK_CONTAINER (widget)->border_width; - - if (GTK_BIN (widget)->child && gtk_widget_intersect (GTK_BIN (widget)->child, &tmp_area, &child_area)) { - gtk_widget_draw (GTK_BIN (widget)->child, &child_area); - } - } -} -static gint -nautilus_druid_page_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - GdkEventExpose child_event; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_DRUID_PAGE (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - if (!GTK_WIDGET_APP_PAINTABLE (widget)) - nautilus_druid_page_paint (widget, &event->area); - - if (GTK_WIDGET_DRAWABLE (widget)) { - child_event = *event; - if (GTK_BIN (widget)->child && GTK_WIDGET_NO_WINDOW (GTK_BIN (widget)->child) && - gtk_widget_intersect (GTK_BIN (widget)->child, &event->area, &child_event.area)) { - gtk_widget_event (GTK_BIN (widget)->child, (GdkEvent*) &child_event); - } - } - - return FALSE; -} - -static void -nautilus_druid_page_realize (GtkWidget *widget) -{ - GdkWindowAttr attributes; - gint attributes_mask; - gint border_width; - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (widget)); - - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - border_width = GTK_CONTAINER (widget)->border_width; - - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - 2*border_width; - attributes.height = widget->allocation.height - 2*border_width; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = gtk_widget_get_events (widget) - | GDK_BUTTON_MOTION_MASK - | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_EXPOSURE_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - gdk_window_set_back_pixmap (widget->window, NULL, FALSE); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); -} -/** - * nautilus_druid_page_next: - * @druid_page: A DruidPage widget. - * - * Description: This will emit the "next" signal for that particular page. It - * is called by gnome-druid exclusively. It is expected that non-linear Druid's - * will override this signal and return TRUE if it handles changing pages. - * - * Return value: This function will return FALSE by default. - **/ -/* Public functions */ -gboolean -nautilus_druid_page_next (NautilusDruidPage *druid_page) -{ - gboolean retval = FALSE; - g_return_val_if_fail (druid_page != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_DRUID_PAGE (druid_page), FALSE); - gtk_signal_emit (GTK_OBJECT (druid_page), druid_page_signals [NEXT], GTK_WIDGET (druid_page)->parent, &retval); - return retval; -} -/** - * nautilus_druid_page_prepare: - * @druid_page: A DruidPage widget. - * - * Description: This emits the "prepare" signal for the page. It is called by - * gnome-druid exclusively. - **/ -void -nautilus_druid_page_prepare (NautilusDruidPage *druid_page) -{ - g_return_if_fail (druid_page != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (druid_page)); - - gtk_signal_emit (GTK_OBJECT (druid_page), druid_page_signals [PREPARE], GTK_WIDGET (druid_page)->parent); -} -/** - * nautilus_druid_page_back: - * @druid_page: A DruidPage widget. - * - * Description: This will emit the "back" signal for that particular page. It - * is called by gnome-druid exclusively. It is expected that non-linear Druid's - * will override this signal and return TRUE if it handles changing pages. - * - * Return value: This function will return FALSE by default. - **/ -gboolean -nautilus_druid_page_back (NautilusDruidPage *druid_page) -{ - gboolean retval = FALSE; - g_return_val_if_fail (druid_page != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_DRUID_PAGE (druid_page), FALSE); - - gtk_signal_emit (GTK_OBJECT (druid_page), druid_page_signals [BACK], GTK_WIDGET (druid_page)->parent, &retval); - return retval; -} -/** - * nautilus_druid_page_finish: - * @druid_page: A DruidPage widget. - * - * Description: This emits the "finish" signal for the page. It is called by - * gnome-druid exclusively. - **/ -void -nautilus_druid_page_finish (NautilusDruidPage *druid_page) -{ - g_return_if_fail (druid_page != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (druid_page)); - - gtk_signal_emit (GTK_OBJECT (druid_page), druid_page_signals [FINISH], GTK_WIDGET (druid_page)->parent); -} -/** - * nautilus_druid_page_cancel: - * @druid_page: A DruidPage widget. - * - * Description: This will emit the "cancel" signal for that particular page. It - * is called by gnome-druid exclusively. It is expected that a Druid will - * override this signal and return TRUE if it does not want to exit. - * - * Return value: This function will return FALSE by default. - **/ -gboolean -nautilus_druid_page_cancel (NautilusDruidPage *druid_page) -{ - gboolean retval = FALSE; - g_return_val_if_fail (druid_page != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_DRUID_PAGE (druid_page), FALSE); - gtk_signal_emit (GTK_OBJECT (druid_page), druid_page_signals [CANCEL], GTK_WIDGET (druid_page)->parent, &retval); - return retval; -} diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page.h b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page.h deleted file mode 100644 index 8a71f236a..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid-page.h +++ /dev/null @@ -1,72 +0,0 @@ -/* nautilus-druid-page.h - * Copyright (C) 1999 Red Hat, Inc. - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ -#ifndef __NAUTILUS_DRUID_PAGE_H__ -#define __NAUTILUS_DRUID_PAGE_H__ - -#include <gtk/gtk.h> -#include <libgnome/gnome-defs.h> - -BEGIN_GNOME_DECLS - -#define NAUTILUS_TYPE_DRUID_PAGE (nautilus_druid_page_get_type ()) -#define NAUTILUS_DRUID_PAGE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_DRUID_PAGE, NautilusDruidPage)) -#define NAUTILUS_DRUID_PAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_DRUID_PAGE, NautilusDruidPageClass)) -#define NAUTILUS_IS_DRUID_PAGE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_DRUID_PAGE)) -#define NAUTILUS_IS_DRUID_PAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DRUID_PAGE)) - - -typedef struct _NautilusDruidPage NautilusDruidPage; -typedef struct _NautilusDruidPagePrivate NautilusDruidPagePrivate; -typedef struct _NautilusDruidPageClass NautilusDruidPageClass; - -struct _NautilusDruidPage -{ - GtkBin parent; - NautilusDruidPagePrivate *_priv; -}; -struct _NautilusDruidPageClass -{ - GtkBinClass parent_class; - - gboolean (*next) (NautilusDruidPage *druid_page, GtkWidget *druid); - void (*prepare) (NautilusDruidPage *druid_page, GtkWidget *druid); - gboolean (*back) (NautilusDruidPage *druid_page, GtkWidget *druid); - void (*finish) (NautilusDruidPage *druid_page, GtkWidget *druid); - gboolean (*cancel) (NautilusDruidPage *druid_page, GtkWidget *druid); -}; - - -GtkType nautilus_druid_page_get_type (void); -gboolean nautilus_druid_page_next (NautilusDruidPage *druid_page); -void nautilus_druid_page_prepare (NautilusDruidPage *druid_page); -gboolean nautilus_druid_page_back (NautilusDruidPage *druid_page); -gboolean nautilus_druid_page_cancel (NautilusDruidPage *druid_page); -void nautilus_druid_page_finish (NautilusDruidPage *druid_page); - -END_GNOME_DECLS - -#endif /* __NAUTILUS_DRUID_PAGE_H__ */ - - - - diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid.c b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid.c deleted file mode 100644 index ecb181d45..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid.c +++ /dev/null @@ -1,794 +0,0 @@ -/* gnome-druid.c - * Copyright (C) 1999 Red Hat, Inc. - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ -#include <config.h> - -#include "nautilus-druid.h" -#include <libgnomeui/gnome-stock.h> -#include <libgnomeui/gnome-uidefs.h> -#include <libgnome/gnome-i18n.h> - -struct _NautilusDruidPrivate -{ - NautilusDruidPage *current; - GList *children; - - gboolean show_finish : 1; /* if TRUE, then we are showing the finish button instead of the next button */ -}; - -enum { - CANCEL, - LAST_SIGNAL -}; -static void nautilus_druid_init (NautilusDruid *druid); -static void nautilus_druid_class_init (NautilusDruidClass *klass); -static void nautilus_druid_destroy (GtkObject *object); -static void nautilus_druid_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void nautilus_druid_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void nautilus_druid_draw (GtkWidget *widget, - GdkRectangle *area); -static gint nautilus_druid_expose (GtkWidget *widget, - GdkEventExpose *event); -static void nautilus_druid_map (GtkWidget *widget); -static void nautilus_druid_unmap (GtkWidget *widget); -static GtkType nautilus_druid_child_type (GtkContainer *container); -static void nautilus_druid_add (GtkContainer *widget, - GtkWidget *page); -static void nautilus_druid_remove (GtkContainer *widget, - GtkWidget *child); -static void nautilus_druid_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static void nautilus_druid_back_callback (GtkWidget *button, - NautilusDruid *druid); -static void nautilus_druid_next_callback (GtkWidget *button, - NautilusDruid *druid); -static void nautilus_druid_cancel_callback (GtkWidget *button, - GtkWidget *druid); -static GtkContainerClass *parent_class = NULL; -static guint druid_signals[LAST_SIGNAL] = { 0 }; - - -GtkType -nautilus_druid_get_type (void) -{ - static GtkType druid_type = 0; - - if (!druid_type) - { - static const GtkTypeInfo druid_info = - { - "NautilusDruid", - sizeof (NautilusDruid), - sizeof (NautilusDruidClass), - (GtkClassInitFunc) nautilus_druid_class_init, - (GtkObjectInitFunc) nautilus_druid_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - druid_type = gtk_type_unique (gtk_container_get_type (), &druid_info); - } - - return druid_type; -} - -static void -nautilus_druid_class_init (NautilusDruidClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - object_class = (GtkObjectClass*) klass; - widget_class = (GtkWidgetClass*) klass; - container_class = (GtkContainerClass*) klass; - parent_class = gtk_type_class (gtk_container_get_type ()); - - druid_signals[CANCEL] = - gtk_signal_new ("cancel", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusDruidClass, cancel), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, druid_signals, LAST_SIGNAL); - - object_class->destroy = nautilus_druid_destroy; - widget_class->size_request = nautilus_druid_size_request; - widget_class->size_allocate = nautilus_druid_size_allocate; - widget_class->map = nautilus_druid_map; - widget_class->unmap = nautilus_druid_unmap; - widget_class->draw = nautilus_druid_draw; - widget_class->expose_event = nautilus_druid_expose; - - container_class->forall = nautilus_druid_forall; - container_class->add = nautilus_druid_add; - container_class->remove = nautilus_druid_remove; - container_class->child_type = nautilus_druid_child_type; -} - -static void -nautilus_druid_init (NautilusDruid *druid) -{ - GtkWidget *pixmap; - - druid->_priv = g_new0(NautilusDruidPrivate, 1); - - GTK_CONTAINER (druid)->border_width = GNOME_PAD_SMALL; - - /* set up the buttons */ - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (druid), GTK_NO_WINDOW); - pixmap = gnome_stock_new_with_icon(GNOME_STOCK_BUTTON_PREV); - druid->back = gnome_pixmap_button (pixmap, _("Back")); - GTK_WIDGET_SET_FLAGS (druid->back, GTK_CAN_DEFAULT); - druid->next = gnome_stock_or_ordinary_button (GNOME_STOCK_BUTTON_NEXT); - GTK_WIDGET_SET_FLAGS (druid->next, GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (druid->next, GTK_HAS_FOCUS); - druid->cancel = gnome_stock_or_ordinary_button (GNOME_STOCK_BUTTON_CANCEL); - GTK_WIDGET_SET_FLAGS (druid->cancel, GTK_CAN_DEFAULT); - pixmap = gnome_stock_new_with_icon(GNOME_STOCK_BUTTON_APPLY); - druid->finish = gnome_pixmap_button (pixmap, _("Finish")); - GTK_WIDGET_SET_FLAGS (druid->finish, GTK_CAN_DEFAULT); - gtk_widget_set_parent (druid->back, GTK_WIDGET (druid)); - gtk_widget_set_parent (druid->next, GTK_WIDGET (druid)); - gtk_widget_set_parent (druid->cancel, GTK_WIDGET (druid)); - gtk_widget_set_parent (druid->finish, GTK_WIDGET (druid)); - gtk_widget_show (druid->back); - gtk_widget_show (druid->next); - gtk_widget_show (druid->cancel); - gtk_widget_show (druid->finish); - - /* other flags */ - druid->_priv->current = NULL; - druid->_priv->children = NULL; - druid->_priv->show_finish = FALSE; - gtk_signal_connect (GTK_OBJECT (druid->back), - "clicked", - nautilus_druid_back_callback, - druid); - gtk_signal_connect (GTK_OBJECT (druid->next), - "clicked", - nautilus_druid_next_callback, - druid); - gtk_signal_connect (GTK_OBJECT (druid->cancel), - "clicked", - nautilus_druid_cancel_callback, - druid); - gtk_signal_connect (GTK_OBJECT (druid->finish), - "clicked", - nautilus_druid_next_callback, - druid); -} - - - -static void -nautilus_druid_destroy (GtkObject *object) -{ - NautilusDruid *druid; - - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (object)); - - druid = NAUTILUS_DRUID (object); - - if(GTK_OBJECT_CLASS(parent_class)->destroy) - GTK_OBJECT_CLASS(parent_class)->destroy(object); - - gtk_widget_destroy (druid->back); - druid->back = NULL; - gtk_widget_destroy (druid->next); - druid->next = NULL; - gtk_widget_destroy (druid->cancel); - druid->cancel = NULL; - gtk_widget_destroy (druid->finish); - druid->finish = NULL; - g_list_free (druid->_priv->children); - druid->_priv->children = NULL; - - g_free(druid->_priv); - druid->_priv = NULL; -} - -static void -nautilus_druid_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - guint16 temp_width, temp_height; - GList *list; - NautilusDruid *druid; - GtkRequisition child_requisition; - NautilusDruidPage *child; - int border; - - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (widget)); - - border = GTK_CONTAINER(widget)->border_width; - - druid = NAUTILUS_DRUID (widget); - temp_height = temp_width = 0; - - /* We find the maximum size of all children widgets */ - for (list = druid->_priv->children; list; list = list->next) { - child = NAUTILUS_DRUID_PAGE (list->data); - if (GTK_WIDGET_VISIBLE (child)) { - gtk_widget_size_request (GTK_WIDGET (child), &child_requisition); - temp_width = MAX (temp_width, child_requisition.width); - temp_height = MAX (temp_height, child_requisition.height); - if (GTK_WIDGET_MAPPED (child) && child != druid->_priv->current) - gtk_widget_unmap (GTK_WIDGET(child)); - } - } - - requisition->width = temp_width + 2 * border; - requisition->height = temp_height + 2 * border; - - /* In an Attempt to show how the widgets are packed, - * here's a little diagram. - * - * ------------- [ Back ] [ Next ] [ Cancel ] - * \ - * This part needs to be at least 1 button width. - * In addition, there is 1/4 X Button width between Cancel and Next, - * and a GNOME_PAD_SMALL between Next and Back. - */ - /* our_button width is temp_width and temp_height */ - temp_height = 0; - temp_width = 0; - - gtk_widget_size_request (druid->back, &child_requisition); - temp_width = MAX (temp_width, child_requisition.width); - temp_height = MAX (temp_height, child_requisition.height); - - gtk_widget_size_request (druid->next, &child_requisition); - temp_width = MAX (temp_width, child_requisition.width); - temp_height = MAX (temp_height, child_requisition.height); - - gtk_widget_size_request (druid->cancel, &child_requisition); - temp_width = MAX (temp_width, child_requisition.width); - temp_height = MAX (temp_height, child_requisition.height); - - gtk_widget_size_request (druid->finish, &child_requisition); - temp_width = MAX (temp_width, child_requisition.width); - temp_height = MAX (temp_height, child_requisition.height); - - temp_width += border * 2; - temp_height += GNOME_PAD_SMALL; - /* FIXME bugzilla.eazel.com 2553: do we need to do something with the buttons requisition? */ - temp_width = temp_width * 17/4 + GNOME_PAD_SMALL * 3; - - /* pick which is bigger, the buttons, or the NautilusDruidPages */ - requisition->width = MAX (temp_width, requisition->width); - requisition->height += temp_height; -} -static void -nautilus_druid_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - NautilusDruid *druid; - GtkAllocation child_allocation; - gint button_height; - GList *list; - int border; - - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (widget)); - - druid = NAUTILUS_DRUID (widget); - widget->allocation = *allocation; - - - - - /* deal with the buttons */ - child_allocation.width = child_allocation.height = 0; - child_allocation.width = druid->back->requisition.width; - child_allocation.height = druid->back->requisition.height; - child_allocation.width = MAX (child_allocation.width, - druid->next->requisition.width); - child_allocation.height = MAX (child_allocation.height, - druid->next->requisition.height); - child_allocation.width = MAX (child_allocation.width, - druid->cancel->requisition.width); - child_allocation.height = MAX (child_allocation.height, - druid->cancel->requisition.height); - - child_allocation.height += GNOME_PAD_SMALL; - button_height = child_allocation.height; - child_allocation.width += 2 * GNOME_PAD_SMALL; - child_allocation.x = allocation->x + allocation->width - GNOME_PAD_SMALL - child_allocation.width; - child_allocation.y = allocation->y + allocation->height - GNOME_PAD_SMALL - child_allocation.height; - gtk_widget_size_allocate (druid->cancel, &child_allocation); - child_allocation.x -= (child_allocation.width * 5 / 4); - gtk_widget_size_allocate (druid->next, &child_allocation); - gtk_widget_size_allocate (druid->finish, &child_allocation); - child_allocation.x -= (GNOME_PAD_SMALL + child_allocation.width); - gtk_widget_size_allocate (druid->back, &child_allocation); - - border = GTK_CONTAINER(widget)->border_width; - - /* Put up the NautilusDruidPage */ - child_allocation.x = allocation->x + border; - child_allocation.y = allocation->y + border; - child_allocation.width = - ((allocation->width - 2 * border) > 0) ? - (allocation->width - 2 * border):0; - child_allocation.height = - ((allocation->height - 2 * border - GNOME_PAD_SMALL - button_height) > 0) ? - (allocation->height - 2 * border - GNOME_PAD_SMALL - button_height):0; - for (list = druid->_priv->children; list; list=list->next) { - if (GTK_WIDGET_VISIBLE (list->data)) { - gtk_widget_size_allocate (GTK_WIDGET (list->data), &child_allocation); - } - } -} - -static GtkType -nautilus_druid_child_type (GtkContainer *container) -{ - return nautilus_druid_page_get_type (); -} - -static void -nautilus_druid_map (GtkWidget *widget) -{ - NautilusDruid *druid; - - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (widget)); - - druid = NAUTILUS_DRUID (widget); - GTK_WIDGET_SET_FLAGS (druid, GTK_MAPPED); - - gtk_widget_map (druid->back); - if (druid->_priv->show_finish) - gtk_widget_map (druid->finish); - else - gtk_widget_map (druid->next); - gtk_widget_map (druid->cancel); - if (druid->_priv->current && - GTK_WIDGET_VISIBLE (druid->_priv->current) && - !GTK_WIDGET_MAPPED (druid->_priv->current)) { - gtk_widget_map (GTK_WIDGET (druid->_priv->current)); - } -} - -static void -nautilus_druid_unmap (GtkWidget *widget) -{ - NautilusDruid *druid; - - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (widget)); - - druid = NAUTILUS_DRUID (widget); - GTK_WIDGET_UNSET_FLAGS (druid, GTK_MAPPED); - - gtk_widget_unmap (druid->back); - if (druid->_priv->show_finish) - gtk_widget_unmap (druid->finish); - else - gtk_widget_unmap (druid->next); - gtk_widget_unmap (druid->cancel); - if (druid->_priv->current && - GTK_WIDGET_VISIBLE (druid->_priv->current) && - GTK_WIDGET_MAPPED (druid->_priv->current)) - gtk_widget_unmap (GTK_WIDGET (druid->_priv->current)); -} -static void -nautilus_druid_add (GtkContainer *widget, - GtkWidget *page) -{ - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (widget)); - g_return_if_fail (page != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (page)); - - nautilus_druid_append_page (NAUTILUS_DRUID (widget), NAUTILUS_DRUID_PAGE (page)); -} -static void -nautilus_druid_remove (GtkContainer *widget, - GtkWidget *child) -{ - NautilusDruid *druid; - GList *list; - - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (widget)); - g_return_if_fail (child != NULL); - - druid = NAUTILUS_DRUID (widget); - - list = g_list_find (druid->_priv->children, child); - /* Is it a page? */ - if (list != NULL) { - /* If we are mapped and visible, we want to deal with changing the page. */ - if ((GTK_WIDGET_MAPPED (GTK_WIDGET (widget))) && - (list->data == (gpointer) druid->_priv->current) && - (list->next != NULL)) { - nautilus_druid_set_page (druid, NAUTILUS_DRUID_PAGE (list->next->data)); - } - } - druid->_priv->children = g_list_remove (druid->_priv->children, child); - gtk_widget_unparent (child); -} - -static void -nautilus_druid_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - NautilusDruid *druid; - NautilusDruidPage *child; - GList *children; - - g_return_if_fail (container != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (container)); - g_return_if_fail (callback != NULL); - - druid = NAUTILUS_DRUID (container); - - children = druid->_priv->children; - while (children) { - child = children->data; - children = children->next; - - (* callback) (GTK_WIDGET (child), callback_data); - } - if (include_internals) { - (* callback) (druid->back, callback_data); - (* callback) (druid->next, callback_data); - (* callback) (druid->cancel, callback_data); - (* callback) (druid->finish, callback_data); - } -} -static void -nautilus_druid_draw (GtkWidget *widget, - GdkRectangle *area) -{ - NautilusDruid *druid; - GdkRectangle child_area; - GtkWidget *child; - GList *children; - - g_return_if_fail (widget != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (widget)); - - if (GTK_WIDGET_DRAWABLE (widget)) { - druid = NAUTILUS_DRUID (widget); - children = druid->_priv->children; - - while (children) { - child = GTK_WIDGET (children->data); - children = children->next; - - if (GTK_WIDGET_DRAWABLE (child) && gtk_widget_intersect (child, area, &child_area)) { - gtk_widget_draw (child, &child_area); - } - } - child = druid->back; - if (GTK_WIDGET_DRAWABLE (child) && gtk_widget_intersect (child, area, &child_area)) - gtk_widget_draw (child, &child_area); - child = druid->next; - if (GTK_WIDGET_DRAWABLE (child) && gtk_widget_intersect (child, area, &child_area)) - gtk_widget_draw (child, &child_area); - child = druid->cancel; - if (GTK_WIDGET_DRAWABLE (child) && gtk_widget_intersect (child, area, &child_area)) - gtk_widget_draw (child, &child_area); - child = druid->finish; - if (GTK_WIDGET_DRAWABLE (child) && gtk_widget_intersect (child, area, &child_area)) - gtk_widget_draw (child, &child_area); - } -} - -static gint -nautilus_druid_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - NautilusDruid *druid; - GtkWidget *child; - GdkEventExpose child_event; - GList *children; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_DRUID (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - if (GTK_WIDGET_DRAWABLE (widget)) { - druid = NAUTILUS_DRUID (widget); - child_event = *event; - children = druid->_priv->children; - - while (children) { - child = GTK_WIDGET (children->data); - children = children->next; - - if (GTK_WIDGET_DRAWABLE (child) && - GTK_WIDGET_NO_WINDOW (child) && - gtk_widget_intersect (child, &event->area, &child_event.area)) { - gtk_widget_event (child, (GdkEvent*) &child_event); - } - } - child = druid->back; - if (GTK_WIDGET_DRAWABLE (child) && - GTK_WIDGET_NO_WINDOW (child) && - gtk_widget_intersect (child, &event->area, &child_event.area)) - gtk_widget_event (child, (GdkEvent*) &child_event); - child = druid->next; - if (GTK_WIDGET_DRAWABLE (child) && - GTK_WIDGET_NO_WINDOW (child) && - gtk_widget_intersect (child, &event->area, &child_event.area)) - gtk_widget_event (child, (GdkEvent*) &child_event); - child = druid->cancel; - if (GTK_WIDGET_DRAWABLE (child) && - GTK_WIDGET_NO_WINDOW (child) && - gtk_widget_intersect (child, &event->area, &child_event.area)) - gtk_widget_event (child, (GdkEvent*) &child_event); - child = druid->finish; - if (GTK_WIDGET_DRAWABLE (child) && - GTK_WIDGET_NO_WINDOW (child) && - gtk_widget_intersect (child, &event->area, &child_event.area)) - gtk_widget_event (child, (GdkEvent*) &child_event); - } - return FALSE; -} - -static void -nautilus_druid_back_callback (GtkWidget *button, NautilusDruid *druid) -{ - GList *list; - g_return_if_fail (druid->_priv->current != NULL); - - if (nautilus_druid_page_back (druid->_priv->current)) - return; - - /* Make sure that we have a next list item */ - list = g_list_find (druid->_priv->children, druid->_priv->current); - g_return_if_fail (list->prev != NULL); - nautilus_druid_set_page (druid, NAUTILUS_DRUID_PAGE (list->prev->data)); -} -static void -nautilus_druid_next_callback (GtkWidget *button, NautilusDruid *druid) -{ - GList *list; - g_return_if_fail (druid->_priv->current != NULL); - - if (druid->_priv->show_finish == FALSE) { - if (nautilus_druid_page_next (druid->_priv->current)) - return; - - /* Make sure that we have a next list item */ - /* FIXME bugzilla.eazel.com 2554: we want to find the next VISIBLE one... */ - list = g_list_find (druid->_priv->children, druid->_priv->current); - g_return_if_fail (list->next != NULL); - nautilus_druid_set_page (druid, NAUTILUS_DRUID_PAGE (list->next->data)); - } else { - nautilus_druid_page_finish (druid->_priv->current); - } -} -static void -nautilus_druid_cancel_callback (GtkWidget *button, GtkWidget *druid) -{ - if (NAUTILUS_DRUID (druid)->_priv->current) { - if (nautilus_druid_page_cancel (NAUTILUS_DRUID (druid)->_priv->current)) - return; - - gtk_signal_emit (GTK_OBJECT (druid), druid_signals [CANCEL]); - } -} - -/* Public Functions */ -GtkWidget * -nautilus_druid_new (void) -{ - return GTK_WIDGET (gtk_type_new (nautilus_druid_get_type ())); -} - -/** - * nautilus_druid_set_buttons_sensitive - * @druid: A Druid. - * @back_sensitive: The sensitivity of the back button. - * @next_sensitive: The sensitivity of the next button. - * @cancel_sensitive: The sensitivity of the cancel button. - * - * Description: Sets the sensitivity of the @druid's control-buttons. If the - * variables are TRUE, then they will be clickable. This function is used - * primarily by the actual NautilusDruidPage widgets. - **/ - -void -nautilus_druid_set_buttons_sensitive (NautilusDruid *druid, - gboolean back_sensitive, - gboolean next_sensitive, - gboolean cancel_sensitive) -{ - g_return_if_fail (druid != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (druid)); - - gtk_widget_set_sensitive (druid->back, back_sensitive); - gtk_widget_set_sensitive (druid->next, next_sensitive); - gtk_widget_set_sensitive (druid->cancel, cancel_sensitive); -} -/** - * nautilus_druid_set_show_finish - * @druid: A Druid widget. - # @show_finish: If TRUE, then the "Cancel" button is changed to be "Finish" - * - * Description: Sets the text on the last button on the @druid. If @show_finish - * is TRUE, then the text becomes "Finish". If @show_finish is FALSE, then the - * text becomes "Cancel". - **/ -void -nautilus_druid_set_show_finish (NautilusDruid *druid, - gboolean show_finish) -{ - g_return_if_fail (druid != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (druid)); - - if (show_finish) { - if (GTK_WIDGET_MAPPED (druid->next)) { - gtk_widget_unmap (druid->next); - gtk_widget_map (druid->finish); - } - } else { - if (GTK_WIDGET_MAPPED (druid->finish)) { - gtk_widget_unmap (druid->finish); - gtk_widget_map (druid->next); - } - } - druid->_priv->show_finish = show_finish; -} -/** - * nautilus_druid_prepend_page: - * @druid: A Druid widget. - * @page: The page to be inserted. - * - * Description: This will prepend a NautilusDruidPage into the internal list of - * pages that the @druid has. - **/ -void -nautilus_druid_prepend_page (NautilusDruid *druid, - NautilusDruidPage *page) -{ - g_return_if_fail (druid != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (druid)); - g_return_if_fail (page != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (page)); - - nautilus_druid_insert_page (druid, NULL, page); -} -/** - * nautilus_druid_insert_page: - * @druid: A Druid widget. - * @back_page: The page prior to the page to be inserted. - * @page: The page to insert. - * - * Description: This will insert @page after @back_page into the list of - * internal pages that the @druid has. If @back_page is not present in the list - * or NULL, @page will be prepended to the list. - **/ -void -nautilus_druid_insert_page (NautilusDruid *druid, - NautilusDruidPage *back_page, - NautilusDruidPage *page) -{ - GList *list; - - g_return_if_fail (druid != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (druid)); - g_return_if_fail (page != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (page)); - - list = g_list_find (druid->_priv->children, back_page); - if (list == NULL) - druid->_priv->children = g_list_prepend (druid->_priv->children, page); - else { - GList *new_el = g_list_alloc (); - new_el->next = list->next; - new_el->prev = list; - if (new_el->next) - new_el->next->prev = new_el; - new_el->prev->next = new_el; - new_el->data = (gpointer) page; - } - gtk_widget_set_parent (GTK_WIDGET (page), GTK_WIDGET (druid)); - - if (GTK_WIDGET_REALIZED (GTK_WIDGET (druid))) - gtk_widget_realize (GTK_WIDGET (page)); - - if (GTK_WIDGET_VISIBLE (GTK_WIDGET (druid)) && GTK_WIDGET_VISIBLE (GTK_WIDGET (page))) { - if (GTK_WIDGET_MAPPED (GTK_WIDGET (page))) - gtk_widget_unmap (GTK_WIDGET (page)); - gtk_widget_queue_resize (GTK_WIDGET (druid)); - } - - /* if it's the first and only page, we want to bring it to the foreground. */ - if (druid->_priv->children->next == NULL) - nautilus_druid_set_page (druid, page); -} - -/** - * nautilus_druid_append_page: - * @druid: A Druid widget. - * @page: The page to be appended. - * - * Description: This will append @page onto the end of the internal list. - **/ -void nautilus_druid_append_page (NautilusDruid *druid, - NautilusDruidPage *page) -{ - GList *list; - g_return_if_fail (druid != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (druid)); - g_return_if_fail (page != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (page)); - - list = g_list_last (druid->_priv->children); - if (list) { - nautilus_druid_insert_page (druid, NAUTILUS_DRUID_PAGE (list->data), page); - } else { - nautilus_druid_insert_page (druid, NULL, page); - } -} -/** - * nautilus_druid_set_page: - * @druid: A Druid widget. - * @page: The page to be brought to the foreground. - * - * Description: This will make @page the currently showing page in the druid. - * @page must already be in the druid. - **/ -void -nautilus_druid_set_page (NautilusDruid *druid, - NautilusDruidPage *page) -{ - GList *list; - GtkWidget *old = NULL; - g_return_if_fail (druid != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID (druid)); - g_return_if_fail (page != NULL); - g_return_if_fail (NAUTILUS_IS_DRUID_PAGE (page)); - - if (druid->_priv->current == page) - return; - list = g_list_find (druid->_priv->children, page); - g_return_if_fail (list != NULL); - - if ((druid->_priv->current) && (GTK_WIDGET_VISIBLE (druid->_priv->current)) && (GTK_WIDGET_MAPPED (druid))) { - old = GTK_WIDGET (druid->_priv->current); - } - druid->_priv->current = NAUTILUS_DRUID_PAGE (list->data); - nautilus_druid_page_prepare (druid->_priv->current); - if (GTK_WIDGET_VISIBLE (druid->_priv->current) && (GTK_WIDGET_MAPPED (druid))) { - gtk_widget_map (GTK_WIDGET (druid->_priv->current)); - } - if (old && GTK_WIDGET_MAPPED (old)) - gtk_widget_unmap (old); -} diff --git a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid.h b/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid.h deleted file mode 100644 index 50c0ee358..000000000 --- a/cut-n-paste-code/widgets/nautilus-druid/nautilus-druid.h +++ /dev/null @@ -1,76 +0,0 @@ -/* nautilus-druid.h - * Copyright (C) 1999 Red Hat, Inc. - * All rights reserved. - * - * This 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. - * - * This 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 this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ -*/ -/* TODO: allow setting bgcolor for all pages globally */ -#ifndef __NAUTILUS_DRUID_H__ -#define __NAUTILUS_DRUID_H__ - -#include <gtk/gtk.h> -#include <widgets/nautilus-druid/nautilus-druid-page.h> -#include <libgnome/gnome-defs.h> -BEGIN_GNOME_DECLS - -#define NAUTILUS_TYPE_DRUID (nautilus_druid_get_type ()) -#define NAUTILUS_DRUID(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_DRUID, NautilusDruid)) -#define NAUTILUS_DRUID_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_DRUID, NautilusDruidClass)) -#define NAUTILUS_IS_DRUID(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_DRUID)) -#define NAUTILUS_IS_DRUID_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DRUID)) - - -typedef struct _NautilusDruid NautilusDruid; -typedef struct _NautilusDruidPrivate NautilusDruidPrivate; -typedef struct _NautilusDruidClass NautilusDruidClass; - -struct _NautilusDruid -{ - GtkContainer parent; - GtkWidget *back; - GtkWidget *next; - GtkWidget *cancel; - GtkWidget *finish; - - /*< private >*/ - NautilusDruidPrivate *_priv; -}; -struct _NautilusDruidClass -{ - GtkContainerClass parent_class; - - void (*cancel) (NautilusDruid *druid); -}; - - -GtkType nautilus_druid_get_type (void); -GtkWidget *nautilus_druid_new (void); -void nautilus_druid_set_buttons_sensitive (NautilusDruid *druid, - gboolean back_sensitive, - gboolean next_sensitive, - gboolean cancel_sensitive); -void nautilus_druid_set_show_finish (NautilusDruid *druid, gboolean show_finish); -void nautilus_druid_prepend_page (NautilusDruid *druid, NautilusDruidPage *page); -void nautilus_druid_insert_page (NautilusDruid *druid, NautilusDruidPage *back_page, NautilusDruidPage *page); -void nautilus_druid_append_page (NautilusDruid *druid, NautilusDruidPage *page); -void nautilus_druid_set_page (NautilusDruid *druid, NautilusDruidPage *page); - -END_GNOME_DECLS - -#endif /* __NAUTILUS_DRUID_H__ */ |