aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/gnome-cal.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-10-07 09:42:50 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-10-07 09:42:50 +0800
commiteb114d32c827f54d0c752ee022f78fb35d5ee4ef (patch)
treee237e128549b5ad2cce8be3c481ab32ba886ddf4 /calendar/gui/gnome-cal.c
parentbfaace723bb0199325f79ac52c32260df9e524fb (diff)
downloadgsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.tar.gz
gsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.tar.zst
gsoc2013-evolution-eb114d32c827f54d0c752ee022f78fb35d5ee4ef.zip
rename to view_popup_factory. Make it build an epopup item list directly.
2004-10-06 Not Zed <NotZed@Ximian.com> * gui/gnome-cal.c (gnome_calendar_setup_view_popup): rename to view_popup_factory. Make it build an epopup item list directly. Can't re-use the galview cruft :-/ (gnome_calendar_discard_view_popup): no longer needed. (gc_set_view, gc_save_custom_view, gc_define_views_response) (gc_define_views): implement the gal-view popup menu items. * gui/gnome-cal.h: * gui/e-week-view.h: * gui/e-day-view.h: * gui/e-cal-list-view.h: removed old e-popup-menu header. * gui/e-calendar-view.c (setup_popup_icons): removed. (e_calendar_view_create_popup_menu): converted to use e-popup. (on_paste, on_copy, on_cut, on_delete_occurrence) (on_unrecur_appointment, on_delete_appointment, on_publish) (on_forward, on_meeting, on_move_to, on_copy_to, on_print_event) (on_save_as, on_print, on_edit_appointment, on_goto_today) (on_goto_date, on_new_task, on_new_meeting, on_new_event) (on_new_appointment): convert to use e-popup stuff. * gui/tasks-component.c (popup_event_cb): e-popup api changes. * gui/e-cal-popup.c (e_cal_popup_target_new_select): implement the selection target. (ecalp_target_free): and free it. * gui/e-cal-model.h: Make the ECalModel struct non-anonymous so it can be forward-declared. * gui/calendar-component.c (popup_event_cb): e-popup api changes. svn path=/trunk/; revision=27489
Diffstat (limited to 'calendar/gui/gnome-cal.c')
-rw-r--r--calendar/gui/gnome-cal.c125
1 files changed, 114 insertions, 11 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index b8c97d5040..f5ac1895d7 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -47,6 +47,7 @@
#include <libecal/e-cal-time-util.h>
#include <gal/menus/gal-view-factory-etable.h>
#include <gal/menus/gal-view-etable.h>
+#include <gal/menus/gal-define-views-dialog.h>
#include "widgets/menus/gal-view-menus.h"
#include "widgets/misc/e-error.h"
#include "e-comp-editor-registry.h"
@@ -77,6 +78,7 @@
#include "misc.h"
#include "ea-calendar.h"
#include "common/authentication.h"
+#include "e-cal-popup.h"
/* FIXME glib 2.4 and above has this */
#ifndef G_MAXINT32
@@ -1982,36 +1984,137 @@ gnome_calendar_discard_view_menus (GnomeCalendar *gcal)
priv->view_menus = NULL;
}
-EPopupMenu *
-gnome_calendar_setup_view_popup (GnomeCalendar *gcal)
+/* This is copied/moved from gal-view-instance, only the calendar uses this for a popup menu */
+static void
+gc_set_view(EPopup *ep, EPopupItem *pitem, void *data)
{
- GnomeCalendarPrivate *priv;
+ GnomeCalendar *gcal = data;
- g_return_val_if_fail (gcal != NULL, NULL);
- g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
+ if (pitem->type & E_POPUP_ACTIVE)
+ gal_view_instance_set_current_view_id(gcal->priv->view_instance, (char *)pitem->user_data);
+}
- priv = gcal->priv;
+static void
+gc_save_custom_view(EPopup *ep, EPopupItem *pitem, void *data)
+{
+ GnomeCalendar *gcal = data;
- g_return_val_if_fail (priv->view_instance != NULL, NULL);
+ gal_view_instance_save_as(gcal->priv->view_instance);
+}
- return gal_view_instance_get_popup_menu (priv->view_instance);
+static void
+gc_define_views_response(GtkWidget *d, int id, GnomeCalendar *gcal)
+{
+ if (id == GTK_RESPONSE_OK)
+ gal_view_collection_save(gcal->priv->view_instance->collection);
+
+ gtk_widget_destroy(d);
}
-void
-gnome_calendar_discard_view_popup (GnomeCalendar *gcal, EPopupMenu *popup)
+static void
+gc_define_views(EPopup *ep, EPopupItem *pitem, void *data)
+{
+ GnomeCalendar *gcal = data;
+ GtkWidget *dialog = gal_define_views_dialog_new(gcal->priv->view_instance->collection);
+
+ g_signal_connect(dialog, "response", G_CALLBACK(gc_define_views_response), data);
+ gtk_widget_show(dialog);
+}
+
+static EPopupItem gc_popups[] = {
+ /* Code generates the path to fit */
+ { E_POPUP_BAR, NULL },
+ { E_POPUP_RADIO|E_POPUP_ACTIVE, NULL, N_("Custom View"), },
+ { E_POPUP_ITEM, NULL, N_("Save Custom View"), gc_save_custom_view },
+
+ /* index == 3, when we have non-custom view */
+
+ { E_POPUP_BAR, NULL },
+ { E_POPUP_ITEM, NULL, N_("Define Views..."), gc_define_views },
+};
+
+static void
+gc_popup_free (EPopup *ep, GSList *list, void *data)
+{
+ while (list) {
+ GSList *n = list->next;
+ EPopupItem *pitem = list->data;
+
+ g_free(pitem->path);
+ g_free(pitem->label);
+ g_free(pitem->user_data);
+ g_free(pitem);
+ g_slist_free_1(list);
+ list = n;
+ }
+}
+
+static void
+gc_popup_free_static (EPopup *ep, GSList *list, void *data)
{
+ while (list) {
+ GSList *n = list->next;
+ EPopupItem *pitem = list->data;
+ g_free(pitem->path);
+ g_free(pitem);
+ g_slist_free_1(list);
+ list = n;
+ }
+}
+void
+gnome_calendar_view_popup_factory (GnomeCalendar *gcal, EPopup *ep, const char *prefix)
+{
GnomeCalendarPrivate *priv;
+ int length;
+ int i;
+ gboolean found = FALSE;
+ char *id;
+ GSList *menus = NULL;
+ EPopupItem *pitem;
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ g_return_if_fail (prefix != NULL);
priv = gcal->priv;
g_return_if_fail (priv->view_instance != NULL);
- gal_view_instance_free_popup_menu (priv->view_instance, popup);
+ length = gal_view_collection_get_count(priv->view_instance->collection);
+ id = gal_view_instance_get_current_view_id (priv->view_instance);
+
+ for (i = 0; i < length; i++) {
+ GalViewCollectionItem *item = gal_view_collection_get_view_item(priv->view_instance->collection, i);
+
+ pitem = g_malloc0(sizeof(*pitem));
+ pitem->type = E_POPUP_RADIO;
+ pitem->path = g_strdup_printf("%s/%02d.item", prefix, i);
+ pitem->label = g_strdup(item->title);
+ pitem->activate = gc_set_view;
+ pitem->user_data = g_strdup(item->id);
+
+ if (!found && id && !strcmp (id, item->id)) {
+ found = TRUE;
+ pitem->type |= E_POPUP_ACTIVE;
+ }
+
+ menus = g_slist_prepend(menus, pitem);
+ }
+
+ if (menus)
+ e_popup_add_items(ep, menus, gc_popup_free, gcal);
+
+ menus = NULL;
+ for (i = found?3:0; i<sizeof(gc_popups)/sizeof(gc_popups[0]);i++) {
+ pitem = g_malloc0(sizeof(*pitem));
+ memcpy(pitem, &gc_popups[i], sizeof(*pitem));
+ pitem->path = g_strdup_printf("%s/%02d.item", prefix, i+length);
+ menus = g_slist_prepend(menus, pitem);
+ }
+
+ e_popup_add_items(ep, menus, gc_popup_free_static, gcal);
}
static void