diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-10-25 12:57:09 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-10-25 12:57:09 +0000 |
commit | 9d7b99e6f6bb593999fedd41d136e7f69a62131a (patch) | |
tree | d28a5a8c89dccbdd79571d9e1bffb47f9ce29464 /components/services/nautilus-dependent-shared | |
parent | ace7eb3c81d650f5c6b26ed089f6c7c4be1c7aec (diff) | |
download | nautilus-9d7b99e6f6bb593999fedd41d136e7f69a62131a.tar.gz |
Two new widgets to deal with services views headers and footers.
* components/services/nautilus-dependent-shared/.cvsignore:
* components/services/nautilus-dependent-shared/Makefile.am:
* components/services/nautilus-dependent-shared/eazel-services-constants.h:
* components/services/nautilus-dependent-shared/eazel-services-footer.c:
(eazel_services_footer_initialize_class),
(eazel_services_footer_initialize), (footer_destroy),
(pixbuf_new_from_name), (label_new), (label_enter_event),
(label_leave_event), (label_button_press_event), (label_free_data),
(label_free_uri), (image_new), (image_new_from_name),
(buffered_widget_add_prelighting), (footer_item_new),
(footer_remainder_new), (eazel_services_footer_new),
(eazel_services_footer_update):
* components/services/nautilus-dependent-shared/eazel-services-footer.h:
* components/services/nautilus-dependent-shared/eazel-services-header.c:
(eazel_services_header_initialize_class),
(eazel_services_header_initialize), (header_destroy),
(pixbuf_new_from_name), (label_new), (image_new),
(image_new_from_name), (eazel_services_header_new),
(eazel_services_header_set_text):
* components/services/nautilus-dependent-shared/eazel-services-header.h:
Two new widgets to deal with services views headers and footers.
* components/services/install/nautilus-view/nautilus-service-install-view.c:
(generate_install_form):
* components/services/login/nautilus-view/nautilus-change-password-view.c:
(generate_change_password_form):
* components/services/summary/nautilus-view/nautilus-summary-view.c:
(generate_summary_form):
Use the new footer and header widgets.
* components/services/nautilus-dependent-shared/shared-service-widgets.c:
* components/services/nautilus-dependent-shared/shared-service-widgets.h:
Retire some old code.
* components/services/nautilus-dependent-shared/test-footer-header.c:
(delete_event), (main):
Add a test for the new header and footer widgets.
Diffstat (limited to 'components/services/nautilus-dependent-shared')
10 files changed, 1045 insertions, 46 deletions
diff --git a/components/services/nautilus-dependent-shared/.cvsignore b/components/services/nautilus-dependent-shared/.cvsignore index 4b9aad494..d68a15a99 100644 --- a/components/services/nautilus-dependent-shared/.cvsignore +++ b/components/services/nautilus-dependent-shared/.cvsignore @@ -4,3 +4,4 @@ Makefile Makefile.in libnautilusdepshared.a +test-footer-header diff --git a/components/services/nautilus-dependent-shared/Makefile.am b/components/services/nautilus-dependent-shared/Makefile.am index f0b09d34f..1cb7fa8af 100644 --- a/components/services/nautilus-dependent-shared/Makefile.am +++ b/components/services/nautilus-dependent-shared/Makefile.am @@ -1,6 +1,6 @@ -NULL = +include $(top_srcdir)/Makefile.shared -SUBDIRS=icons +SUBDIRS = icons CPPFLAGS = \ -DPREFIX=\"$(prefix)\" \ @@ -21,13 +21,35 @@ INCLUDES = \ noinst_LIBRARIES = libnautilusdepshared.a -noinst_HEADERS = \ - shared-service-utilities.h \ - shared-service-widgets.h \ +noinst_HEADERS =\ + eazel-services-footer.h \ + eazel-services-header.h \ + shared-service-utilities.h \ + shared-service-widgets.h \ $(NULL) -libnautilusdepshared_a_SOURCES = \ - shared-service-utilities.c \ - shared-service-widgets.c \ +libnautilusdepshared_a_SOURCES =\ + eazel-services-footer.c \ + eazel-services-header.c \ + shared-service-utilities.c \ + shared-service-widgets.c \ $(NULL) +test_footer_header_LDADD = \ + $(top_builddir)/components/services/nautilus-dependent-shared/libnautilusdepshared.a \ + $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \ + $(top_builddir)/libnautilus/libnautilus.la \ + $(BONOBO_LIBS) \ + $(OAF_LIBS) \ + $(GCONF_LIBS) \ + $(GNOMEUI_LIBS) \ + $(VFS_LIBS) \ + $(XML_LIBS) \ + $(NULL) + +noinst_PROGRAMS =\ + test-footer-header \ + $(NULL) + +test_footer_header_SOURCES = test-footer-header.c + diff --git a/components/services/nautilus-dependent-shared/eazel-services-constants.h b/components/services/nautilus-dependent-shared/eazel-services-constants.h new file mode 100644 index 000000000..fd4c804c2 --- /dev/null +++ b/components/services/nautilus-dependent-shared/eazel-services-constants.h @@ -0,0 +1,52 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* eazel-services-constants.h - Constants used in services widgets. + + Copyright (C) 2000 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#ifndef EAZEL_SERVICES_CONSTANTS_H +#define EAZEL_SERVICES_CONSTANTS_H + +#define EAZEL_SERVICES_BACKGROUND_COLOR_STRING "white" +#define EAZEL_SERVICES_BACKGROUND_COLOR_RGBA NAUTILUS_RGB_COLOR_WHITE +#define EAZEL_SERVICES_DROP_SHADOW_COLOR_RGBA NAUTILUS_RGB_COLOR_BLACK +#define EAZEL_SERVICES_TEXT_COLOR_RGBA NAUTILUS_RGB_COLOR_WHITE + +#define EAZEL_SERVICES_LOGO_LEFT_SIDE_REPEAT_ICON "eazel-logo-left-side-repeat.png" +#define EAZEL_SERVICES_LOGO_RIGHT_SIDE_ICON "eazel-logo-right-side-logo.png" + +#define EAZEL_SERVICES_NORMAL_FILL "summary-service-normal-fill.png" +#define EAZEL_SERVICES_NORMAL_LEFT_BUMPER "summary-service-normal-left-bumper.png" +#define EAZEL_SERVICES_NORMAL_RIGHT_BUMPER "summary-service-normal-right-bumper.png" + +#define EAZEL_SERVICES_PRELIGHT_FILL "summary-service-prelight-fill.png" +#define EAZEL_SERVICES_PRELIGHT_LEFT_BUMPER "summary-service-prelight-left-bumper.png" +#define EAZEL_SERVICES_PRELIGHT_RIGHT_BUMPER "summary-service-prelight-right-bumper.png" + +#define EAZEL_SERVICES_REMAINDER_LEFT_BUMPER "summary-service-remainder-left-bumper.png" +#define EAZEL_SERVICES_REMAINDER_FILL "summary-service-remainder-fill.png" +#define EAZEL_SERVICES_REMAINDER_RIGHT_BUMPER "summary-service-remainder-right-bumper.png" + +END_GNOME_DECLS + +#endif /* EAZEL_SERVICES_CONSTANTS_H */ + + diff --git a/components/services/nautilus-dependent-shared/eazel-services-footer.c b/components/services/nautilus-dependent-shared/eazel-services-footer.c new file mode 100644 index 000000000..b11013693 --- /dev/null +++ b/components/services/nautilus-dependent-shared/eazel-services-footer.c @@ -0,0 +1,475 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* eazel-services-footer.c - A footer widget for services views. + + Copyright (C) 2000 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#include <config.h> +#include "eazel-services-footer.h" +#include "eazel-services-constants.h" + +#include <libnautilus-extensions/nautilus-file-utilities.h> +#include <libnautilus-extensions/nautilus-gdk-extensions.h> +#include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h> +#include <libnautilus-extensions/nautilus-glib-extensions.h> +#include <libnautilus-extensions/nautilus-gtk-extensions.h> +#include <libnautilus-extensions/nautilus-gtk-macros.h> +#include <libnautilus-extensions/nautilus-image.h> +#include <libnautilus-extensions/nautilus-label.h> +#include <libnautilus-extensions/nautilus-theme.h> + +#include <gtk/gtksignal.h> +#include <gtk/gtkeventbox.h> + +struct _EazelServicesFooterDetails +{ + GList *items; +}; + +/* GtkObjectClass methods */ +static void eazel_services_footer_initialize_class (EazelServicesFooterClass *klass); +static void eazel_services_footer_initialize (EazelServicesFooter *footer); +static void footer_destroy (GtkObject *object); + +NAUTILUS_DEFINE_CLASS_BOILERPLATE (EazelServicesFooter, eazel_services_footer, GTK_TYPE_HBOX) + +/* EazelServicesFooterClass methods */ +static void +eazel_services_footer_initialize_class (EazelServicesFooterClass *footer_class) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (footer_class); + + /* GtkObjectClass */ + object_class->destroy = footer_destroy; +} + +static void +eazel_services_footer_initialize (EazelServicesFooter *item) +{ + item->details = g_new0 (EazelServicesFooterDetails, 1); +} + +/* GtkObjectClass methods */ +static void +footer_destroy (GtkObject *object) +{ + EazelServicesFooter *footer; + + g_return_if_fail (EAZEL_SERVICES_IS_FOOTER (object)); + + footer = EAZEL_SERVICES_FOOTER (object); + + g_free (footer->details); + + /* Chain destroy */ + NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); +} + +/* Private stuff */ +static GdkPixbuf * +pixbuf_new_from_name (const char *name) +{ + char *path; + GdkPixbuf *pixbuf; + + g_return_val_if_fail (name != NULL, NULL); + + path = nautilus_theme_get_image_path (name); + + g_return_val_if_fail (path != NULL, NULL); + + pixbuf = gdk_pixbuf_new_from_file (path); + g_free (path); + + return pixbuf; +} + +static GtkWidget * +label_new (const char *text, + guint font_size, + guint drop_shadow_offset, + guint vertical_offset, + guint horizontal_offset, + gint xpadding, + gint ypadding, + guint32 background_color, + guint32 drop_shadow_color, + guint32 text_color, + const char *tile_name) +{ + GtkWidget *label; + + g_return_val_if_fail (text != NULL, NULL); + + label = nautilus_label_new (text); + nautilus_label_set_font_size (NAUTILUS_LABEL (label), font_size); + nautilus_label_set_drop_shadow_offset (NAUTILUS_LABEL (label), drop_shadow_offset); + nautilus_buffered_widget_set_background_type (NAUTILUS_BUFFERED_WIDGET (label), NAUTILUS_BACKGROUND_SOLID); + nautilus_buffered_widget_set_background_color (NAUTILUS_BUFFERED_WIDGET (label), background_color); + nautilus_label_set_drop_shadow_color (NAUTILUS_LABEL (label), drop_shadow_color); + nautilus_label_set_text_color (NAUTILUS_LABEL (label), background_color); + + nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (label), vertical_offset); + nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (label), horizontal_offset); + + gtk_misc_set_padding (GTK_MISC (label), xpadding, ypadding); + + if (tile_name != NULL) { + GdkPixbuf *tile_pixbuf; + + tile_pixbuf = pixbuf_new_from_name (tile_name); + + if (tile_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (label), tile_pixbuf); + } + + nautilus_gdk_pixbuf_unref_if_not_null (tile_pixbuf); + } + + return label; +} + +typedef struct +{ + GtkWidget *buffered_widget; + char *tile_name; + char *prelight_tile_name; + GdkPixbuf *tile_pixbuf; + GdkPixbuf *prelight_tile_pixbuf; +} PrelightLabelData; + +static gint +label_enter_event (GtkWidget *event_box, + GdkEventCrossing *event, + gpointer client_data) +{ + PrelightLabelData *data; + + g_return_val_if_fail (GTK_IS_EVENT_BOX (event_box), TRUE); + g_return_val_if_fail (client_data != NULL, TRUE); + + data = (PrelightLabelData *) client_data; + + g_return_val_if_fail (data->prelight_tile_name, TRUE); + g_return_val_if_fail (NAUTILUS_IS_BUFFERED_WIDGET (data->buffered_widget), TRUE); + + //g_print ("%s(%p)\n", __FUNCTION__, data); + + if (data->prelight_tile_pixbuf == NULL) { + data->prelight_tile_pixbuf = pixbuf_new_from_name (data->prelight_tile_name); + } + + if (data->prelight_tile_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (data->buffered_widget), + data->prelight_tile_pixbuf); + } + + return TRUE; +} + +static gint +label_leave_event (GtkWidget *event_box, + GdkEventCrossing *event, + gpointer client_data) +{ + PrelightLabelData *data; + + g_return_val_if_fail (GTK_IS_EVENT_BOX (event_box), TRUE); + g_return_val_if_fail (client_data != NULL, TRUE); + + data = (PrelightLabelData *) client_data; + + g_return_val_if_fail (data->tile_name, TRUE); + g_return_val_if_fail (NAUTILUS_IS_BUFFERED_WIDGET (data->buffered_widget), TRUE); + + if (data->tile_pixbuf == NULL) { + data->tile_pixbuf = pixbuf_new_from_name (data->tile_name); + } + + if (data->tile_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (data->buffered_widget), + data->tile_pixbuf); + } + + return TRUE; +} + +static gint +label_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer client_data) +{ + const char *uri; + + g_return_val_if_fail (GTK_IS_EVENT_BOX (widget), TRUE); + g_return_val_if_fail (client_data != NULL, TRUE); + + uri = (const char *) client_data; + + g_print ("%s(%s)\n", __FUNCTION__, uri); + + return TRUE; +} + +static void +label_free_data (GtkWidget *event_box, + gpointer client_data) +{ + PrelightLabelData *data; + + g_return_if_fail (GTK_IS_EVENT_BOX (event_box)); + g_return_if_fail (client_data != NULL); + + data = (PrelightLabelData *) client_data; + + g_free (data->tile_name); + g_free (data->prelight_tile_name); + nautilus_gdk_pixbuf_unref_if_not_null (data->tile_pixbuf); + nautilus_gdk_pixbuf_unref_if_not_null (data->prelight_tile_pixbuf); + g_free (data); +} + +static void +label_free_uri (GtkWidget *event_box, + gpointer client_data) +{ + g_return_if_fail (GTK_IS_EVENT_BOX (event_box)); + g_return_if_fail (client_data != NULL); + + g_free (client_data); +} + +static GtkWidget * +image_new (GdkPixbuf *pixbuf, GdkPixbuf *tile_pixbuf, guint32 background_color) +{ + GtkWidget *image; + + g_return_val_if_fail (pixbuf || tile_pixbuf, NULL); + + image = nautilus_image_new (); + + nautilus_buffered_widget_set_background_type (NAUTILUS_BUFFERED_WIDGET (image), NAUTILUS_BACKGROUND_SOLID); + nautilus_buffered_widget_set_background_color (NAUTILUS_BUFFERED_WIDGET (image), background_color); + + if (pixbuf != NULL) { + nautilus_image_set_pixbuf (NAUTILUS_IMAGE (image), pixbuf); + } + + if (tile_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (image), tile_pixbuf); + } + + return image; +} + +static GtkWidget * +image_new_from_name (const char *icon_name, const char *tile_name, guint32 background_color) +{ + GtkWidget *image; + GdkPixbuf *pixbuf = NULL; + GdkPixbuf *tile_pixbuf = NULL; + + g_return_val_if_fail (icon_name || tile_name, NULL); + + if (icon_name) { + pixbuf = pixbuf_new_from_name (icon_name); + } + + if (tile_name) { + tile_pixbuf = pixbuf_new_from_name (tile_name); + } + + g_return_val_if_fail (pixbuf || tile_pixbuf, NULL); + + image = image_new (pixbuf, tile_pixbuf, background_color); + + nautilus_gdk_pixbuf_unref_if_not_null (pixbuf); + nautilus_gdk_pixbuf_unref_if_not_null (tile_pixbuf); + + return image; +} + +static void +buffered_widget_add_prelighting (GtkWidget *buffered_widget, + GtkWidget *event_box, + const char *tile_name, + const char *prelight_tile_name) +{ + PrelightLabelData *data; + + g_return_if_fail (NAUTILUS_IS_BUFFERED_WIDGET (buffered_widget)); + g_return_if_fail (GTK_IS_EVENT_BOX (event_box)); + g_return_if_fail (tile_name != NULL); + g_return_if_fail (prelight_tile_name != NULL); + + data = g_new0 (PrelightLabelData, 1); + + data->buffered_widget = buffered_widget; + data->tile_name = g_strdup (tile_name); + data->prelight_tile_name = g_strdup (prelight_tile_name); + + gtk_signal_connect (GTK_OBJECT (event_box), "enter_notify_event", GTK_SIGNAL_FUNC (label_enter_event), data); + gtk_signal_connect (GTK_OBJECT (event_box), "leave_notify_event", GTK_SIGNAL_FUNC (label_leave_event), data); + gtk_signal_connect (GTK_OBJECT (event_box), "destroy", GTK_SIGNAL_FUNC (label_free_data), data); +} + +static GtkWidget * +footer_item_new (const char *text, const char *uri, gboolean has_left_bumper, gboolean has_right_bumper) +{ + GtkWidget *hbox; + GtkWidget *event_box; + GtkWidget *label; + char *uri_copy; + + g_return_val_if_fail (text != NULL, NULL); + g_return_val_if_fail (text[0] != '\0', NULL); + + g_return_val_if_fail (uri != NULL, NULL); + g_return_val_if_fail (uri[0] != '\0', NULL); + + event_box = gtk_event_box_new (); + hbox = gtk_hbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (event_box), hbox); + + if (has_left_bumper) { + GtkWidget *left; + left = image_new_from_name (EAZEL_SERVICES_NORMAL_LEFT_BUMPER, EAZEL_SERVICES_NORMAL_FILL, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + buffered_widget_add_prelighting (left, event_box, EAZEL_SERVICES_NORMAL_FILL, EAZEL_SERVICES_PRELIGHT_FILL); + gtk_box_pack_start (GTK_BOX (hbox), left, FALSE, FALSE, 0); + gtk_widget_show (left); + } + + label = label_new (text, + 13, + 1, + 2, + 0, + 5, + 0, + EAZEL_SERVICES_BACKGROUND_COLOR_RGBA, + EAZEL_SERVICES_DROP_SHADOW_COLOR_RGBA, + EAZEL_SERVICES_TEXT_COLOR_RGBA, + EAZEL_SERVICES_NORMAL_FILL); + + gtk_widget_show (label); + + uri_copy = g_strdup (uri); + + gtk_signal_connect (GTK_OBJECT (event_box), "button_press_event", GTK_SIGNAL_FUNC (label_button_press_event), uri_copy); + gtk_signal_connect (GTK_OBJECT (event_box), "destroy", GTK_SIGNAL_FUNC (label_free_uri), uri_copy); + + buffered_widget_add_prelighting (label, event_box, EAZEL_SERVICES_NORMAL_FILL, EAZEL_SERVICES_PRELIGHT_FILL); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + if (has_right_bumper) { + GtkWidget *right; + right = image_new_from_name (EAZEL_SERVICES_NORMAL_RIGHT_BUMPER, EAZEL_SERVICES_NORMAL_FILL, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + buffered_widget_add_prelighting (right, event_box, EAZEL_SERVICES_NORMAL_FILL, EAZEL_SERVICES_PRELIGHT_FILL); + gtk_box_pack_start (GTK_BOX (hbox), right, FALSE, FALSE, 0); + gtk_widget_show (right); + } + + gtk_widget_show (hbox); + + return event_box; +} + +static GtkWidget * +footer_remainder_new (void) +{ + GtkWidget *hbox; + GtkWidget *left; + GtkWidget *fill; + GtkWidget *right; + + hbox = gtk_hbox_new (FALSE, 0); + + left = image_new_from_name (EAZEL_SERVICES_REMAINDER_LEFT_BUMPER, NULL, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + fill = image_new_from_name (NULL, EAZEL_SERVICES_REMAINDER_FILL, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + right = image_new_from_name (EAZEL_SERVICES_REMAINDER_RIGHT_BUMPER, NULL, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + + gtk_box_pack_start (GTK_BOX (hbox), left, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), fill, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), right, FALSE, FALSE, 0); + + gtk_widget_show (left); + gtk_widget_show (fill); + gtk_widget_show (right); + + return hbox; +} + +/* EazelServicesFooter public methods */ +GtkWidget * +eazel_services_footer_new (void) +{ + EazelServicesFooter *footer; + + footer = EAZEL_SERVICES_FOOTER (gtk_widget_new (eazel_services_footer_get_type (), NULL)); + + return GTK_WIDGET (footer); +} + +void +eazel_services_footer_update (EazelServicesFooter *footer, + const char *items[], + const char *uris[], + guint num_items) +{ + GtkWidget *remainder; + GtkWidget *date; + guint i; + + g_return_if_fail (EAZEL_SERVICES_IS_FOOTER (footer)); + g_return_if_fail (items != NULL); + g_return_if_fail (uris != NULL); + g_return_if_fail (num_items > 0); + + for (i = 0; i < num_items; i++) { + GtkWidget *item; + + item = footer_item_new (items[i], uris[i], i > 0, i < (num_items - 1)); + gtk_box_pack_start (GTK_BOX (footer), item, FALSE, FALSE, 0); + gtk_widget_show (item); + } + + remainder = footer_remainder_new (); + gtk_box_pack_start (GTK_BOX (footer), remainder, TRUE, TRUE, 0); + + date = label_new ("Friday, October 13th", + 13, + 1, + 2, + 0, + 8, + 0, + EAZEL_SERVICES_BACKGROUND_COLOR_RGBA, + EAZEL_SERVICES_DROP_SHADOW_COLOR_RGBA, + EAZEL_SERVICES_TEXT_COLOR_RGBA, + EAZEL_SERVICES_NORMAL_FILL); + + gtk_widget_show (remainder); + gtk_widget_show (date); + + gtk_box_pack_start (GTK_BOX (footer), date, FALSE, FALSE, 0); +} diff --git a/components/services/nautilus-dependent-shared/eazel-services-footer.h b/components/services/nautilus-dependent-shared/eazel-services-footer.h new file mode 100644 index 000000000..79f574445 --- /dev/null +++ b/components/services/nautilus-dependent-shared/eazel-services-footer.h @@ -0,0 +1,69 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* eazel-services-footer.h - A footer widget for services views. + + Copyright (C) 2000 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#ifndef EAZEL_SERVICES_FOOTER_H +#define EAZEL_SERVICES_FOOTER_H + +#include <gtk/gtkhbox.h> +#include <libgnome/gnome-defs.h> + +BEGIN_GNOME_DECLS + +#define EAZEL_SERVICES_TYPE_FOOTER (eazel_services_footer_get_type ()) +#define EAZEL_SERVICES_FOOTER(obj) (GTK_CHECK_CAST ((obj), EAZEL_SERVICES_TYPE_FOOTER, EazelServicesFooter)) +#define EAZEL_SERVICES_FOOTER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EAZEL_SERVICES_TYPE_FOOTER, EazelServicesFooterClass)) +#define EAZEL_SERVICES_IS_FOOTER(obj) (GTK_CHECK_TYPE ((obj), EAZEL_SERVICES_TYPE_FOOTER)) +#define EAZEL_SERVICES_IS_FOOTER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), EAZEL_SERVICES_TYPE_FOOTER)) + +typedef struct _EazelServicesFooter EazelServicesFooter; +typedef struct _EazelServicesFooterClass EazelServicesFooterClass; +typedef struct _EazelServicesFooterDetails EazelServicesFooterDetails; + +struct _EazelServicesFooter +{ + /* Super Class */ + GtkHBox hbox; + + /* Private stuff */ + EazelServicesFooterDetails *details; +}; + +struct _EazelServicesFooterClass +{ + /* Super Class */ + GtkHBoxClass hbox_class; +}; + +GtkType eazel_services_footer_get_type (void); +GtkWidget* eazel_services_footer_new (void); +void eazel_services_footer_update (EazelServicesFooter *footer, + const char *items[], + const char *uris[], + guint num_items); + +END_GNOME_DECLS + +#endif /* EAZEL_SERVICES_FOOTER_H */ + + diff --git a/components/services/nautilus-dependent-shared/eazel-services-header.c b/components/services/nautilus-dependent-shared/eazel-services-header.c new file mode 100644 index 000000000..d60622629 --- /dev/null +++ b/components/services/nautilus-dependent-shared/eazel-services-header.c @@ -0,0 +1,247 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* eazel-services-header.c - A header widget for services views. + + Copyright (C) 2000 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#include <config.h> +#include "eazel-services-header.h" +#include "eazel-services-constants.h" + +#include <libnautilus-extensions/nautilus-file-utilities.h> +#include <libnautilus-extensions/nautilus-gdk-extensions.h> +#include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h> +#include <libnautilus-extensions/nautilus-glib-extensions.h> +#include <libnautilus-extensions/nautilus-gtk-extensions.h> +#include <libnautilus-extensions/nautilus-gtk-macros.h> +#include <libnautilus-extensions/nautilus-image.h> +#include <libnautilus-extensions/nautilus-label.h> +#include <libnautilus-extensions/nautilus-theme.h> + +#include <gtk/gtksignal.h> +#include <gtk/gtkeventbox.h> + +struct _EazelServicesHeaderDetails +{ + GtkWidget *text; +}; + +/* GtkObjectClass methods */ +static void eazel_services_header_initialize_class (EazelServicesHeaderClass *klass); +static void eazel_services_header_initialize (EazelServicesHeader *header); +static void header_destroy (GtkObject *object); + +NAUTILUS_DEFINE_CLASS_BOILERPLATE (EazelServicesHeader, eazel_services_header, GTK_TYPE_HBOX) + +/* EazelServicesHeaderClass methods */ +static void +eazel_services_header_initialize_class (EazelServicesHeaderClass *header_class) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (header_class); + + /* GtkObjectClass */ + object_class->destroy = header_destroy; +} + +static void +eazel_services_header_initialize (EazelServicesHeader *item) +{ + item->details = g_new0 (EazelServicesHeaderDetails, 1); +} + +/* GtkObjectClass methods */ +static void +header_destroy (GtkObject *object) +{ + EazelServicesHeader *header; + + g_return_if_fail (EAZEL_SERVICES_IS_HEADER (object)); + + header = EAZEL_SERVICES_HEADER (object); + + g_free (header->details); + + /* Chain destroy */ + NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); +} + +/* Private stuff */ +static GdkPixbuf * +pixbuf_new_from_name (const char *name) +{ + char *path; + GdkPixbuf *pixbuf; + + g_return_val_if_fail (name != NULL, NULL); + + path = nautilus_theme_get_image_path (name); + + g_return_val_if_fail (path != NULL, NULL); + + pixbuf = gdk_pixbuf_new_from_file (path); + g_free (path); + + return pixbuf; +} + +static GtkWidget * +label_new (const char *text, + guint font_size, + guint drop_shadow_offset, + guint vertical_offset, + guint horizontal_offset, + gint xpadding, + gint ypadding, + guint32 background_color, + guint32 drop_shadow_color, + guint32 text_color, + const char *tile_name) +{ + GtkWidget *label; + + g_return_val_if_fail (text != NULL, NULL); + + label = nautilus_label_new (text); + nautilus_label_set_font_size (NAUTILUS_LABEL (label), font_size); + nautilus_label_set_drop_shadow_offset (NAUTILUS_LABEL (label), drop_shadow_offset); + nautilus_buffered_widget_set_background_type (NAUTILUS_BUFFERED_WIDGET (label), NAUTILUS_BACKGROUND_SOLID); + nautilus_buffered_widget_set_background_color (NAUTILUS_BUFFERED_WIDGET (label), background_color); + nautilus_label_set_drop_shadow_color (NAUTILUS_LABEL (label), drop_shadow_color); + nautilus_label_set_text_color (NAUTILUS_LABEL (label), background_color); + + nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (label), vertical_offset); + nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (label), horizontal_offset); + + gtk_misc_set_padding (GTK_MISC (label), xpadding, ypadding); + + if (tile_name != NULL) { + GdkPixbuf *tile_pixbuf; + + tile_pixbuf = pixbuf_new_from_name (tile_name); + + if (tile_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (label), tile_pixbuf); + } + + nautilus_gdk_pixbuf_unref_if_not_null (tile_pixbuf); + } + + return label; +} + +static GtkWidget * +image_new (GdkPixbuf *pixbuf, GdkPixbuf *tile_pixbuf, guint32 background_color) +{ + GtkWidget *image; + + g_return_val_if_fail (pixbuf || tile_pixbuf, NULL); + + image = nautilus_image_new (); + + nautilus_buffered_widget_set_background_type (NAUTILUS_BUFFERED_WIDGET (image), NAUTILUS_BACKGROUND_SOLID); + nautilus_buffered_widget_set_background_color (NAUTILUS_BUFFERED_WIDGET (image), background_color); + + if (pixbuf != NULL) { + nautilus_image_set_pixbuf (NAUTILUS_IMAGE (image), pixbuf); + } + + if (tile_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (image), tile_pixbuf); + } + + return image; +} + +static GtkWidget * +image_new_from_name (const char *icon_name, const char *tile_name, guint32 background_color) +{ + GtkWidget *image; + GdkPixbuf *pixbuf = NULL; + GdkPixbuf *tile_pixbuf = NULL; + + g_return_val_if_fail (icon_name || tile_name, NULL); + + if (icon_name) { + pixbuf = pixbuf_new_from_name (icon_name); + } + + if (tile_name) { + tile_pixbuf = pixbuf_new_from_name (tile_name); + } + + g_return_val_if_fail (pixbuf || tile_pixbuf, NULL); + + image = image_new (pixbuf, tile_pixbuf, background_color); + + nautilus_gdk_pixbuf_unref_if_not_null (pixbuf); + nautilus_gdk_pixbuf_unref_if_not_null (tile_pixbuf); + + return image; +} + +/* EazelServicesHeader public methods */ +GtkWidget * +eazel_services_header_new (const char *text) +{ + EazelServicesHeader *header; + GtkWidget *middle; + GtkWidget *logo; + + header = EAZEL_SERVICES_HEADER (gtk_widget_new (eazel_services_header_get_type (), NULL)); + + header->details->text = label_new (text ? text : "foo", + 18, + 1, + 4, + 0, + 10, + 0, + EAZEL_SERVICES_BACKGROUND_COLOR_RGBA, + EAZEL_SERVICES_DROP_SHADOW_COLOR_RGBA, + EAZEL_SERVICES_TEXT_COLOR_RGBA, + EAZEL_SERVICES_LOGO_LEFT_SIDE_REPEAT_ICON); + + middle = image_new_from_name (NULL, EAZEL_SERVICES_LOGO_LEFT_SIDE_REPEAT_ICON, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + + logo = image_new_from_name (EAZEL_SERVICES_LOGO_RIGHT_SIDE_ICON, NULL, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + + gtk_box_pack_start (GTK_BOX (header), header->details->text, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (header), middle, TRUE, TRUE, 0); + gtk_box_pack_end (GTK_BOX (header), logo, FALSE, FALSE, 0); + + gtk_widget_show (header->details->text); + gtk_widget_show (middle); + gtk_widget_show (logo); + + return GTK_WIDGET (header); +} + +void +eazel_services_header_set_text (EazelServicesHeader *header, + const char *text) +{ + g_return_if_fail (EAZEL_SERVICES_IS_HEADER (header)); + g_return_if_fail (text != NULL); + + nautilus_label_set_text (NAUTILUS_LABEL (header->details->text), text); +} diff --git a/components/services/nautilus-dependent-shared/eazel-services-header.h b/components/services/nautilus-dependent-shared/eazel-services-header.h new file mode 100644 index 000000000..ed90dea9e --- /dev/null +++ b/components/services/nautilus-dependent-shared/eazel-services-header.h @@ -0,0 +1,67 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* eazel-services-header.h - A header widget for services views. + + Copyright (C) 2000 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#ifndef EAZEL_SERVICES_HEADER_H +#define EAZEL_SERVICES_HEADER_H + +#include <gtk/gtkhbox.h> +#include <libgnome/gnome-defs.h> + +BEGIN_GNOME_DECLS + +#define EAZEL_SERVICES_TYPE_HEADER (eazel_services_header_get_type ()) +#define EAZEL_SERVICES_HEADER(obj) (GTK_CHECK_CAST ((obj), EAZEL_SERVICES_TYPE_HEADER, EazelServicesHeader)) +#define EAZEL_SERVICES_HEADER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EAZEL_SERVICES_TYPE_HEADER, EazelServicesHeaderClass)) +#define EAZEL_SERVICES_IS_HEADER(obj) (GTK_CHECK_TYPE ((obj), EAZEL_SERVICES_TYPE_HEADER)) +#define EAZEL_SERVICES_IS_HEADER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), EAZEL_SERVICES_TYPE_HEADER)) + +typedef struct _EazelServicesHeader EazelServicesHeader; +typedef struct _EazelServicesHeaderClass EazelServicesHeaderClass; +typedef struct _EazelServicesHeaderDetails EazelServicesHeaderDetails; + +struct _EazelServicesHeader +{ + /* Super Class */ + GtkHBox hbox; + + /* Private stuff */ + EazelServicesHeaderDetails *details; +}; + +struct _EazelServicesHeaderClass +{ + /* Super Class */ + GtkHBoxClass hbox_class; +}; + +GtkType eazel_services_header_get_type (void); +GtkWidget* eazel_services_header_new (const char *text); +void eazel_services_header_set_text (EazelServicesHeader *header, + const char *text); + +END_GNOME_DECLS + +#endif /* EAZEL_SERVICES_HEADER_H */ + + diff --git a/components/services/nautilus-dependent-shared/shared-service-widgets.c b/components/services/nautilus-dependent-shared/shared-service-widgets.c index 4c263fe9e..acb51d3e1 100644 --- a/components/services/nautilus-dependent-shared/shared-service-widgets.c +++ b/components/services/nautilus-dependent-shared/shared-service-widgets.c @@ -195,44 +195,7 @@ create_label_widget (const char *text, return label; } -/* utility routine to create the standard services title bar */ - -GtkWidget* -create_services_title_widget (const char *title_text) -{ - GtkWidget *title_hbox; - GtkWidget *logo_image; - GtkWidget *filler_image; - GtkWidget *label; - - g_return_val_if_fail (title_text != NULL, NULL); - - title_hbox = gtk_hbox_new (FALSE, 0); - - logo_image = create_image_widget ("eazel-services-logo.png", NULL); - - filler_image = create_image_widget (NULL, "eazel-services-logo-tile.png"); - - label = create_label_widget (title_text, 20, "eazel-services-logo-tile.png", 10, 0, 0, -4); - - nautilus_label_set_font_from_components (NAUTILUS_LABEL (label), "helvetica", "bold", NULL, NULL); - nautilus_label_set_font_size (NAUTILUS_LABEL (label), 18); - nautilus_label_set_text_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_WHITE); - - gtk_widget_show (logo_image); - gtk_widget_show (filler_image); - gtk_widget_show (label); - - gtk_box_pack_start (GTK_BOX (title_hbox), logo_image, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (title_hbox), filler_image, TRUE, TRUE, 0); - gtk_box_pack_end (GTK_BOX (title_hbox), label, FALSE, FALSE, 0); - - return title_hbox; - -} - /* utility routine to create the top half of the summary title */ - GtkWidget* create_summary_service_title_top_widget (const char *login_status_text) { diff --git a/components/services/nautilus-dependent-shared/shared-service-widgets.h b/components/services/nautilus-dependent-shared/shared-service-widgets.h index 58aa1da6e..c80a24dd3 100644 --- a/components/services/nautilus-dependent-shared/shared-service-widgets.h +++ b/components/services/nautilus-dependent-shared/shared-service-widgets.h @@ -46,7 +46,6 @@ GtkWidget* create_label_widget (const char *text, guint ypad, gint horizontal_offset, gint vertical_offset); -GtkWidget* create_services_title_widget (const char *title_text); GtkWidget* create_summary_service_title_top_widget (const char *login_status_text); GtkWidget* create_summary_service_title_bottom_widget (const char *section_title); GtkWidget* create_services_header_widget (const char *left_text, diff --git a/components/services/nautilus-dependent-shared/test-footer-header.c b/components/services/nautilus-dependent-shared/test-footer-header.c new file mode 100644 index 000000000..cdf3acada --- /dev/null +++ b/components/services/nautilus-dependent-shared/test-footer-header.c @@ -0,0 +1,104 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* test-footer-header.c - Test for footer/header widgetry. + + Copyright (C) 2000 Eazel, Inc. + + The Gnome Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The Gnome Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the Gnome Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Authors: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#include <config.h> + +#include <gtk/gtk.h> +#include <libnautilus-extensions/nautilus-gtk-extensions.h> +#include <libnautilus-extensions/nautilus-glib-extensions.h> + +/* #include <libnautilus-extensions/nautilus-gdk-extensions.h> */ +/* #include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h> */ +/* #include <libnautilus-extensions/nautilus-image.h> */ +/* #include <libnautilus-extensions/nautilus-label.h> */ +/* #include <libnautilus-extensions/nautilus-theme.h> */ + +#include "eazel-services-footer.h" +#include "eazel-services-header.h" +#include "eazel-services-constants.h" + +static void +delete_event (GtkWidget *widget, GdkEvent *event, gpointer callback_data) +{ + gtk_main_quit (); +} + +static const char *footer_items[] = +{ + "Register", + "Login", + "Terms of Use", + "Privacy Statement" +}; + +static const char *footer_uris[] = +{ + "eazel:register", + "eazel:login", + "eazel:terms", + "eazel:privacy" +}; + +int +main (int argc, char* argv[]) +{ + GtkWidget *window; + GtkWidget *vbox; + GtkWidget *header; + GtkWidget *footer; + GtkWidget *content; + + gtk_init (&argc, &argv); + gdk_rgb_init (); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + nautilus_gtk_widget_set_background_color (window, EAZEL_SERVICES_BACKGROUND_COLOR_STRING); + gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); + gtk_window_set_title (GTK_WINDOW (window), "Nautilus Wrapped Label Test"); + gtk_window_set_policy (GTK_WINDOW (window), TRUE, TRUE, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (window), 10); + gtk_widget_set_usize (window, 640, 480); + + vbox = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (window), vbox); + + header = eazel_services_header_new ("Welcome back, Arlo!"); + content = gtk_vbox_new (FALSE, 0); + + footer = eazel_services_footer_new (); + eazel_services_footer_update (EAZEL_SERVICES_FOOTER (footer), + footer_items, + footer_uris, + NAUTILUS_N_ELEMENTS (footer_items)); + + gtk_box_pack_start (GTK_BOX (vbox), header, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), content, TRUE, TRUE, 0); + gtk_box_pack_end (GTK_BOX (vbox), footer, FALSE, FALSE, 0); + + gtk_widget_show_all (window); + + gtk_main (); + + return 0; +} |