diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-10-25 15:39:39 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-10-25 15:39:39 +0000 |
commit | e2312c84db078a93e15aa72df91971e50bdaea4b (patch) | |
tree | ba5bc276dd83b014660a65365f8b78a4e10de5e3 | |
parent | 9d7b99e6f6bb593999fedd41d136e7f69a62131a (diff) | |
download | nautilus-e2312c84db078a93e15aa72df91971e50bdaea4b.tar.gz |
Removed. It was a bad try. Stuff is now in eazel-services-extensions.h.
* components/services/nautilus-dependent-shared/eazel-services-constants.h:
Removed. It was a bad try. Stuff is now in eazel-services-extensions.h.
* components/services/nautilus-dependent-shared/Makefile.am:
* components/services/nautilus-dependent-shared/eazel-services-extensions.c:
(pixbuf_new_from_name), (eazel_services_image_new),
(eazel_services_label_new):
* components/services/nautilus-dependent-shared/eazel-services-extensions.h:
Add a place to put shared services extensions.
* components/services/nautilus-dependent-shared/eazel-services-footer.c:
(footer_item_new), (footer_remainder_new),
(eazel_services_footer_update):
* components/services/nautilus-dependent-shared/eazel-services-header.c:
(eazel_services_header_new):
* components/services/nautilus-dependent-shared/test-footer-header.c:
Remove a bunch of duplicated code and put it in a shared
extensions location. Make the footer real. Add an item_clicked
signal to the footer.
* components/services/summary/nautilus-view/nautilus-summary-view.c:
Hook up the footer for item clicks.
* libnautilus-extensions/nautilus-image.c:
(nautilus_image_new_loaded):
* libnautilus-extensions/nautilus-image.h:
* libnautilus-extensions/nautilus-label.c:
(nautilus_label_new_loaded):
* libnautilus-extensions/nautilus-label.h:
Add constructors that take a bunch of arguments for the various
widgets attributes. Makes the widgets easier to use for callers
that need to tweak many attributes (like eazel services).
18 files changed, 822 insertions, 486 deletions
@@ -1,5 +1,40 @@ 2000-10-25 Ramiro Estrugo <ramiro@eazel.com> + * components/services/nautilus-dependent-shared/eazel-services-constants.h: + Removed. It was a bad try. Stuff is now in eazel-services-extensions.h. + + * components/services/nautilus-dependent-shared/Makefile.am: + * components/services/nautilus-dependent-shared/eazel-services-extensions.c: + (pixbuf_new_from_name), (eazel_services_image_new), + (eazel_services_label_new): + * components/services/nautilus-dependent-shared/eazel-services-extensions.h: + Add a place to put shared services extensions. + + * components/services/nautilus-dependent-shared/eazel-services-footer.c: + (footer_item_new), (footer_remainder_new), + (eazel_services_footer_update): + * components/services/nautilus-dependent-shared/eazel-services-header.c: + (eazel_services_header_new): + * components/services/nautilus-dependent-shared/test-footer-header.c: + Remove a bunch of duplicated code and put it in a shared + extensions location. Make the footer real. Add an item_clicked + signal to the footer. + + * components/services/summary/nautilus-view/nautilus-summary-view.c: + Hook up the footer for item clicks. + + * libnautilus-extensions/nautilus-image.c: + (nautilus_image_new_loaded): + * libnautilus-extensions/nautilus-image.h: + * libnautilus-extensions/nautilus-label.c: + (nautilus_label_new_loaded): + * libnautilus-extensions/nautilus-label.h: + Add constructors that take a bunch of arguments for the various + widgets attributes. Makes the widgets easier to use for callers + that need to tweak many attributes (like eazel services). + +2000-10-25 Ramiro Estrugo <ramiro@eazel.com> + * components/services/nautilus-dependent-shared/.cvsignore: * components/services/nautilus-dependent-shared/Makefile.am: * components/services/nautilus-dependent-shared/eazel-services-constants.h: diff --git a/components/services/nautilus-dependent-shared/Makefile.am b/components/services/nautilus-dependent-shared/Makefile.am index 1cb7fa8af..cf2155491 100644 --- a/components/services/nautilus-dependent-shared/Makefile.am +++ b/components/services/nautilus-dependent-shared/Makefile.am @@ -10,6 +10,7 @@ CPPFLAGS = \ INCLUDES = \ -I$(top_srcdir) \ -I$(top_builddir) \ + -I$(top_srcdir)/components/services/nautilus-dependent-shared \ -I$(top_srcdir)/components/services/trilobite \ -I$(top_builddir)/components/services/trilobite \ -I$(top_srcdir)/components/services/trilobite/lib \ @@ -22,6 +23,7 @@ INCLUDES = \ noinst_LIBRARIES = libnautilusdepshared.a noinst_HEADERS =\ + eazel-services-extensions.h \ eazel-services-footer.h \ eazel-services-header.h \ shared-service-utilities.h \ @@ -29,6 +31,7 @@ noinst_HEADERS =\ $(NULL) libnautilusdepshared_a_SOURCES =\ + eazel-services-extensions.c \ eazel-services-footer.c \ eazel-services-header.c \ shared-service-utilities.c \ diff --git a/components/services/nautilus-dependent-shared/eazel-services-extensions.c b/components/services/nautilus-dependent-shared/eazel-services-extensions.c new file mode 100644 index 000000000..2d54a5df7 --- /dev/null +++ b/components/services/nautilus-dependent-shared/eazel-services-extensions.c @@ -0,0 +1,133 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* eazel-services-extensions.c - Extensions to Nautilus and gtk widget. + + 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-extensions.h" + +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> + +#include <libnautilus-extensions/nautilus-image.h> +#include <libnautilus-extensions/nautilus-label.h> +#include <libnautilus-extensions/nautilus-theme.h> + +#include <time.h> + +GdkPixbuf * +eazel_services_pixbuf_new (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; +} + +GtkWidget * +eazel_services_image_new (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 = eazel_services_pixbuf_new (icon_name); + } + + if (tile_name) { + tile_pixbuf = eazel_services_pixbuf_new (tile_name); + } + + g_return_val_if_fail (pixbuf || tile_pixbuf, NULL); + + image = nautilus_image_new_loaded (pixbuf, 0, 0, 0, 0, background_color, tile_pixbuf); + + nautilus_gdk_pixbuf_unref_if_not_null (pixbuf); + nautilus_gdk_pixbuf_unref_if_not_null (tile_pixbuf); + + return image; +} + +GtkWidget * +eazel_services_label_new (const char *text, + gboolean bold, + guint font_size, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + const char *tile_name) +{ + GtkWidget *label; + GdkPixbuf *text_tile; + + text_tile = eazel_services_pixbuf_new (tile_name); + + label = nautilus_label_new_loaded (text, + EAZEL_SERVICES_FONT_FAMILY, + bold ? "bold" : NULL, + font_size, + 1, /* drop_shadow_offset */ + EAZEL_SERVICES_DROP_SHADOW_COLOR_RGBA, + EAZEL_SERVICES_TEXT_COLOR_RGBA, + xpadding, + ypadding, + vertical_offset, + horizontal_offset, + EAZEL_SERVICES_BACKGROUND_COLOR_RGBA, + text_tile); + + nautilus_gdk_pixbuf_unref_if_not_null (text_tile); + + return label; +} + +char * +eazel_services_get_current_date_string (void) +{ + time_t my_time; + struct tm *my_localtime; + + my_time = time (NULL); + + if (my_time == -1) { + return g_strdup (_("Unknown Date")); + } + + my_localtime = localtime (&my_time); + + return nautilus_strdup_strftime (_("%A, %B %e"), my_localtime); +} diff --git a/components/services/nautilus-dependent-shared/eazel-services-constants.h b/components/services/nautilus-dependent-shared/eazel-services-extensions.h index fd4c804c2..e5cd1e0c1 100644 --- a/components/services/nautilus-dependent-shared/eazel-services-constants.h +++ b/components/services/nautilus-dependent-shared/eazel-services-extensions.h @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* eazel-services-constants.h - Constants used in services widgets. +/* eazel-services-extensions.h - Extensions to Nautilus and gtk widget. Copyright (C) 2000 Eazel, Inc. @@ -22,8 +22,14 @@ Authors: Ramiro Estrugo <ramiro@eazel.com> */ -#ifndef EAZEL_SERVICES_CONSTANTS_H -#define EAZEL_SERVICES_CONSTANTS_H +#ifndef EAZEL_SERVICES_EXTENSIONS_H +#define EAZEL_SERVICES_EXTENSIONS_H + +#include <libgnome/gnome-defs.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> #define EAZEL_SERVICES_BACKGROUND_COLOR_STRING "white" #define EAZEL_SERVICES_BACKGROUND_COLOR_RGBA NAUTILUS_RGB_COLOR_WHITE @@ -45,8 +51,27 @@ #define EAZEL_SERVICES_REMAINDER_FILL "summary-service-remainder-fill.png" #define EAZEL_SERVICES_REMAINDER_RIGHT_BUMPER "summary-service-remainder-right-bumper.png" +#define EAZEL_SERVICES_FONT_FAMILY "helvetica" + +BEGIN_GNOME_DECLS + +GdkPixbuf *eazel_services_pixbuf_new (const char *name); +GtkWidget *eazel_services_image_new (const char *icon_name, + const char *tile_name, + guint32 background_color); +GtkWidget *eazel_services_label_new (const char *text, + gboolean bold, + guint font_size, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + const char *tile_name); +char * eazel_services_get_current_date_string (void); + END_GNOME_DECLS -#endif /* EAZEL_SERVICES_CONSTANTS_H */ +#endif /* EAZEL_SERVICES_EXTENSIONS_H */ diff --git a/components/services/nautilus-dependent-shared/eazel-services-footer.c b/components/services/nautilus-dependent-shared/eazel-services-footer.c index b11013693..0507f925d 100644 --- a/components/services/nautilus-dependent-shared/eazel-services-footer.c +++ b/components/services/nautilus-dependent-shared/eazel-services-footer.c @@ -23,14 +23,10 @@ */ #include <config.h> + #include "eazel-services-footer.h" -#include "eazel-services-constants.h" +#include "eazel-services-extensions.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> @@ -41,9 +37,19 @@ struct _EazelServicesFooterDetails { - GList *items; + GtkWidget *date; }; +/* Signals */ +typedef enum +{ + ITEM_CLICKED, + LAST_SIGNAL +} FooterSignal; + +/* Signals */ +static guint footer_signals[LAST_SIGNAL] = { 0 }; + /* GtkObjectClass methods */ static void eazel_services_footer_initialize_class (EazelServicesFooterClass *klass); static void eazel_services_footer_initialize (EazelServicesFooter *footer); @@ -61,6 +67,18 @@ eazel_services_footer_initialize_class (EazelServicesFooterClass *footer_class) /* GtkObjectClass */ object_class->destroy = footer_destroy; + + /* Signals */ + footer_signals[ITEM_CLICKED] = gtk_signal_new ("item_clicked", + GTK_RUN_LAST, + object_class->type, + 0, + gtk_marshal_NONE__INT, + GTK_TYPE_NONE, + 1, + GTK_TYPE_INT); + + gtk_object_class_add_signals (object_class, footer_signals, LAST_SIGNAL); } static void @@ -80,74 +98,14 @@ footer_destroy (GtkObject *object) footer = EAZEL_SERVICES_FOOTER (object); g_free (footer->details); + + g_print ("%s()\n", __FUNCTION__); /* 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 { @@ -156,27 +114,25 @@ typedef struct char *prelight_tile_name; GdkPixbuf *tile_pixbuf; GdkPixbuf *prelight_tile_pixbuf; -} PrelightLabelData; +} PrelightData; static gint -label_enter_event (GtkWidget *event_box, - GdkEventCrossing *event, - gpointer client_data) +footer_item_enter_event (GtkWidget *event_box, + GdkEventCrossing *event, + gpointer client_data) { - PrelightLabelData *data; + PrelightData *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; + data = (PrelightData *) 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); + data->prelight_tile_pixbuf = eazel_services_pixbuf_new (data->prelight_tile_name); } if (data->prelight_tile_pixbuf != NULL) { @@ -188,22 +144,22 @@ label_enter_event (GtkWidget *event_box, } static gint -label_leave_event (GtkWidget *event_box, - GdkEventCrossing *event, - gpointer client_data) +footer_item_leave_event (GtkWidget *event_box, + GdkEventCrossing *event, + gpointer client_data) { - PrelightLabelData *data; + PrelightData *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; + data = (PrelightData *) 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); + data->tile_pixbuf = eazel_services_pixbuf_new (data->tile_name); } if (data->tile_pixbuf != NULL) { @@ -214,33 +170,41 @@ label_leave_event (GtkWidget *event_box, return TRUE; } +typedef struct +{ + EazelServicesFooter *footer; + int index; +} ButtonPressData; + static gint -label_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer client_data) +footer_item_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer client_data) { - const char *uri; - + ButtonPressData *data; + 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; + data = (ButtonPressData *) client_data; - g_print ("%s(%s)\n", __FUNCTION__, uri); + g_return_val_if_fail (EAZEL_SERVICES_IS_FOOTER (data->footer), TRUE); + + gtk_signal_emit (GTK_OBJECT (data->footer), footer_signals[ITEM_CLICKED], data->index); return TRUE; } static void -label_free_data (GtkWidget *event_box, - gpointer client_data) +footer_item_prelight_data_free_callback (GtkWidget *event_box, + gpointer client_data) { - PrelightLabelData *data; + PrelightData *data; g_return_if_fail (GTK_IS_EVENT_BOX (event_box)); g_return_if_fail (client_data != NULL); - data = (PrelightLabelData *) client_data; + data = (PrelightData *) client_data; g_free (data->tile_name); g_free (data->prelight_tile_name); @@ -250,8 +214,8 @@ label_free_data (GtkWidget *event_box, } static void -label_free_uri (GtkWidget *event_box, - gpointer client_data) +free_data_callback (GtkWidget *event_box, + gpointer client_data) { g_return_if_fail (GTK_IS_EVENT_BOX (event_box)); g_return_if_fail (client_data != NULL); @@ -259,131 +223,77 @@ label_free_uri (GtkWidget *event_box, 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; + PrelightData *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 = g_new0 (PrelightData, 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); + gtk_signal_connect (GTK_OBJECT (event_box), "enter_notify_event", GTK_SIGNAL_FUNC (footer_item_enter_event), data); + gtk_signal_connect (GTK_OBJECT (event_box), "leave_notify_event", GTK_SIGNAL_FUNC (footer_item_leave_event), data); + gtk_signal_connect (GTK_OBJECT (event_box), "destroy", GTK_SIGNAL_FUNC (footer_item_prelight_data_free_callback), data); } static GtkWidget * -footer_item_new (const char *text, const char *uri, gboolean has_left_bumper, gboolean has_right_bumper) +footer_item_new (EazelServicesFooter *footer, + const char *text, + int index, + gboolean has_left_bumper, + gboolean has_right_bumper) { GtkWidget *hbox; GtkWidget *event_box; GtkWidget *label; - char *uri_copy; + ButtonPressData *data; + g_return_val_if_fail (EAZEL_SERVICES_IS_FOOTER (footer), NULL); 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); + left = eazel_services_image_new (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); + label = eazel_services_label_new (text, FALSE, 13, 5, 0, 2, 0, + EAZEL_SERVICES_BACKGROUND_COLOR_RGBA, + EAZEL_SERVICES_NORMAL_FILL); gtk_widget_show (label); - uri_copy = g_strdup (uri); + data = g_new (ButtonPressData, 1); + data->index = index; + data->footer = footer; - 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); + gtk_signal_connect (GTK_OBJECT (event_box), "button_press_event", GTK_SIGNAL_FUNC (footer_item_button_press_event), data); + gtk_signal_connect (GTK_OBJECT (event_box), "destroy", GTK_SIGNAL_FUNC (free_data_callback), data); 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); + right = eazel_services_image_new (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); @@ -404,9 +314,9 @@ footer_remainder_new (void) 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); + left = eazel_services_image_new (EAZEL_SERVICES_REMAINDER_LEFT_BUMPER, NULL, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + fill = eazel_services_image_new (NULL, EAZEL_SERVICES_REMAINDER_FILL, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + right = eazel_services_image_new (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); @@ -433,22 +343,21 @@ eazel_services_footer_new (void) void eazel_services_footer_update (EazelServicesFooter *footer, const char *items[], - const char *uris[], guint num_items) { GtkWidget *remainder; - GtkWidget *date; guint i; + char *date_string; 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)); + item = footer_item_new (footer, items[i], i, i > 0, i < (num_items - 1)); + gtk_box_pack_start (GTK_BOX (footer), item, FALSE, FALSE, 0); gtk_widget_show (item); } @@ -456,20 +365,30 @@ eazel_services_footer_update (EazelServicesFooter *footer, 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); + date_string = eazel_services_get_current_date_string (); + footer->details->date = eazel_services_label_new (date_string, + FALSE, 13, 8, 0, 2, 0, + EAZEL_SERVICES_BACKGROUND_COLOR_RGBA, + EAZEL_SERVICES_NORMAL_FILL); + g_free (date_string); + gtk_widget_show (remainder); - gtk_widget_show (date); + gtk_widget_show (footer->details->date); + + gtk_box_pack_start (GTK_BOX (footer), footer->details->date, FALSE, FALSE, 0); +} + +void +eazel_services_footer_set_date (EazelServicesFooter *footer, + const char *date) +{ + + g_return_if_fail (EAZEL_SERVICES_IS_FOOTER (footer)); + g_return_if_fail (date != NULL); + g_return_if_fail (date[0] != '\0'); + + g_return_if_fail (NAUTILUS_IS_LABEL (footer->details->date)); - gtk_box_pack_start (GTK_BOX (footer), date, FALSE, FALSE, 0); + nautilus_label_set_text (NAUTILUS_LABEL (footer->details->date), date); } diff --git a/components/services/nautilus-dependent-shared/eazel-services-footer.h b/components/services/nautilus-dependent-shared/eazel-services-footer.h index 79f574445..d689d671f 100644 --- a/components/services/nautilus-dependent-shared/eazel-services-footer.h +++ b/components/services/nautilus-dependent-shared/eazel-services-footer.h @@ -59,8 +59,9 @@ 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); +void eazel_services_footer_set_date (EazelServicesFooter *footer, + const char *date); END_GNOME_DECLS diff --git a/components/services/nautilus-dependent-shared/eazel-services-header.c b/components/services/nautilus-dependent-shared/eazel-services-header.c index d60622629..a8c6c9cca 100644 --- a/components/services/nautilus-dependent-shared/eazel-services-header.c +++ b/components/services/nautilus-dependent-shared/eazel-services-header.c @@ -23,14 +23,10 @@ */ #include <config.h> + #include "eazel-services-header.h" -#include "eazel-services-constants.h" +#include "eazel-services-extensions.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> @@ -85,120 +81,6 @@ header_destroy (GtkObject *object) 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) @@ -209,21 +91,13 @@ eazel_services_header_new (const char *text) 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); + header->details->text = eazel_services_label_new (text, TRUE, 18, 10, 0, 4, 0, + EAZEL_SERVICES_BACKGROUND_COLOR_RGBA, + EAZEL_SERVICES_LOGO_LEFT_SIDE_REPEAT_ICON); + + middle = eazel_services_image_new (NULL, EAZEL_SERVICES_LOGO_LEFT_SIDE_REPEAT_ICON, EAZEL_SERVICES_BACKGROUND_COLOR_RGBA); + + logo = eazel_services_image_new (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); diff --git a/components/services/nautilus-dependent-shared/test-footer-header.c b/components/services/nautilus-dependent-shared/test-footer-header.c index cdf3acada..1e28301bb 100644 --- a/components/services/nautilus-dependent-shared/test-footer-header.c +++ b/components/services/nautilus-dependent-shared/test-footer-header.c @@ -25,18 +25,9 @@ #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-extensions.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) @@ -52,13 +43,11 @@ static const char *footer_items[] = "Privacy Statement" }; -static const char *footer_uris[] = +static void +footer_item_clicked_callback (GtkWidget *widget, int index, gpointer callback_data) { - "eazel:register", - "eazel:login", - "eazel:terms", - "eazel:privacy" -}; + g_print ("footer_item_clicked_callback(%d)\n", index); +} int main (int argc, char* argv[]) @@ -87,9 +76,10 @@ main (int argc, char* argv[]) content = gtk_vbox_new (FALSE, 0); footer = eazel_services_footer_new (); + gtk_signal_connect (GTK_OBJECT (footer), "item_clicked", GTK_SIGNAL_FUNC (footer_item_clicked_callback), NULL); + 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); diff --git a/components/services/summary/nautilus-summary-view.c b/components/services/summary/nautilus-summary-view.c index 298762db9..a93604074 100644 --- a/components/services/summary/nautilus-summary-view.c +++ b/components/services/summary/nautilus-summary-view.c @@ -30,7 +30,7 @@ #include "eazel-services-footer.h" #include "eazel-services-header.h" -#include "eazel-services-constants.h" +#include "eazel-services-extensions.h" #include <gnome-xml/tree.h> #include <bonobo/bonobo-control.h> @@ -210,70 +210,76 @@ struct _NautilusSummaryViewDetails { GConfEngine * engine_gconf; }; -static void nautilus_summary_view_initialize_class (NautilusSummaryViewClass *klass); -static void nautilus_summary_view_initialize (NautilusSummaryView *view); -static void nautilus_summary_view_destroy (GtkObject *object); -static void summary_load_location_callback (NautilusView *nautilus_view, - const char *location, - NautilusSummaryView *view); -static void generate_summary_form (NautilusSummaryView *view); -static void generate_service_entry_row (NautilusSummaryView *view, - int row); -static void generate_eazel_news_entry_row (NautilusSummaryView *view, - int row); -static void generate_update_news_entry_row (NautilusSummaryView *view, - int row); -static void login_button_cb (GtkWidget *button, - NautilusSummaryView *view); -static void preferences_button_cb (GtkWidget *button, - NautilusSummaryView *view); -static void logout_button_cb (GtkWidget *button, - NautilusSummaryView *view); -static void goto_service_cb (GtkWidget *button, - ServicesButtonCallbackData *cbdata); -static void goto_update_cb (GtkWidget *button, - ServicesButtonCallbackData *cbdata); -static void register_button_cb (GtkWidget *button, - NautilusSummaryView *view); -static gboolean am_i_logged_in (NautilusSummaryView *view); -static char* who_is_logged_in (NautilusSummaryView *view); -static gint logged_in_callback (gpointer raw); -static gint logged_out_callback (gpointer raw); -static void generate_error_dialog (NautilusSummaryView *view, - const char *message); -static void generate_login_dialog (NautilusSummaryView *view); -static void widget_set_nautilus_background_color (GtkWidget *widget, - const char *color); -static void merge_bonobo_menu_items (BonoboControl *control, - gboolean state, - gpointer user_data); -static void update_menu_items (NautilusSummaryView *view, - gboolean logged_in); -static void -service_tab_selected_callback (GtkWidget *widget, - int which_tab, - NautilusSummaryView *view); -static void -updates_tab_selected_callback (GtkWidget *widget, - int which_tab, - NautilusSummaryView *view); +static void nautilus_summary_view_initialize_class (NautilusSummaryViewClass *klass); +static void nautilus_summary_view_initialize (NautilusSummaryView *view); +static void nautilus_summary_view_destroy (GtkObject *object); +static void summary_load_location_callback (NautilusView *nautilus_view, + const char *location, + NautilusSummaryView *view); +static void generate_summary_form (NautilusSummaryView *view); +static void generate_service_entry_row (NautilusSummaryView *view, + int row); +static void generate_eazel_news_entry_row (NautilusSummaryView *view, + int row); +static void generate_update_news_entry_row (NautilusSummaryView *view, + int row); +static void login_button_cb (GtkWidget *button, + NautilusSummaryView *view); +static void preferences_button_cb (GtkWidget *button, + NautilusSummaryView *view); +static void logout_button_cb (GtkWidget *button, + NautilusSummaryView *view); +static void goto_service_cb (GtkWidget *button, + ServicesButtonCallbackData *cbdata); +static void goto_update_cb (GtkWidget *button, + ServicesButtonCallbackData *cbdata); +static void register_button_cb (GtkWidget *button, + NautilusSummaryView *view); +static gboolean am_i_logged_in (NautilusSummaryView *view); +static char* who_is_logged_in (NautilusSummaryView *view); +static gint logged_in_callback (gpointer raw); +static gint logged_out_callback (gpointer raw); +static void generate_error_dialog (NautilusSummaryView *view, + const char *message); +static void generate_login_dialog (NautilusSummaryView *view); +static void widget_set_nautilus_background_color (GtkWidget *widget, + const char *color); +static void merge_bonobo_menu_items (BonoboControl *control, + gboolean state, + gpointer user_data); +static void update_menu_items (NautilusSummaryView *view, + gboolean logged_in); +static void service_tab_selected_callback (GtkWidget *widget, + int which_tab, + NautilusSummaryView *view); +static void updates_tab_selected_callback (GtkWidget *widget, + int which_tab, + NautilusSummaryView *view); +static void footer_item_clicked_callback (GtkWidget *widget, + int index, + gpointer callback_data); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusSummaryView, nautilus_summary_view, GTK_TYPE_EVENT_BOX) -static const char *footer_items[] = +#define FOOTER_REGISTER_OR_PREFERENCES 0 +#define FOOTER_LOGIN_OR_LOGOUT 1 +#define FOOTER_TERMS_OF_USER 2 +#define FOOTER_PRIVACY_STATEMENT 3 + +static const char *footer_online_items[] = { - "Register", - "Login", - "Terms of Use", - "Privacy Statement" + N_("Register"), + N_("Login"), + N_("Terms of Use"), + N_("Privacy Statement") }; -static const char *footer_uris[] = +static const char *footer_offline_items[] = { - "eazel:register", - "eazel:login", - "eazel:terms", - "eazel:privacy" + N_("Account Preferences"), + N_("Logout"), + N_("Terms of Use"), + N_("Privacy Statement") }; static void @@ -316,11 +322,7 @@ generate_summary_form (NautilusSummaryView *view) /* setup the title */ title = eazel_services_header_new (""); - if (!view->details->logged_in) { - eazel_services_header_set_text (EAZEL_SERVICES_HEADER (title), - _("You are not logged in!")); - } - else { + if (view->details->logged_in) { char *text; g_free (view->details->user_name); view->details->user_name = who_is_logged_in (view); @@ -328,6 +330,10 @@ generate_summary_form (NautilusSummaryView *view) eazel_services_header_set_text (EAZEL_SERVICES_HEADER (title), text); g_free (text); } + else { + eazel_services_header_set_text (EAZEL_SERVICES_HEADER (title), + _("You are not logged in!")); + } gtk_box_pack_start (GTK_BOX (view->details->form), title, FALSE, FALSE, 0); gtk_widget_show (title); @@ -576,11 +582,19 @@ generate_summary_form (NautilusSummaryView *view) view->details->xml_data = NULL; footer = eazel_services_footer_new (); - eazel_services_footer_update (EAZEL_SERVICES_FOOTER (footer), - footer_items, - footer_uris, - NAUTILUS_N_ELEMENTS (footer_items)); - + gtk_signal_connect (GTK_OBJECT (footer), "item_clicked", GTK_SIGNAL_FUNC (footer_item_clicked_callback), view); + + if (view->details->logged_in) { + eazel_services_footer_update (EAZEL_SERVICES_FOOTER (footer), + footer_offline_items, + NAUTILUS_N_ELEMENTS (footer_online_items)); + } + else { + eazel_services_footer_update (EAZEL_SERVICES_FOOTER (footer), + footer_online_items, + NAUTILUS_N_ELEMENTS (footer_online_items)); + } + gtk_box_pack_start (GTK_BOX (view->details->form), footer, FALSE, FALSE, 0); gtk_widget_show (footer); @@ -1615,3 +1629,37 @@ merge_bonobo_menu_items (BonoboControl *control, gboolean state, gpointer user_d * views are never explicitly deactivated */ } + +static void +footer_item_clicked_callback (GtkWidget *widget, int index, gpointer callback_data) +{ + NautilusSummaryView *view; + + g_return_if_fail (NAUTILUS_IS_SUMMARY_VIEW (callback_data)); + g_return_if_fail (index >= FOOTER_REGISTER_OR_PREFERENCES); + g_return_if_fail (index <= FOOTER_PRIVACY_STATEMENT); + + view = NAUTILUS_SUMMARY_VIEW (callback_data); + + switch (index) { + case FOOTER_REGISTER_OR_PREFERENCES: + register_button_cb (NULL, view); + break; + + case FOOTER_LOGIN_OR_LOGOUT: + generate_login_dialog (view); + break; + + case FOOTER_TERMS_OF_USER: + go_to_uri (view->details->nautilus_view, "eazel-services://anonymous/aboutus/terms_of_use"); + break; + + case FOOTER_PRIVACY_STATEMENT: + go_to_uri (view->details->nautilus_view, "eazel-services://anonymous/aboutus/privacy"); + break; + + default: + g_assert_not_reached (); + break; + } +} diff --git a/components/services/summary/nautilus-view/nautilus-summary-view.c b/components/services/summary/nautilus-view/nautilus-summary-view.c index 298762db9..a93604074 100644 --- a/components/services/summary/nautilus-view/nautilus-summary-view.c +++ b/components/services/summary/nautilus-view/nautilus-summary-view.c @@ -30,7 +30,7 @@ #include "eazel-services-footer.h" #include "eazel-services-header.h" -#include "eazel-services-constants.h" +#include "eazel-services-extensions.h" #include <gnome-xml/tree.h> #include <bonobo/bonobo-control.h> @@ -210,70 +210,76 @@ struct _NautilusSummaryViewDetails { GConfEngine * engine_gconf; }; -static void nautilus_summary_view_initialize_class (NautilusSummaryViewClass *klass); -static void nautilus_summary_view_initialize (NautilusSummaryView *view); -static void nautilus_summary_view_destroy (GtkObject *object); -static void summary_load_location_callback (NautilusView *nautilus_view, - const char *location, - NautilusSummaryView *view); -static void generate_summary_form (NautilusSummaryView *view); -static void generate_service_entry_row (NautilusSummaryView *view, - int row); -static void generate_eazel_news_entry_row (NautilusSummaryView *view, - int row); -static void generate_update_news_entry_row (NautilusSummaryView *view, - int row); -static void login_button_cb (GtkWidget *button, - NautilusSummaryView *view); -static void preferences_button_cb (GtkWidget *button, - NautilusSummaryView *view); -static void logout_button_cb (GtkWidget *button, - NautilusSummaryView *view); -static void goto_service_cb (GtkWidget *button, - ServicesButtonCallbackData *cbdata); -static void goto_update_cb (GtkWidget *button, - ServicesButtonCallbackData *cbdata); -static void register_button_cb (GtkWidget *button, - NautilusSummaryView *view); -static gboolean am_i_logged_in (NautilusSummaryView *view); -static char* who_is_logged_in (NautilusSummaryView *view); -static gint logged_in_callback (gpointer raw); -static gint logged_out_callback (gpointer raw); -static void generate_error_dialog (NautilusSummaryView *view, - const char *message); -static void generate_login_dialog (NautilusSummaryView *view); -static void widget_set_nautilus_background_color (GtkWidget *widget, - const char *color); -static void merge_bonobo_menu_items (BonoboControl *control, - gboolean state, - gpointer user_data); -static void update_menu_items (NautilusSummaryView *view, - gboolean logged_in); -static void -service_tab_selected_callback (GtkWidget *widget, - int which_tab, - NautilusSummaryView *view); -static void -updates_tab_selected_callback (GtkWidget *widget, - int which_tab, - NautilusSummaryView *view); +static void nautilus_summary_view_initialize_class (NautilusSummaryViewClass *klass); +static void nautilus_summary_view_initialize (NautilusSummaryView *view); +static void nautilus_summary_view_destroy (GtkObject *object); +static void summary_load_location_callback (NautilusView *nautilus_view, + const char *location, + NautilusSummaryView *view); +static void generate_summary_form (NautilusSummaryView *view); +static void generate_service_entry_row (NautilusSummaryView *view, + int row); +static void generate_eazel_news_entry_row (NautilusSummaryView *view, + int row); +static void generate_update_news_entry_row (NautilusSummaryView *view, + int row); +static void login_button_cb (GtkWidget *button, + NautilusSummaryView *view); +static void preferences_button_cb (GtkWidget *button, + NautilusSummaryView *view); +static void logout_button_cb (GtkWidget *button, + NautilusSummaryView *view); +static void goto_service_cb (GtkWidget *button, + ServicesButtonCallbackData *cbdata); +static void goto_update_cb (GtkWidget *button, + ServicesButtonCallbackData *cbdata); +static void register_button_cb (GtkWidget *button, + NautilusSummaryView *view); +static gboolean am_i_logged_in (NautilusSummaryView *view); +static char* who_is_logged_in (NautilusSummaryView *view); +static gint logged_in_callback (gpointer raw); +static gint logged_out_callback (gpointer raw); +static void generate_error_dialog (NautilusSummaryView *view, + const char *message); +static void generate_login_dialog (NautilusSummaryView *view); +static void widget_set_nautilus_background_color (GtkWidget *widget, + const char *color); +static void merge_bonobo_menu_items (BonoboControl *control, + gboolean state, + gpointer user_data); +static void update_menu_items (NautilusSummaryView *view, + gboolean logged_in); +static void service_tab_selected_callback (GtkWidget *widget, + int which_tab, + NautilusSummaryView *view); +static void updates_tab_selected_callback (GtkWidget *widget, + int which_tab, + NautilusSummaryView *view); +static void footer_item_clicked_callback (GtkWidget *widget, + int index, + gpointer callback_data); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusSummaryView, nautilus_summary_view, GTK_TYPE_EVENT_BOX) -static const char *footer_items[] = +#define FOOTER_REGISTER_OR_PREFERENCES 0 +#define FOOTER_LOGIN_OR_LOGOUT 1 +#define FOOTER_TERMS_OF_USER 2 +#define FOOTER_PRIVACY_STATEMENT 3 + +static const char *footer_online_items[] = { - "Register", - "Login", - "Terms of Use", - "Privacy Statement" + N_("Register"), + N_("Login"), + N_("Terms of Use"), + N_("Privacy Statement") }; -static const char *footer_uris[] = +static const char *footer_offline_items[] = { - "eazel:register", - "eazel:login", - "eazel:terms", - "eazel:privacy" + N_("Account Preferences"), + N_("Logout"), + N_("Terms of Use"), + N_("Privacy Statement") }; static void @@ -316,11 +322,7 @@ generate_summary_form (NautilusSummaryView *view) /* setup the title */ title = eazel_services_header_new (""); - if (!view->details->logged_in) { - eazel_services_header_set_text (EAZEL_SERVICES_HEADER (title), - _("You are not logged in!")); - } - else { + if (view->details->logged_in) { char *text; g_free (view->details->user_name); view->details->user_name = who_is_logged_in (view); @@ -328,6 +330,10 @@ generate_summary_form (NautilusSummaryView *view) eazel_services_header_set_text (EAZEL_SERVICES_HEADER (title), text); g_free (text); } + else { + eazel_services_header_set_text (EAZEL_SERVICES_HEADER (title), + _("You are not logged in!")); + } gtk_box_pack_start (GTK_BOX (view->details->form), title, FALSE, FALSE, 0); gtk_widget_show (title); @@ -576,11 +582,19 @@ generate_summary_form (NautilusSummaryView *view) view->details->xml_data = NULL; footer = eazel_services_footer_new (); - eazel_services_footer_update (EAZEL_SERVICES_FOOTER (footer), - footer_items, - footer_uris, - NAUTILUS_N_ELEMENTS (footer_items)); - + gtk_signal_connect (GTK_OBJECT (footer), "item_clicked", GTK_SIGNAL_FUNC (footer_item_clicked_callback), view); + + if (view->details->logged_in) { + eazel_services_footer_update (EAZEL_SERVICES_FOOTER (footer), + footer_offline_items, + NAUTILUS_N_ELEMENTS (footer_online_items)); + } + else { + eazel_services_footer_update (EAZEL_SERVICES_FOOTER (footer), + footer_online_items, + NAUTILUS_N_ELEMENTS (footer_online_items)); + } + gtk_box_pack_start (GTK_BOX (view->details->form), footer, FALSE, FALSE, 0); gtk_widget_show (footer); @@ -1615,3 +1629,37 @@ merge_bonobo_menu_items (BonoboControl *control, gboolean state, gpointer user_d * views are never explicitly deactivated */ } + +static void +footer_item_clicked_callback (GtkWidget *widget, int index, gpointer callback_data) +{ + NautilusSummaryView *view; + + g_return_if_fail (NAUTILUS_IS_SUMMARY_VIEW (callback_data)); + g_return_if_fail (index >= FOOTER_REGISTER_OR_PREFERENCES); + g_return_if_fail (index <= FOOTER_PRIVACY_STATEMENT); + + view = NAUTILUS_SUMMARY_VIEW (callback_data); + + switch (index) { + case FOOTER_REGISTER_OR_PREFERENCES: + register_button_cb (NULL, view); + break; + + case FOOTER_LOGIN_OR_LOGOUT: + generate_login_dialog (view); + break; + + case FOOTER_TERMS_OF_USER: + go_to_uri (view->details->nautilus_view, "eazel-services://anonymous/aboutus/terms_of_use"); + break; + + case FOOTER_PRIVACY_STATEMENT: + go_to_uri (view->details->nautilus_view, "eazel-services://anonymous/aboutus/privacy"); + break; + + default: + g_assert_not_reached (); + break; + } +} diff --git a/libnautilus-extensions/nautilus-image.c b/libnautilus-extensions/nautilus-image.c index 8affda5e7..b6b87a10f 100644 --- a/libnautilus-extensions/nautilus-image.c +++ b/libnautilus-extensions/nautilus-image.c @@ -503,3 +503,53 @@ nautilus_image_get_alpha_mode (const NautilusImage *image) return image->detail->alpha_mode; } + +/** + * nautilus_image_new_loaded: + * + * @text: Text or NULL + * @family: Font family or NULL + * @weight: Font weight or NULL + * @font_size: Font size in pixels + * @drop_shadow_offset: Drop shadow offset + * @drop_shadow_color: Drop shadow color + * @text_color: Text color + * @xpadding: Amount to pad image in the x direction. + * @ypadding: Amount to pad image in the y direction. + * @vertical_offset: Amount to offset the image vertically. + * @horizontal_offset: Amount to offset the image horizontally. + * @background_color: Background color. + * @tile_pixbuf: Pixbuf to use for tile or NULL + * + * Return value: Newly created image with all the given values. + */ +GtkWidget * +nautilus_image_new_loaded (GdkPixbuf *pixbuf, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + GdkPixbuf *tile_pixbuf) +{ + NautilusImage *image; + + image = NAUTILUS_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); + nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (image), vertical_offset); + nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (image), horizontal_offset); + + gtk_misc_set_padding (GTK_MISC (image), xpadding, ypadding); + + if (pixbuf != NULL) { + nautilus_image_set_pixbuf (image, pixbuf); + } + + if (tile_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (image), tile_pixbuf); + } + + return GTK_WIDGET (image); +} diff --git a/libnautilus-extensions/nautilus-image.h b/libnautilus-extensions/nautilus-image.h index 648116269..9cf537c29 100644 --- a/libnautilus-extensions/nautilus-image.h +++ b/libnautilus-extensions/nautilus-image.h @@ -73,6 +73,13 @@ typedef enum GtkType nautilus_image_get_type (void); GtkWidget * nautilus_image_new (void); +GtkWidget * nautilus_image_new_loaded (GdkPixbuf *pixbuf, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + GdkPixbuf *tile_pixbuf); void nautilus_image_set_pixbuf (NautilusImage *image, GdkPixbuf *pixbuf); GdkPixbuf* nautilus_image_get_pixbuf (const NautilusImage *image); diff --git a/libnautilus-extensions/nautilus-label.c b/libnautilus-extensions/nautilus-label.c index 9ef11d973..b45dd56a8 100644 --- a/libnautilus-extensions/nautilus-label.c +++ b/libnautilus-extensions/nautilus-label.c @@ -1018,3 +1018,63 @@ nautilus_label_get_line_wrap_separators (const NautilusLabel *label) return g_strdup (label->detail->line_wrap_separators); } + +/** + * nautilus_label_new_loaded: + * + * @text: Text or NULL + * @family: Font family or NULL + * @weight: Font weight or NULL + * @font_size: Font size in pixels + * @drop_shadow_offset: Drop shadow offset + * @drop_shadow_color: Drop shadow color + * @text_color: Text color + * @xpadding: Amount to pad label in the x direction. + * @ypadding: Amount to pad label in the y direction. + * @vertical_offset: Amount to offset the label vertically. + * @horizontal_offset: Amount to offset the label horizontally. + * @background_color: Background color. + * @tile_pixbuf: Pixbuf to use for tile or NULL + * + * Return value: Newly created label with all the given values. + */ +GtkWidget * +nautilus_label_new_loaded (const char *text, + const char *family, + const char *weight, + guint font_size, + guint drop_shadow_offset, + guint32 drop_shadow_color, + guint32 text_color, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + GdkPixbuf *tile_pixbuf) +{ + NautilusLabel *label; + + label = NAUTILUS_LABEL (nautilus_label_new (text ? text : "")); + + if (family != NULL) { + nautilus_label_set_font_from_components (label, family, weight, NULL, NULL); + } + + nautilus_label_set_font_size (label, font_size); + nautilus_label_set_drop_shadow_offset (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 (label, drop_shadow_color); + nautilus_label_set_text_color (label, text_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_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (label), tile_pixbuf); + } + + return GTK_WIDGET (label); +} diff --git a/libnautilus-extensions/nautilus-label.h b/libnautilus-extensions/nautilus-label.h index 4d648cb19..2e42aa04d 100644 --- a/libnautilus-extensions/nautilus-label.h +++ b/libnautilus-extensions/nautilus-label.h @@ -71,6 +71,19 @@ struct _NautilusLabelClass GtkType nautilus_label_get_type (void); GtkWidget * nautilus_label_new (const char *text); +GtkWidget * nautilus_label_new_loaded (const char *text, + const char *family, + const char *weight, + guint font_size, + guint drop_shadow_offset, + guint32 drop_shadow_color, + guint32 text_color, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + GdkPixbuf *tile_pixbuf); void nautilus_label_set_text (NautilusLabel *label, const char *text); char* nautilus_label_get_text (NautilusLabel *label); diff --git a/libnautilus-private/nautilus-image.c b/libnautilus-private/nautilus-image.c index 8affda5e7..b6b87a10f 100644 --- a/libnautilus-private/nautilus-image.c +++ b/libnautilus-private/nautilus-image.c @@ -503,3 +503,53 @@ nautilus_image_get_alpha_mode (const NautilusImage *image) return image->detail->alpha_mode; } + +/** + * nautilus_image_new_loaded: + * + * @text: Text or NULL + * @family: Font family or NULL + * @weight: Font weight or NULL + * @font_size: Font size in pixels + * @drop_shadow_offset: Drop shadow offset + * @drop_shadow_color: Drop shadow color + * @text_color: Text color + * @xpadding: Amount to pad image in the x direction. + * @ypadding: Amount to pad image in the y direction. + * @vertical_offset: Amount to offset the image vertically. + * @horizontal_offset: Amount to offset the image horizontally. + * @background_color: Background color. + * @tile_pixbuf: Pixbuf to use for tile or NULL + * + * Return value: Newly created image with all the given values. + */ +GtkWidget * +nautilus_image_new_loaded (GdkPixbuf *pixbuf, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + GdkPixbuf *tile_pixbuf) +{ + NautilusImage *image; + + image = NAUTILUS_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); + nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (image), vertical_offset); + nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (image), horizontal_offset); + + gtk_misc_set_padding (GTK_MISC (image), xpadding, ypadding); + + if (pixbuf != NULL) { + nautilus_image_set_pixbuf (image, pixbuf); + } + + if (tile_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (image), tile_pixbuf); + } + + return GTK_WIDGET (image); +} diff --git a/libnautilus-private/nautilus-image.h b/libnautilus-private/nautilus-image.h index 648116269..9cf537c29 100644 --- a/libnautilus-private/nautilus-image.h +++ b/libnautilus-private/nautilus-image.h @@ -73,6 +73,13 @@ typedef enum GtkType nautilus_image_get_type (void); GtkWidget * nautilus_image_new (void); +GtkWidget * nautilus_image_new_loaded (GdkPixbuf *pixbuf, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + GdkPixbuf *tile_pixbuf); void nautilus_image_set_pixbuf (NautilusImage *image, GdkPixbuf *pixbuf); GdkPixbuf* nautilus_image_get_pixbuf (const NautilusImage *image); diff --git a/libnautilus-private/nautilus-label.c b/libnautilus-private/nautilus-label.c index 9ef11d973..b45dd56a8 100644 --- a/libnautilus-private/nautilus-label.c +++ b/libnautilus-private/nautilus-label.c @@ -1018,3 +1018,63 @@ nautilus_label_get_line_wrap_separators (const NautilusLabel *label) return g_strdup (label->detail->line_wrap_separators); } + +/** + * nautilus_label_new_loaded: + * + * @text: Text or NULL + * @family: Font family or NULL + * @weight: Font weight or NULL + * @font_size: Font size in pixels + * @drop_shadow_offset: Drop shadow offset + * @drop_shadow_color: Drop shadow color + * @text_color: Text color + * @xpadding: Amount to pad label in the x direction. + * @ypadding: Amount to pad label in the y direction. + * @vertical_offset: Amount to offset the label vertically. + * @horizontal_offset: Amount to offset the label horizontally. + * @background_color: Background color. + * @tile_pixbuf: Pixbuf to use for tile or NULL + * + * Return value: Newly created label with all the given values. + */ +GtkWidget * +nautilus_label_new_loaded (const char *text, + const char *family, + const char *weight, + guint font_size, + guint drop_shadow_offset, + guint32 drop_shadow_color, + guint32 text_color, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + GdkPixbuf *tile_pixbuf) +{ + NautilusLabel *label; + + label = NAUTILUS_LABEL (nautilus_label_new (text ? text : "")); + + if (family != NULL) { + nautilus_label_set_font_from_components (label, family, weight, NULL, NULL); + } + + nautilus_label_set_font_size (label, font_size); + nautilus_label_set_drop_shadow_offset (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 (label, drop_shadow_color); + nautilus_label_set_text_color (label, text_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_pixbuf != NULL) { + nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (label), tile_pixbuf); + } + + return GTK_WIDGET (label); +} diff --git a/libnautilus-private/nautilus-label.h b/libnautilus-private/nautilus-label.h index 4d648cb19..2e42aa04d 100644 --- a/libnautilus-private/nautilus-label.h +++ b/libnautilus-private/nautilus-label.h @@ -71,6 +71,19 @@ struct _NautilusLabelClass GtkType nautilus_label_get_type (void); GtkWidget * nautilus_label_new (const char *text); +GtkWidget * nautilus_label_new_loaded (const char *text, + const char *family, + const char *weight, + guint font_size, + guint drop_shadow_offset, + guint32 drop_shadow_color, + guint32 text_color, + gint xpadding, + gint ypadding, + guint vertical_offset, + guint horizontal_offset, + guint32 background_color, + GdkPixbuf *tile_pixbuf); void nautilus_label_set_text (NautilusLabel *label, const char *text); char* nautilus_label_get_text (NautilusLabel *label); |