/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* e-shortcuts-view-model.c * * Copyright (C) 2000 Helix Code, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program 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 * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Ettore Perazzoli */ /* FIXME. This really sucks. We are using the model/view approach in the dumbest possible way. */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "e-shortcuts-view-model.h" #define PARENT_TYPE e_shortcut_model_get_type () static EShortcutModelClass *parent_class = NULL; struct _EShortcutsViewModelPrivate { EShortcuts *shortcuts; }; /* View initialization. */ static const char * get_storage_set_path_from_uri (const char *uri) { const char *colon; if (g_path_is_absolute (uri)) return NULL; colon = strchr (uri, ':'); if (colon == NULL || colon == uri || colon[1] == '\0') return NULL; if (! g_path_is_absolute (colon + 1)) return NULL; if (g_strncasecmp (uri, "evolution", colon - uri) != 0) return NULL; return colon + 1; } static void load_group_into_model (EShortcutsViewModel *shortcuts_view_model, const char *group_title, int group_num) { EShortcutsViewModelPrivate *priv; EStorageSet *storage_set; GList *shortcut_list; GList *p; priv = shortcuts_view_model->priv; storage_set = e_shortcuts_get_storage_set (priv->shortcuts); g_assert (storage_set != NULL); shortcut_list = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, group_title); if (shortcut_list == NULL) return; for (p = shortcut_list; p != NULL; p = p->next) { EFolder *folder = NULL; const char *path; const char *uri; const char *name; uri = (const char *) p->data; path = get_storage_set_path_from_uri (uri); if (path != NULL) folder = e_storage_set_get_folder (storage_set, path); if (path == NULL || folder == NULL) { /* FIXME */ g_warning ("Invalid link while loading shortcut bar view -- %s\n", uri); continue; } name = e_folder_get_name (folder); e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, -1, uri, name); } e_free_string_list (shortcut_list); } static void load_all_shortcuts_into_model (EShortcutsViewModel *shortcuts_view_model) { EShortcutsViewModelPrivate *priv; GList *group_titles; GList *p; int group_num; priv = shortcuts_view_model->priv; group_titles = e_shortcuts_get_group_titles (priv->shortcuts); for (p = group_titles; p != NULL; p = p->next) { const char *group_title; group_title = (const char *) p->data; group_num = e_shortcut_model_add_group (E_SHORTCUT_MODEL (shortcuts_view_model), -1, group_title); load_group_into_model (shortcuts_view_model, group_title, group_num); } e_free_string_list (group_titles); } /* EShortcuts callbacks. */ static void shortcuts_new_group_cb (EShortcuts *shortcuts, int group_num, void *data) { EShortcutsViewModel *shortcuts_view_model; EShortcutsViewModelPrivate *priv; const char *title; shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data); priv = shortcuts_view_model->priv; title = e_shortcuts_get_group_title (priv->shortcuts, group_num); e_shortcut_model_add_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, title); } static void shortcuts_remove_group_cb (EShortcuts *shortcuts, int group_num, void *data) { EShortcutsViewModel *shortcuts_view_model; shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data); e_shortcut_model_remove_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num); } static void shortcuts_new_shortcut_cb (EShortcuts *shortcuts, int group_num, int item_num, void *data) { EShortcutsViewModel *shortcuts_view_model; EShortcutsViewModelPrivate *priv; EStorageSet *storage_set; EFolder *folder; const char *uri; const char *storage_set_path; const char *folder_name; shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data); priv = shortcuts_view_model->priv; uri = e_shortcuts_get_uri (priv->shortcuts, group_num, item_num); g_assert (uri != NULL); storage_set_path = get_storage_set_path_from_uri (uri); if (storage_set_path == NULL) return; storage_set = e_shortcuts_get_storage_set (priv->shortcuts); folder = e_storage_set_get_folder (storage_set, storage_set_path); folder_name = e_folder_get_name (folder); e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, item_num, uri, folder_name); } static void shortcuts_remove_shortcut_cb (EShortcuts *shortcuts, int group_num, int item_num, void *data) { EShortcutsViewModel *shortcuts_view_model; shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data); e_shortcut_model_remove_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, item_num); } /* GtkObject methods. */ static void impl_destroy (GtkObject *object) { EShortcutsViewModel *view_model; EShortcutsViewModelPrivate *priv; view_model = E_SHORTCUTS_VIEW_MODEL (object); priv = view_model->priv; g_free (priv); } static void class_init (EShortcutsViewModelClass *klass) { GtkObjectClass *object_class; object_class = GTK_OBJECT_CLASS (klass); object_class->destroy = impl_destroy; parent_class = gtk_type_class (e_shortcut_model_get_type ()); } static void init (EShortcutsViewModel *shortcuts_view_model) { EShortcutsViewModelPrivate *priv; priv = g_new (EShortcutsViewModelPrivate, 1); priv->shortcuts = NULL; shortcuts_view_model->priv = priv; } void e_shortcuts_view_model_construct (EShortcutsViewModel *model, EShortcuts *shortcuts) { EShortcutsViewModelPrivate *priv; g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SHORTCUTS_VIEW_MODEL (model)); g_return_if_fail (shortcuts != NULL); g_return_if_fail (E_IS_SHORTCUTS (shortcuts)); priv = model->priv; g_return_if_fail (priv->shortcuts == NULL); priv->shortcuts = shortcuts; load_all_shortcuts_into_model (model); gtk_signal_connect_while_alive (GTK_OBJECT (priv->shortcuts), "new_group", GTK_SIGNAL_FUNC (shortcuts_new_group_cb), model, GTK_OBJECT (model)); gtk_signal_connect_while_alive (GTK_OBJECT (priv->shortcuts), "remove_group", GTK_SIGNAL_FUNC (shortcuts_remove_group_cb), model, GTK_OBJECT (model)); gtk_signal_connect_while_alive (GTK_OBJECT (priv->shortcuts), "new_shortcut", GTK_SIGNAL_FUNC (shortcuts_new_shortcut_cb), model, GTK_OBJECT (model)); gtk_signal_connect_while_alive (GTK_OBJECT (priv->shortcuts), "remove_shortcut", GTK_SIGNAL_FUNC (shortcuts_remove_shortcut_cb), model, GTK_OBJECT (model)); } EShortcutsViewModel * e_shortcuts_view_model_new (EShortcuts *shortcuts) { EShortcutsViewModel *new; g_return_val_if_fail (shortcuts != NULL, NULL); g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL); new = gtk_type_new (e_shortcuts_view_model_get_type ()); e_shortcuts_view_model_construct (new, shortcuts); return new; } E_MAKE_TYPE (e_shortcuts_view_model, "EShortcutsViewModel", EShortcutsViewModel, class_init, init, PARENT_TYPE) 62716fb55e'>Fix C99-ism.bland2005-05-012-4/+4 * Add USB devices support for 5.x.bland2005-04-274-2/+176 * Commit a patch forgotten in the last commit:marcus2005-04-224-2/+24 * Link the gnome-pilot libraries correctly so they play nice with the newmarcus2005-04-224-0/+42 * Set my ports to their shiny new MAINTAINER address.lawrance2005-04-1213-13/+13 * At Kris's request, back out the MACHINE_ARCH spelling correction untilobrien2005-04-128-8/+8 * Assist getting more ports working on AMD64 by obeying theobrien2005-04-118-8/+8 * Update to 2.0.13.marcus2005-04-1112-16/+38 * Fix MASTER_SITES.krion2005-03-311-3/+1 * BROKEN: Unfetchablekris2005-03-271-0/+2 * Bump PORTREVISION to chase the glib20 shared lib version change.marcus2005-03-1210-5/+10 * Update to 0.13arved2005-03-092-2/+3 * Remove more copies of Tcl's SunOS shared library hack.das2005-02-202-0/+34 * As previously announced, remove ports that have reached their expiry date,kris2005-02-196-55/+0 * Fix gzip namespace pollution (bump PORTREV)vs2005-02-172-1/+10 * BROKEN: Incorrect pkg-plistkris2005-02-121-0/+2 * ColdSync 2.2.5 fails to work with devices running PalmOS 4.0 and above,vs2005-02-123-6/+54 * - Fix pkg-plistleeym2005-02-081-0/+1 * - Look for pilot-link in ${LOCALBASE}pav2005-02-061-1/+2 * Unquote IGNORE.vs2005-01-201-1/+1 * [maintainer] palm/synce-kde: update to 0.8.0; transform from rapipedwin2005-01-145-434/+40 * - remove palm/rapip after repocopysem2005-01-105-484/+0 * Add synce-multisync, a SynCE synchronization plugin for Multisync.pav2005-01-095-0/+42 * repo copy palm/rapip -> palm/synce-kdesem2005-01-091-1/+1 * - Fix build on 4.xpav2005-01-092-0/+52 * - Update to 0.9.0pav2005-01-0927-140/+84 * Now buildable on 4.x, still broken on >= 5.x.kris2005-01-081-2/+4 * Say hello to the linux mega patch, it consolidates our linux bits anetchild2005-01-011-1/+1 * This port is scheduled to be removed on 2005-02-18 if it is stillkris2004-12-191-0/+2 * BROKEN on 4.x: Does not buildkris2004-12-121-1/+7 * o) I'm not using syncal anymore for several month so it would be best to givelkoeller2004-11-301-1/+1 * Use new GCONF_SCHEMAS.mezz2004-11-244-6/+2 * Use new INSTALLS_OMF.mezz2004-11-234-4/+2 * More pthread-check fixes.lofi2004-11-124-2/+840 * Bump PORTREVISIONS for all ports that depend on atk or pango to ease in themarcus2004-11-089-5/+9 * Update tp 1.3.0kevlo2004-11-062-3/+4 * - Update to 1.8pav2004-11-038-42/+84 * Updated to 4.15skv2004-10-192-3/+3 * Now builds on amd64kris2004-09-281-4/+0 * BROKEN: Configure failskris2004-09-261-0/+2 * BROKEN on 4.x alsokris2004-09-261-4/+2 * BROKEN on 5.x: Does not compilekris2004-09-261-0/+4 * - Fix package on 4.x (perl 5.0) - Pod:Man is needed for generating of some ma...pav2004-09-262-0/+5 * - Fix plist and unbreakpav2004-09-262-284/+303 * Update to 0.7 to fix build failure (deal with usbdevs changes).thierry2004-09-252-4/+4 * Update to 2.0.12.marcus2004-09-0412-12/+16 * Update to KDE 3.3lofi2004-08-315-189/+0 * Use intlhack.adamw2004-08-282-2/+2 * Update to 2.0.11.marcus2004-08-2726-162/+52 * Optionalize building of tcl/tk bindings.lofi2004-08-264-20/+38 * Change maintainer's email.krion2004-08-212-4/+1 * Fix build with gcc-3.4krion2004-08-181-2/+11 * - Fix build with gcc-3.4pav2004-08-142-0/+78 * Factor out all but one of the build switches of the KDE main module portslofi2004-08-115-0/+189 * - Upgrade to 3.2 (1).kuriyama2004-08-064-5/+18 * Fix build with GCC 3.4.2. This patch was originally submitted bymarcus2004-08-062-0/+22 * Fix build with GCC 3.4.2.marcus2004-08-038-0/+80 * Add pdbc, the PalmOS database compiler/decompiler.pav2004-08-017-0/+122 * Move a bunch of now unique stuff out of gnomehier and intoadamw2004-07-288-4/+12 * re-organize Makefileijliao2004-07-192-142/+42 * Change the default configuration to use GTK2 rather than GTK1.vs2004-07-151-3/+4 * Fix build w/ GCC2 / GTK2vs2004-07-141-0/+20 * Apply a big libtool patch to allow porters to use the libtool installed bymarcus2004-07-108-8/+8 * Use the new GConf handling policy, this will be required for GNOME 2.7/2.8 ormezz2004-07-082-8/+4 * After many hours of fiddling with ugen and uvisor and coldsync and such,green2004-07-022-1/+41 * Update to version 0.6krion2004-06-252-3/+3 * BROKEN on sparc64: Fails to linkkris2004-06-111-0/+4 * Sync with new bsd.autotools.mkade2004-06-051-2/+1 * - Fix build on 5.x and unbreakpav2004-05-112-13/+13 * Make TCL_VER a knob. Default it to 8.4, there for bump PORTREVISION.mi2004-05-092-8/+10 * - Support WITHOUT_NLS to disable gettextpav2004-05-032-49/+59 * Correct pkg-plistkris2004-04-174-2/+22 * Fix /bin/bash-ism (approved by maintainer)vs2004-04-121-0/+8 * Tidy up whitespace.trevor2004-04-111-1/+0 * - Update to 0.40: http://jasonday.home.att.net/code/libmal/ChangeLogvs2004-04-104-7/+19 * Chase the glib20 update, and bump all affected ports' PORTREVISIONs.marcus2004-04-059-9/+9 * - drop math libdinoex2004-04-041-1/+0 * - fix linkage with netpbmdinoex2004-04-041-0/+2 * BROKEN on !i386: Does not compilekris2004-04-031-1/+7 * Remove category pkg/COMMENT files in favour of a COMMENT variable in thekris2004-04-022-1/+2 * BROKEN: Incorrect pkg-plistkris2004-04-011-0/+2 * SIZEify (maintainer timeout)trevor2004-03-315-0/+6 * - Use USE_ICONV knobkrion2004-03-313-6/+5 * Add pdbar, an utility to create and manipulates PalmOS database (.pdb)pav2004-03-307-0/+268 * Update to 0.5kevlo2004-03-262-4/+5 * Updated to 4.01skv2004-03-232-3/+4 * - SIZE'ifykrion2004-03-231-0/+3 * Add SIZE data.knu2004-03-222-0/+2 * Add p5-Palm-PalmDoc 0.12, perl 5 modules for reading and writing PalmDocvanilla2004-03-215-0/+35 * Add size data, approved by maintainers.trevor2004-03-192-0/+2 * Add size data, approved by maintainers.trevor2004-03-191-0/+1 * - Add SIZE to GNOME portspav2004-03-184-0/+4 * - Remove SIZE of old tarballkrion2004-03-181-1/+0 * - Update to version 3.1krion2004-03-183-28/+8 * Add SIZE.sumikawa2004-03-181-0/+1 * SIZEifyijliao2004-03-182-0/+2 * Add size data.trevor2004-03-187-0/+7 * SIZEify.kuriyama2004-03-181-0/+1 * SIZEify.trevor2004-03-184-0/+8 * o) Update to version 0.8.9lkoeller2004-03-172-2/+3 * Whoa there, boy, that's a mighty big commit y'all have there...ade2004-03-1416-16/+16 * - Fix build on gcc-3.3, patch obtained from Gentoo ebuildpav2004-03-143-9/+1746 * Add synce-rra, a project for connecting to devices running Windows CE or Pock...pav2004-03-1413-0/+161 * - Update to version 0.8.9krion2004-03-124-6/+20 * - Update to version 0.8.9krion2004-03-122-3/+4 * - Update to version 0.8.9krion2004-03-122-2/+3 * Date: Wed, 10 Mar 2004 23:30:56 -0800 (PST)edwin2004-03-122-2/+2 * - Update to 0.99.7 [1]pav2004-03-024-55/+55 * - Mark BROKEN on AMD64krion2004-02-271-0/+4 * 1. Fix patch error.nobutaka2004-02-233-9/+8 * BROKEN on alpha: Does not compilekris2004-02-231-1/+7 * Don my portmgr hat and return dirk@FreeBSD.org's ports back to thekris2004-02-221-1/+1 * Utilize the EXPIRATION_DATE tag for these ports scheduled for removal.kris2004-02-221-1/+2 * BROKEN: Does not patchkris2004-02-161-0/+3 * BROKEN on 5.x: does not compilekris2004-02-091-1/+7 * Update to 2.3. No longer needs quite so many antique gcc files.linimon2004-02-088-144/+237 * Use PLIST_FILES (bento-tested, marcus-reviewed).trevor2004-02-0616-8/+8 * Bump PORTREVISION on all ports that depend on gettext to aid with upgrading.marcus2004-02-0419-1/+19 * Add USE_GETTEXT and bump PORTREVISION.marcus2004-02-042-6/+5 * Bump PORTREVISION for read-todos output format fix.olgeni2004-02-032-2/+2 * Follow portlint's suggestion about using MASTER_SITE_GENTOO.olgeni2004-02-032-2/+4 * Use LOCALBASE rather than hardcoded /usr/local.olgeni2004-02-032-2/+2 * Remove trailing whitespace (portlint).olgeni2004-02-032-2/+2 * The read-todos utility prints "No Date" when the todo item has noolgeni2004-02-032-0/+28 * SIZEify.trevor2004-01-303-0/+3 * Now gettext 0.12.1 is gettext-old.trevor2004-01-242-2/+2 * - Update to 1.6.2pav2004-01-222-4/+4 * Substitute BROKEN with IGNORE in cases where the port requires the src treemarcus2004-01-101-1/+1 * Add uppc-kmod, USB device driver for Windows CE handhelds which provides serialpav2003-12-305-0/+49 * o Upgrade to 5.0r3.kuriyama2003-12-283-213/+250 * - Update to 1.6.1pav2003-12-268-26/+40 * - Use canonical form (ports@FreeBSD.org) in MAINTAINER linesergei2003-12-211-1/+1 * - Add optional GTK2 support.pav2003-12-191-1/+7 * - Chase master sites (fix fetching)pav2003-12-192-2/+2 * Update pilot-link port to 0.11.8.silby2003-12-188-172/+24 * Add synce-trayicon, an icon for notification area displaying statisticspav2003-12-175-0/+37 * Add synce-gnomevfs, a GNOME2 VFS module giving gnome-vfs aware applicationspav2003-12-179-0/+71 * - Update to 0.8.1pav2003-12-173-3/+5 * - Update to 0.8.1pav2003-12-172-2/+2 * - Fix build on 5.xpav2003-11-222-9/+60 * Define USE_PERL5_BUILD, not erroneous USE_PERL.trevor2003-11-201-1/+1 * Define USE_PERL to make Perl available for (mostly deprecated)trevor2003-11-201-0/+1 * USE_REINPLACE need be defined only when REINPLACE_CMD is used.trevor2003-11-172-2/+0 * Fix pathname in patch file.olgeni2003-11-161-2/+2 * Use the FIND and XARGS macros introduced in bsd.port.mk 1.391.trevor2003-11-131-2/+2 * - update from 1.2 to 1.6jeh2003-11-096-265/+178 * Mark BROKEN (see bento logs). These ports are scheduled for removalkris2003-11-031-4/+2 * Reset maintainer on ports maintained by the following non-ports committers,kris2003-11-032-2/+2 * Remove the recursive assignment of SITE_PERL to ${SITE_PERL} introducederwin2003-10-241-1/+0 * utilize SITE_PERLijliao2003-10-243-45/+45 * Following up on Bill Fenner's reports, the original web site is gone,linimon2003-10-182-2/+4 * Before committing the previous BROKEN changes I carefully checked the statuskris2003-10-161-7/+1 * BROKEN on 5.x: does not compilekris2003-10-162-1/+11 * BROKEN on 5.x: does not compilekris2003-10-161-1/+7 * - Fix MASTER_SITESkrion2003-10-101-3/+3 * PERL => REINPLACEadamw2003-09-161-1/+4 * Remove two obsolete patches.arved2003-08-302-28/+0 * Update port version and related.erwin2003-08-283-5/+9 * Update port verion and related.erwin2003-08-284-10/+10 * Update to 0.8erwin2003-08-283-2/+5 * - Update to 0.8erwin2003-08-284-15/+15 * Bump the PORTREVISION for the ports directly affected by the gettext upgrade.marcus2003-08-272-0/+2 * sitescooper doesn't work with pluckeredwin2003-08-262-0/+14 * Chase the libintl.so shared lib version.marcus2003-08-252-2/+2 * reset maintainererwin2003-08-181-1/+1 * Previous commitment needs a PORTREVISION bump.daichi2003-08-181-0/+1 * patch palm/synce-serial:daichi2003-08-181-0/+11 * Remove these ports as part of phase II of the GNOME 1.4 desktop removal.marcus2003-08-1219-418/+0 * Updated to 3.35skv2003-08-082-3/+3 * Update to 0.31arved2003-08-014-63/+55 * Add rapip, a kio-slave that provides transparent filesystem access toarved2003-08-019-0/+127 * Add Librapi2, an open source implementation of Microsoft's Remotearved2003-08-015-0/+51 * Add synce-dccm, DCCM is a daemon that listens for connections fromarved2003-08-019-0/+73