diff options
author | nobody <nobody@localhost> | 2004-09-16 23:13:43 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2004-09-16 23:13:43 +0800 |
commit | 91b7c7ad502c36164a0a8ced6305e0d2efb030f5 (patch) | |
tree | 84f708d147f828d83167994109df8669680c32e8 /widgets | |
parent | 0a6ebcf09b23bfc9d4ca42112a4f4ddb8d6c9df9 (diff) | |
download | gsoc2013-evolution-GAL_2_2_2.tar.gz gsoc2013-evolution-GAL_2_2_2.tar.zst gsoc2013-evolution-GAL_2_2_2.zip |
This commit was manufactured by cvs2svn to create tag 'GAL_2_2_2'.GAL_2_2_2
svn path=/tags/GAL_2_2_2/; revision=27277
Diffstat (limited to 'widgets')
87 files changed, 0 insertions, 28968 deletions
diff --git a/widgets/.cvsignore b/widgets/.cvsignore deleted file mode 100644 index d5b3a2ad62..0000000000 --- a/widgets/.cvsignore +++ /dev/null @@ -1,9 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -minicard-test -minicard-label-test -reflow-test diff --git a/widgets/ChangeLog b/widgets/ChangeLog deleted file mode 100644 index 3154caedba..0000000000 --- a/widgets/ChangeLog +++ /dev/null @@ -1,134 +0,0 @@ -2004-09-13 Rodney Dawes <dobey@novell.com> - - * e-timezone-dialog/e-timezone-dialog.c (get_widgets): - (on_map_motion, on_map_leave, e_timezone_dialog_set_timezone): - * e-timezone-dialog/e-timezone-dialog.glade: - Add the label back for previewing the timezone name, and set the - label appropriately - - Fixes #64800 - -2004-08-17 Rodney Dawes <dobey@novell.com> - - * e-timezone-dialog/e-timezone-dialog.c (e_timezone_dialog_construct): - Connect to the "changed" signal instead of "activate" - - Fixes #62970 - -2004-06-22 Hans Petter Jansson <hpj@ximian.com> - - * misc/e-source-selector.c (e_source_selector_peek_primary_selection): - Add preconditions. Make sure garbage or NULL data doesn't get used. - -2004-06-11 Larry Ewing <lewing@ximian.com> - - * misc/e-source-selector.c: make the source selector use a colock - block instead of setting the foreground to indicate the source - color. - (pixbuf_cell_data_func): actually initialize the pixbuf (bad larry). - (pixbuf_cell_data_func): clean up warnings. (double bad larry). - (pixbuf_cell_data_func): fix the appearance a little. - -2004-05-20 Rodney Dawes <dobey@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c (e_timezone_dialog_construct): - Use the activate signal, instead of changed, for the combo box - (on_map_motion): Set the text in the combo's entry when we mouse over - one of the points on the map, as a preview for the timezone - (on_map_leave): Reset the combo's entry to the timezone we started with - when we leave the map - - Fixes #57122 - -2004-04-09 Rodney Dawes <dobey@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c - (e_timezone_dialog_construct): Set the border widths on the dialog's - vbox and action area to be HIG-complaint - Get rid of the timezone preview widget in here - Point the internal 'table' to the right widget - (on_map_motion): Get rid of the extra-hacky code to set the preview - widget's label to the timezone, now that that widget is gone - (on_map_leave): Update the comment to not reference the preview - widget that is now gone - Get rid of the code to set the preview widget's label to empty string - * e-timezone-dialog/e-timezone-dialog.glade: Update for HIG-compliance - -2004-02-26 JP Rosevear <jpr@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c - (e_timezone_dialog_dispose): don't reference uninitialized memory - -2003-12-16 Hans Petter Jansson <hpj@ximian.com> - - * misc/e-source-option-menu.c (select_source_foreach_menu_item): - Use e_source_equal() instead of comparing pointers. This allows user - to pass in a source that was obtained from somewhere else. Set the - matching internal source as "selected" instead of the one passed in. - (select_source): Emit signal only if we found a match. Don't ref/unref - anything, since the selected source will always be from our internal - list. - -2003-12-10 Not Zed <NotZed@Ximian.com> - - * menus/gal-view-menus.c (remove_instance): NULL out - priv->instance when we unref it. Bug #51713. - -2003-12-06 JP Rosevear <jpr@ximian.com> - - * */Makefile.am: Remove hard coded disable deprecated flags - -2003-11-07 JP Rosevear <jpr@ximian.com> - - * e-timezone-dialog/Makefile.am: don't include toplevel libical - -2003-11-07 JP Rosevear <jpr@ximian.com> - - * e-timezone-dialog/Makefile.am: use TZDIALOG_FLAGS - -2003-10-09 Jeffrey Stedfast <fejj@ximian.com> - - * e-timezone-dialog/Makefile.am: INCLUDE path fixes for changes - made to libical build. - - * e-timezone-dialog.h: #include <libical/ical.h> - -2003-09-19 Bolian Yin <bolian.yin@sun.com> - - Fixes #1245. ECalendar should be usable with the keyboard - - *misc/e-calendar-item.c (e_calendar_item_focus): new func, focus - handler. - (e_calendar_item_key_press_event): new func, key press event - handler - (e_calendar_item_selection_add_days, - e_calendar_item_stop_selecting): helpers. - (e_calendar_item_ensure_days_visible, - e_calendar_item_set_selection_if_emission): add the flag to - control if we should emit e-calendar signals. - (e_calendar_item_class_init): register focus handler. - (e_calendar_item_event): add code for GDK_FOCUS_CHANGE and - GDK_KEY_PRESS. - - *misc/e-calendar.c (e_calendar_focus): new func, focus handler - (e_calendar_button_has_focus): new func, if prev/next button has - focus. - (e_calendar_on_next_clicked, e_calendar_on_prev_clicked): click - signal handler for prev/next buttons. - (e_calendar_set_focusable): set if the e-calendar is focusable - - *misc/e-dateedit.c (e_date_edit_show_date_popup, hide_date_popup): - grab/ungrab gdk keyboard. - -2003-08-27 Hans Petter Jansson <hpj@ximian.com> - - Fixes #15638. - - * misc/e-dateedit.c (rebuild_time_popup): Make 12-hour time format - not be zero-padded. Right-align time labels so digits line up. - -2003-08-27 Bolian Yin <bolian.yin@sun.com> - - * misc/Makefile.am: add dependency on a11y/widgets. - * misc/e-calendar-item.c (e_calendar_item_class_init): a11y init. - (e_calendar_item_bounds): new func, impl the bounds virtual func. diff --git a/widgets/ChangeLog.pre-1-4 b/widgets/ChangeLog.pre-1-4 deleted file mode 100644 index 42bb1157ac..0000000000 --- a/widgets/ChangeLog.pre-1-4 +++ /dev/null @@ -1,506 +0,0 @@ -2003-05-19 Anna Marie Dirks <anna@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.glade: HIG-ified the - spacing, padding, alignment of this dialog. Fixes bug #41148 - -2003-05-16 Anna Marie Dirks <anna@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.glade: HIG-ified the - spacing, padding, alignment of this dialog. Fixes bug #41148 - -2003-05-14 JP Rosevear <jpr@ximian.com> - - * menus/gal-view-menus.c (gvm_finalize): unref the component - -2003-05-13 Ettore Perazzoli <ettore@ximian.com> - - * menus/gal-view-menus.c (gal_view_menus_unmerge): Guard against - the BonoboUIComponent not having a container to prevent a warning. - -2003-04-23 Jeffrey Stedfast <fejj@ximian.com> - - * menus/gal-view-menus.c (build_menus): Don't convert the label - charset from UTF-8 into the locale charset. - -2003-04-22 Anna Dirks <anna@ximian.com> - - * misc/e-multi-config-dialog.c : add appropriate padding and - spacing to the settings dialog. Fixes #41392. - -2003-04-10 Mike Kestner <mkestner@ximian.com> - - * menus/gal-view-menus.c (build menus): add ... to "Define Views" - and "Save Custom View" menuitem labels. - -2003-03-27 Ettore Perazzoli <ettore@ximian.com> - - * menus/gal-view-menus.c (set_state): Removed debugging message. - -2003-03-18 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.glade: Swap OK/Cancel - buttons to comply with the HIG. - -2003-03-17 Dan Winship <danw@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c (on_map_motion): Don't - crash if there's no timezone set initially. #39783 - -2003-03-11 Dan Winship <danw@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c: Various cleanups. - (e_timezone_dialog_get_timezone): Return an icaltimezone. - (e_timezone_dialog_set_timezone): Take an icaltimezone - (e_timezone_dialog_construct): Set a minimum size on the scrolled - window - -2003-03-06 Ettore Perazzoli <ettore@ximian.com> - - * menus/gal-view-menus.c (gal_view_menus_unmerge): Use - G_GNUC_FUNCTION instead of __FUNCTION__. - -2003-02-20 Dan Winship <danw@ximian.com> - - * e-timezone-dialog/Makefile.am: Make this a dynamic lib rather - than static so it can be portably linked into the shlib - components. - -2003-02-06 Dan Winship <danw@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.glade: Set response_ids on - the OK/Cancel buttons - -2003-02-05 Dan Winship <danw@ximian.com> - - * e-timezone-dialog/Makefile.am (INCLUDES): Remove unneeded - MAP_DIR define. - (gladedir): Remove. Defined in configure.in now. - - * menus/gal-view-menus.c: #include <string.h> - -2003-01-22 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/Makefile.am (gladedir): Version using - $(BASE_VERSION). - (INCLUDES): Update the MAP_DIR define with versioning. - -2003-01-08 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/Makefile.am: Images are now in - $(datadir)/evolution/images instead of - $(datadir)/images/evolution. - -2002-11-14 Chris Toshok <toshok@ximian.com> - - * menus/gal-view-menus.c (define_views): use GtkDialog's - ::response instead of GnomeDialog's ::clicked. - (dialog_response): use response id's. - (gvm_finalize): fix warning. - -2002-11-13 Ettore Perazzoli <ettore@ximian.com> - - * menus/gal-view-menus.h - * menus/gal-view-menus.c: GObjectified. - - * e-timezone-dialog/e-timezone-dialog.h - * e-timezone-dialog/e-timezone-dialog.c: GObjectified. - -2002-11-13 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c - (e_timezone_dialog_destroy): g_object_unref() instead of - gtk_object_unref() on the GladeXML object. - (e_timezone_dialog_construct): Likewise on the ETimezoneDialog - object. - -2002-11-13 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.glade: Converted to Glade 2. - -2002-11-13 Not Zed <NotZed@Ximian.com> - - * menus/gal-view-menus.c: gnome-xml->libxml - - * menus/gal-view-menus.h: gnome-xml->libxml - -2002-11-03 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c - (e_timezone_dialog_get_builtin_timezone): Constify arg - display_name. - -2002-11-01 Ettore Perazzoli <ettore@ximian.com> - - * menus/gal-view-menus.c (build_stuff): Add some casts. - -2002-10-30 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c - (e_timezone_dialog_construct): Pass NULL as the domain arg to - glade_xml_new(). - (e_timezone_dialog_get_timezone): Make arg display_name const. - (find_selected_point): Constify local variable timezone. - - * e-timezone-dialog/e-timezone-dialog.h: Do not #include - <libgnome/gnome-defs.h>. - -2002-08-15 Mike Kestner <mkestner@ximian.com> - - * menus/gal-view-menus.c (build_stuff): ref/unref the gvm - -2002-07-09 Peter Williams <peterw@ximian.com> - - * e-timezone-dialog/Makefile.am: Add -I$(top_builddir)/libical/src/libical; - some headers that we rely on get installed, so they point to the ical.h that - gets generated and installed; consequently we need to be able to find the - generated ical.h - - * misc/Makefile.am: Install libemiscwidgets.a and its headers. However, - break EFilterBar into a separate libefilterbar.a because we don't want - the installed library to depend on libfilter. - -2002-07-05 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.c (e_timezone_dialog_init): - Make not floating. - -2002-06-04 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c, menus/gal-view-menus.h - (gal_view_menus_set_show_define_views): Added this function to let - you disable the define views dialog. - -2002-06-04 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c (define_views): Don't show this dialog - more than once per collection. - -2002-05-14 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c (build_menus): Made it so that if the - current_id doesn't match any of the given ids, it treats it the - same as a NULL id. - (gal_view_menus_apply): Added a check for gvm->priv == NULL here. - (gal_view_menus_apply, collection_changed, instance_changed): - Removed calls to set_radio after build_stuff, since the last thing - build_stuff does is calls set_radio. - -2002-02-27 Larry Ewing <lewing@ximian.com> - - * misc/e-combo-button.c (impl_button_press_event): make a right - click bring up the popup menu. - -2002-02-07 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c, menus/gal-view-menus.h - (gal_view_menus_unmerge): New function to handle unmerging menus - at control deactivation time. - (d): Turned off debugging output here. - (build_menus): Gave the separators names and marked them with f="" - to make them work better with bonobo 1. - -2002-02-07 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c, menus/gal-view-menus.h - (gal_view_menus_new): Made this take a GalViewInstance instead of - a GalViewCollection. Reworked most of this to utilize the - interfaces provided by GalViewInstance. - -2002-01-27 Ettore Perazzoli <ettore@ximian.com> - - * menus/Makefile.am: Use `GNOME_FULL_CFLAGS'. - -2002-01-11 Damon Chaplin <damon@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.[hc]: translate timezone names, - and provide a function to get back to the English version. - -2001-10-24 Jon Trowbridge <trow@ximian.com> - - * menus/gal-view-menus.c (gal_view_menus_apply): Ref the - BonoboUIComponent that we are holding. - (gvm_destroy): Unref our BonoboUIComponent. - -2001-10-21 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c: Make this not be a radio button, but - instead just a normal menu. - -2001-10-18 Jeffrey Stedfast <fejj@ximian.com> - - * menus/gal-view-menus.c: #include bonobo-ui-util.h - -2001-10-04 Rodrigo Moya <rodrigo@ximian.com> - - * misc/Makefile.am: - * menus/Makefile.am: added BONOBO_GNOME_CFLAGS to make it compile - with latest Bonobo - -2001-09-19 JP Rosevear <jpr@ximian.com> - - * Makefile.am: the meeting-time-sel dir is dead, relevant pieces - moved to calendar/gui - -2001-08-26 Zbigniew Chyla <cyba@gnome.pl> - - Fixes #2465 - - * menus/gal-view-menus.c (build_menus): - Encode the label using bonobo_ui_util_encode_str and set "label" - attribute, not "_label". - I have no idea what the previous code was trying to do but it was - definitely wrong. - -2001-08-27 Ettore Perazzoli <ettore@ximian.com> - - * e-timezone-dialog/e-timezone-dialog.h - (e_timezone_dialog_reparent): New prototype here. - -2001-08-27 Iain Holmes <iain@ximian.com> - - * e-timezone-dialog/e-timezone.h: Add a prototype for - e_timezone_dialog_reparent - -2001-08-18 Iain Holmes <iain@ximian.com> - - * Makefile.am: Add the e-timezone-dialog dir. - - * e-timezone-dialog/*: Add new files. - -2001-08-10 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c (build_menus): Don't display the Define - Views dialog. - -2001-07-02 Anna Marie Dirks <anna@ximian.com> - - * misc/e-filter-bar.c (option_changed): Specified a default size - for the Advanced Search dialog such that when it first appear, it - is large enough to view all parts of a search clause without the - user needing to resize it. - -2001-05-31 Federico Mena Quintero <federico@ximian.com> - - * menus/gal-view-menus.c (gal_view_menus_construct): Store the - connection ID of the "changed" signal in the collection. - (gal_view_menus_new): Added preconditions. - (gal_view_menus_construct): Added preconditions. - -2001-05-21 Chris Toshok <toshok@ximian.com> - - * menus/gal-view-menus.c (build_menus): make the view menuitems - radio items of the same group, and allocate the closure here. - (free_verbs): only need to free the one DefineViews verb here. - (closure_free): new function - EListFreeFunc for our - listenerClosure list. - (remove_listeners): new function, free our listener list. - (gvm_destroy): call remove_listeners. - (gvm_init): init listenerClosures list. - (toggled_cb): callback for radio items. - (build_verbs): strip out almost all the code since there's only 1 - verb now. - (build_stuff): call remove_listeners. - -2001-05-08 Gediminas Paulauskas <menesis@delfi.lt> - - * misc/e-search-bar.c (add_dropdown), (set_option): first try to - translate, then if not suceeded -- convert from utf8. This handles - cases when menuitem needs to be translated (it is passed as N_()), or is - utf8 search title. However you cannot have a search like "Folders" -- it - is translated. Part of fix for #2253. - - * misc/e-filter-bar.c: d() debugging strings. Use E_FILTERBAR_ADVANCED - macro instead of own "Advanced ..." for consistency. - -2001-05-07 Gediminas Paulauskas <menesis@delfi.lt> - - * menus/gal-view-menus.c (build_menus): convert label to locale - encoding. Still displays truncated strings. - - * menus/Makefile.am: removed -DEVOLUTION_VERSION. - -2001-04-21 Gediminas Paulauskas <menesis@delfi.lt> - - * menus/gal-view-menus.c: bonobo_ui_node_set_attr expects unstranslated - strings, so change _() to N_(). - -2001-04-12 Dan Winship <danw@ximian.com> - - * menus/gal-view-menus.c (build_menus): Fix a memory leak. - (Doesn't anyone ever change any other file in this directory? :) - -2001-04-10 Gediminas Paulauskas <menesis@delfi.lt> - - * menus/gal-view-menus.c: convert label to utf8. - -2001-04-04 Kjartan Maraas <kmaraas@gnome.org> - - * menus/gal-view-menus.c: Fix headers. - -2001-03-28 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c (build_menus): Don't print the xml tree - here. - -2001-03-16 Miguel de Icaza <miguel@ximian.com> - - * menus/gal-view-menus.c (build_menus): Hook this up under the - "ViewBegin" node. - -2001-02-28 Miguel de Icaza <miguel@ximian.com> - - * menus/gal-view-menus.c (build_menus): Add translation string - here. - -2001-03-05 Christopher James Lahey <clahey@ximian.com> - - * menus/gal-view-menus.c (collection_changed): Rebuild when the - collection changes. - -2001-01-27 Jason Leach <jasonleach@usa.net> - - * cvs remove all files in shortcut-bar/, this widget is now in - gal, will be maintained there. - - * Makefile.am (SUBDIRS): Remove shortcut-bar from here. - -2001-01-25 Christopher James Lahey <clahey@helixcode.com> - - * menus/gal-view-menus.c: Make this actually deploy the titles - from the GalViewCollection and emit the display_view signals and - such. - -2001-01-22 Jon Trowbridge <trow@gnu.org> - - * menus/gal-view-menus.c (define_views): Fixed - gal_define_views_dialog_new to be called with its proper argument. - -2000-12-06 Christopher James Lahey <clahey@helixcode.com> - - * menus/gal-view-menus.c, menus/gal-view-menus.h: Added a - GalViewCollection argument to the new function here. - -2000-12-04 Dan Winship <danw@helixcode.com> - - * menus/gal-view-menus.c: NULL-terminate gal_view_menus_apply's - BonoboUIVerb array to prevent a crash. (Why are there gal* things - in the evolution sources?) - -2000-11-05 Christopher James Lahey <clahey@helixcode.com> - - * e-paned/.cvsignore, e-table/.cvsignore, e-text/.cvsignore: - Removed unnecessary .cvsignore files. - -2000-09-18 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Removed directories that have been moved to gal. - - * e-paned/.cvsignore, e-paned/Makefile.am, e-paned/e-hpaned.c, - e-paned/e-hpaned.h, e-paned/e-paned.c, e-paned/e-paned.h, - e-paned/e-vpaned.c, e-paned/e-vpaned.h: Moved to gal. - - * e-reflow/.cvsignore, e-reflow/Makefile.am, - e-reflow/e-reflow-sorted.c, e-reflow/e-reflow-sorted.h, - e-reflow/e-reflow.c, e-reflow/e-reflow.h: Moved to gal. - - * e-table/.cvsignore, e-table/ChangeLog, e-table/LICENSE, - e-table/Makefile.am, e-table/ROADMAP.e-table, e-table/TODO, - e-table/add-col.xpm, e-table/arrow-down.xpm, e-table/arrow-up.xpm, - e-table/check-empty.xpm, e-table/check-filled.xpm, - e-table/clip.png, e-table/e-cell-checkbox.c, - e-table/e-cell-checkbox.h, e-table/e-cell-string.c, - e-table/e-cell-text.c, e-table/e-cell-text.h, - e-table/e-cell-toggle.c, e-table/e-cell-toggle.h, - e-table/e-cell-tree.c, e-table/e-cell-tree.h, e-table/e-cell.c, - e-table/e-cell.h, e-table/e-table-click-to-add.c, - e-table/e-table-click-to-add.h, e-table/e-table-col-dnd.h, - e-table/e-table-col.c, e-table/e-table-col.h, - e-table/e-table-column-model.h, e-table/e-table-column.c, - e-table/e-table-config.c, e-table/e-table-config.glade, - e-table/e-table-config.glade.h, e-table/e-table-config.h, - e-table/e-table-defines.h, e-table/e-table-example-1.c, - e-table/e-table-example-2.c, - e-table/e-table-field-chooser-dialog.c, - e-table/e-table-field-chooser-dialog.h, - e-table/e-table-field-chooser-item.c, - e-table/e-table-field-chooser-item.h, - e-table/e-table-field-chooser.c, - e-table/e-table-field-chooser.glade, - e-table/e-table-field-chooser.glade.h, - e-table/e-table-field-chooser.h, - e-table/e-table-group-container.c, - e-table/e-table-group-container.h, e-table/e-table-group-leaf.c, - e-table/e-table-group-leaf.h, e-table/e-table-group.c, - e-table/e-table-group.glade, e-table/e-table-group.glade.h, - e-table/e-table-group.h, e-table/e-table-header-item.c, - e-table/e-table-header-item.h, e-table/e-table-header.c, - e-table/e-table-header.h, e-table/e-table-item.c, - e-table/e-table-item.h, e-table/e-table-model.c, - e-table/e-table-model.h, e-table/e-table-one.c, - e-table/e-table-one.h, e-table/e-table-scrolled.c, - e-table/e-table-scrolled.h, e-table/e-table-selection-model.c, - e-table/e-table-selection-model.h, e-table/e-table-simple.c, - e-table/e-table-simple.h, e-table/e-table-size-test.c, - e-table/e-table-sort-info.c, e-table/e-table-sort-info.h, - e-table/e-table-sorted-variable.c, - e-table/e-table-sorted-variable.h, e-table/e-table-sorted.c, - e-table/e-table-sorted.h, e-table/e-table-sorter.c, - e-table/e-table-sorter.h, e-table/e-table-subset-variable.c, - e-table/e-table-subset-variable.h, e-table/e-table-subset.c, - e-table/e-table-subset.h, e-table/e-table-text-model.c, - e-table/e-table-text-model.h, e-table/e-table-tooltip.h, - e-table/e-table-tree.h, e-table/e-table.c, e-table/e-table.h, - e-table/e-tree-example-1.c, e-table/e-tree-example-2.c, - e-table/e-tree-model.c, e-table/e-tree-model.h, - e-table/e-tree-simple.c, e-table/e-tree-simple.h, - e-table/image1.png, e-table/image2.png, e-table/image3.png, - e-table/remove-col.xpm, e-table/sample.table, - e-table/table-test.c, e-table/table-test.h, e-table/test-check.c, - e-table/test-cols.c, e-table/test-table.c: Moved to gal. - - * e-text/.cvsignore, e-text/Makefile.am, e-text/e-entry-test.c, - e-text/e-entry.c, e-text/e-entry.h, - e-text/e-text-event-processor-emacs-like.c, - e-text/e-text-event-processor-emacs-like.h, - e-text/e-text-event-processor-types.h, - e-text/e-text-event-processor.c, e-text/e-text-event-processor.h, - e-text/e-text-model.c, e-text/e-text-model.h, - e-text/e-text-test.c, e-text/e-text.c, e-text/e-text.h: Moved to - gal. - -2000-09-14 Michael Meeks <michael@helixcode.com> - - * e-reflow/e-reflow-sorted.h: fix include. - -2000-09-13 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am (SUBDIRS): Added e-reflow. - - * e-reflow/e-reflow.c, e-reflow/e-reflow.h: Moved from - addressbook/gui/minicard/. - - * e-reflow/Makefile.am, e-reflow/.cvsignore: New files for a new - directory. - -2000-09-08 Lauris Kaplinski <lauris@helixcode.com> - - * e-text/e-text.c (calc_line_widths): Fix byte/char confusion - -2000-08-30 Federico Mena Quintero <federico@helixcode.com> - - * e-paned/e-hpaned.c (e_hpaned_motion): Do not flicker while - trying to resize a quantized pane. - - * e-paned/e-vpaned.c (e_vpaned_motion): Likewise. - -2000-08-30 Federico Mena Quintero <federico@helixcode.com> - - * widgets/e-paned/e-vpaned.c (e_vpaned_size_allocate): Ensure that - the child's allocation height is >= 1. - - * widgets/e-paned/e-hpaned.c (e_hpaned_size_allocate): Ensure that - the child's allocation width is >= 1. - -2000-08-30 Federico Mena Quintero <federico@helixcode.com> - - * ChangeLog: Started a ChangeLog here. diff --git a/widgets/LICENSE b/widgets/LICENSE deleted file mode 100644 index b1f6ae08a4..0000000000 --- a/widgets/LICENSE +++ /dev/null @@ -1 +0,0 @@ -This code is released under the terms of the GNU GPL. diff --git a/widgets/Makefile.am b/widgets/Makefile.am deleted file mode 100644 index 4154550db6..0000000000 --- a/widgets/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ - -SUBDIRS = \ - e-timezone-dialog \ - misc \ - menus - -EXTRA_DIST = \ - ChangeLog.pre-1-4 diff --git a/widgets/e-timezone-dialog/.cvsignore b/widgets/e-timezone-dialog/.cvsignore deleted file mode 100644 index d6c55c7345..0000000000 --- a/widgets/e-timezone-dialog/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la diff --git a/widgets/e-timezone-dialog/Makefile.am b/widgets/e-timezone-dialog/Makefile.am deleted file mode 100644 index ed4502a080..0000000000 --- a/widgets/e-timezone-dialog/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DG_LOG_DOMAIN=__FILE__ \ - $(TZDIALOG_CFLAGS) - -noinst_LTLIBRARIES = \ - libetimezonedialog.la - -libetimezonedialog_la_SOURCES = \ - e-timezone-dialog.c \ - e-timezone-dialog.h - -glade_DATA = e-timezone-dialog.glade - -EXTRA_DIST = $(glade_DATA) diff --git a/widgets/e-timezone-dialog/e-timezone-dialog.c b/widgets/e-timezone-dialog/e-timezone-dialog.c deleted file mode 100644 index 19a5685b38..0000000000 --- a/widgets/e-timezone-dialog/e-timezone-dialog.c +++ /dev/null @@ -1,678 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Evolution calendar - Timezone selector dialog - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Damon Chaplin <damon@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#include <config.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkcombo.h> -#include <gtk/gtkentry.h> -#include <gtk/gtklabel.h> -#include <gnome.h> -#include <glade/glade.h> -#include <widgets/misc/e-map.h> - -#include "e-timezone-dialog.h" - -#include <gal/util/e-util.h> - -#define E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA 0xc070a0ff -#define E_TIMEZONE_DIALOG_MAP_POINT_HOVER_RGBA 0xffff60ff -#define E_TIMEZONE_DIALOG_MAP_POINT_SELECTED_1_RGBA 0xff60e0ff -#define E_TIMEZONE_DIALOG_MAP_POINT_SELECTED_2_RGBA 0x000000ff - -struct _ETimezoneDialogPrivate { - /* The selected timezone. May be NULL for a 'local time' (i.e. when - the displayed name is ""). */ - icaltimezone *zone; - - /* Glade XML data */ - GladeXML *xml; - - EMapPoint *point_selected; - EMapPoint *point_hover; - - EMap *map; - - /* The timeout used to flash the nearest point. */ - guint timeout_id; - - /* Widgets from the Glade file */ - GtkWidget *app; - GtkWidget *table; - GtkWidget *map_window; - GtkWidget *timezone_combo; - GtkWidget *preview_label; -}; - - -static void e_timezone_dialog_class_init (ETimezoneDialogClass *class); -static void e_timezone_dialog_init (ETimezoneDialog *etd); -static void e_timezone_dialog_dispose (GObject *object); -static void e_timezone_dialog_finalize (GObject *object); - -static gboolean get_widgets (ETimezoneDialog *etd); -static gboolean on_map_timeout (gpointer data); -static gboolean on_map_motion (GtkWidget *widget, - GdkEventMotion *event, - gpointer data); -static gboolean on_map_leave (GtkWidget *widget, - GdkEventCrossing *event, - gpointer data); -static gboolean on_map_visibility_changed (GtkWidget *w, - GdkEventVisibility *event, - gpointer data); -static gboolean on_map_button_pressed (GtkWidget *w, - GdkEventButton *event, - gpointer data); - -static icaltimezone* get_zone_from_point (ETimezoneDialog *etd, - EMapPoint *point); -static void set_map_timezone (ETimezoneDialog *etd, - icaltimezone *zone); -static void on_combo_changed (GtkEditable *entry, - ETimezoneDialog *etd); - - -static GObjectClass *parent_class; - - -/* Class initialization function for the event editor */ -static void -e_timezone_dialog_class_init (ETimezoneDialogClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - object_class->dispose = e_timezone_dialog_dispose; - object_class->finalize = e_timezone_dialog_finalize; - - parent_class = gtk_type_class (G_TYPE_OBJECT); -} - -/* Object initialization function for the event editor */ -static void -e_timezone_dialog_init (ETimezoneDialog *etd) -{ - ETimezoneDialogPrivate *priv; - - priv = g_new0 (ETimezoneDialogPrivate, 1); - etd->priv = priv; - - priv->point_selected = NULL; - priv->point_hover = NULL; - priv->timeout_id = 0; -} - -/* Dispose handler for the event editor */ -static void -e_timezone_dialog_dispose (GObject *object) -{ - ETimezoneDialog *etd; - ETimezoneDialogPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_TIMEZONE_DIALOG (object)); - - etd = E_TIMEZONE_DIALOG (object); - priv = etd->priv; - - /* Destroy the actual dialog. */ - if (priv->app != NULL) { - gtk_widget_destroy (priv->app); - priv->app = NULL; - } - - if (priv->timeout_id) { - g_source_remove (priv->timeout_id); - priv->timeout_id = 0; - } - - if (priv->xml) { - g_object_unref (priv->xml); - priv->xml = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* Finalize handler for the event editor */ -static void -e_timezone_dialog_finalize (GObject *object) -{ - ETimezoneDialog *etd; - ETimezoneDialogPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_TIMEZONE_DIALOG (object)); - - etd = E_TIMEZONE_DIALOG (object); - priv = etd->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -e_timezone_dialog_add_timezones (ETimezoneDialog *etd) -{ - ETimezoneDialogPrivate *priv; - icalarray *zones; - GtkWidget *listitem; - GtkCombo *combo; - int i; - - priv = etd->priv; - - combo = GTK_COMBO (priv->timezone_combo); - - /* Clear any existing items in the combo. */ - gtk_list_clear_items (GTK_LIST (combo->list), 0, -1); - - /* Put the "None" and "UTC" entries at the top of the combo's list. - When "None" is selected we want the field to be cleared. */ - listitem = gtk_list_item_new_with_label (_("None")); - gtk_combo_set_item_string (combo, GTK_ITEM (listitem), ""); - gtk_widget_show (listitem); - gtk_container_add (GTK_CONTAINER (combo->list), listitem); - - listitem = gtk_list_item_new_with_label (_("UTC")); - gtk_widget_show (listitem); - gtk_container_add (GTK_CONTAINER (combo->list), listitem); - - /* Get the array of builtin timezones. */ - zones = icaltimezone_get_builtin_timezones (); - - for (i = 0; i < zones->num_elements; i++) { - icaltimezone *zone; - char *location; - - zone = icalarray_element_at (zones, i); - - location = _(icaltimezone_get_location (zone)); - - e_map_add_point (priv->map, location, - icaltimezone_get_longitude (zone), - icaltimezone_get_latitude (zone), - E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA); - - listitem = gtk_list_item_new_with_label (location); - gtk_widget_show (listitem); - gtk_container_add (GTK_CONTAINER (combo->list), listitem); - } -} - - -ETimezoneDialog * -e_timezone_dialog_construct (ETimezoneDialog *etd) -{ - ETimezoneDialogPrivate *priv; - GtkWidget *map; - - g_return_val_if_fail (etd != NULL, NULL); - g_return_val_if_fail (E_IS_TIMEZONE_DIALOG (etd), NULL); - - priv = etd->priv; - - /* Load the content widgets */ - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/e-timezone-dialog.glade", NULL, NULL); - if (!priv->xml) { - g_message ("e_timezone_dialog_construct(): Could not load the Glade XML file!"); - goto error; - } - - if (!get_widgets (etd)) { - g_message ("e_timezone_dialog_construct(): Could not find all widgets in the XML file!"); - goto error; - } - - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (priv->app)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (priv->app)->action_area), 12); - - priv->map = e_map_new (); - map = GTK_WIDGET (priv->map); - gtk_widget_set_events (map, gtk_widget_get_events (map) - | GDK_LEAVE_NOTIFY_MASK - | GDK_VISIBILITY_NOTIFY_MASK); - - gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry), FALSE); - - e_timezone_dialog_add_timezones (etd); - - gtk_container_add (GTK_CONTAINER (priv->map_window), map); - gtk_widget_show (map); - - /* Ensure a reasonable minimum amount of map is visible */ - gtk_widget_set_size_request (priv->map_window, 200, 200); - - g_signal_connect (map, "motion-notify-event", G_CALLBACK (on_map_motion), etd); - g_signal_connect (map, "leave-notify-event", G_CALLBACK (on_map_leave), etd); - g_signal_connect (map, "visibility-notify-event", G_CALLBACK (on_map_visibility_changed), etd); - g_signal_connect (map, "button-press-event", G_CALLBACK (on_map_button_pressed), etd); - - g_signal_connect (GTK_COMBO (priv->timezone_combo)->entry, "changed", G_CALLBACK (on_combo_changed), etd); - - return etd; - - error: - - g_object_unref (etd); - return NULL; -} - -/* Gets the widgets from the XML file and returns if they are all available. - * For the widgets whose values can be simply set with e-dialog-utils, it does - * that as well. - */ -static gboolean -get_widgets (ETimezoneDialog *etd) -{ - ETimezoneDialogPrivate *priv; - - priv = etd->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - priv->app = GW ("timezone-dialog"); - priv->map_window = GW ("map-window"); - priv->timezone_combo = GW ("timezone-combo"); - priv->table = GW ("timezone-table"); - priv->preview_label = GW ("preview-label"); - - return (priv->app - && priv->map_window - && priv->timezone_combo - && priv->table - && priv->preview_label); -} - - -/** - * e_timezone_dialog_new: - * - * Creates a new event editor dialog. - * - * Return value: A newly-created event editor dialog, or NULL if the event - * editor could not be created. - **/ -ETimezoneDialog * -e_timezone_dialog_new (void) -{ - ETimezoneDialog *etd; - - etd = E_TIMEZONE_DIALOG (g_object_new (E_TYPE_TIMEZONE_DIALOG, NULL)); - return e_timezone_dialog_construct (E_TIMEZONE_DIALOG (etd)); -} - -static const char * -zone_display_name (icaltimezone *zone) -{ - const char *display_name; - - display_name = icaltimezone_get_display_name (zone); - if (icaltimezone_get_builtin_timezone (display_name)) - display_name = _(display_name); - - return display_name; -} - - -/* This flashes the currently selected timezone in the map. */ -static gboolean -on_map_timeout (gpointer data) -{ - ETimezoneDialog *etd; - ETimezoneDialogPrivate *priv; - - etd = E_TIMEZONE_DIALOG (data); - priv = etd->priv; - - if (!priv->point_selected) - return TRUE; - - if (e_map_point_get_color_rgba (priv->point_selected) - == E_TIMEZONE_DIALOG_MAP_POINT_SELECTED_1_RGBA) - e_map_point_set_color_rgba (priv->map, priv->point_selected, - E_TIMEZONE_DIALOG_MAP_POINT_SELECTED_2_RGBA); - else - e_map_point_set_color_rgba (priv->map, priv->point_selected, - E_TIMEZONE_DIALOG_MAP_POINT_SELECTED_1_RGBA); - - return TRUE; -} - - -static gboolean -on_map_motion (GtkWidget *widget, GdkEventMotion *event, gpointer data) -{ - ETimezoneDialog *etd; - ETimezoneDialogPrivate *priv; - double longitude, latitude; - icaltimezone *new_zone; - - etd = E_TIMEZONE_DIALOG (data); - priv = etd->priv; - - e_map_window_to_world (priv->map, (double) event->x, (double) event->y, - &longitude, &latitude); - - if (priv->point_hover && priv->point_hover != priv->point_selected) - e_map_point_set_color_rgba (priv->map, priv->point_hover, - E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA); - - priv->point_hover = e_map_get_closest_point (priv->map, longitude, - latitude, TRUE); - - if (priv->point_hover != priv->point_selected) - e_map_point_set_color_rgba (priv->map, priv->point_hover, - E_TIMEZONE_DIALOG_MAP_POINT_HOVER_RGBA); - - new_zone = get_zone_from_point (etd, priv->point_hover); - - gtk_label_set_text (GTK_LABEL (priv->preview_label), - zone_display_name (new_zone)); - - return TRUE; -} - - -static gboolean -on_map_leave (GtkWidget *widget, GdkEventCrossing *event, gpointer data) -{ - ETimezoneDialog *etd; - ETimezoneDialogPrivate *priv; - - etd = E_TIMEZONE_DIALOG (data); - priv = etd->priv; - - /* We only want to reset the hover point if this is a normal leave - event. For some reason we are getting leave events when the - button is pressed in the map, which causes problems. */ - if (event->mode != GDK_CROSSING_NORMAL) - return FALSE; - - if (priv->point_hover && priv->point_hover != priv->point_selected) - e_map_point_set_color_rgba (priv->map, priv->point_hover, - E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA); - - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry), - zone_display_name (priv->zone)); - gtk_label_set_text (GTK_LABEL (priv->preview_label), ""); - - priv->point_hover = NULL; - - return FALSE; -} - - -static gboolean -on_map_visibility_changed (GtkWidget *w, GdkEventVisibility *event, - gpointer data) -{ - ETimezoneDialog *etd; - ETimezoneDialogPrivate *priv; - - etd = E_TIMEZONE_DIALOG (data); - priv = etd->priv; - - if (event->state != GDK_VISIBILITY_FULLY_OBSCURED) { - /* Map is visible, at least partly, so make sure we flash the - selected point. */ - if (!priv->timeout_id) - priv->timeout_id = gtk_timeout_add (100, on_map_timeout, etd); - } else { - /* Map is invisible, so don't waste resources on the timeout.*/ - if (priv->timeout_id) { - g_source_remove (priv->timeout_id); - priv->timeout_id = 0; - } - } - - return FALSE; -} - - -static gboolean -on_map_button_pressed (GtkWidget *w, GdkEventButton *event, gpointer data) -{ - ETimezoneDialog *etd; - ETimezoneDialogPrivate *priv; - double longitude, latitude; - - etd = E_TIMEZONE_DIALOG (data); - priv = etd->priv; - - e_map_window_to_world (priv->map, (double) event->x, (double) event->y, - &longitude, &latitude); - - if (event->button != 1) { - e_map_zoom_out (priv->map); - } else { - if (e_map_get_magnification (priv->map) <= 1.0) - e_map_zoom_to_location (priv->map, longitude, - latitude); - - if (priv->point_selected) - e_map_point_set_color_rgba (priv->map, - priv->point_selected, - E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA); - priv->point_selected = priv->point_hover; - - priv->zone = get_zone_from_point (etd, priv->point_selected); - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry), - zone_display_name (priv->zone)); - } - - return TRUE; -} - - -/* Returns the translated timezone location of the given EMapPoint, - e.g. "Europe/London". */ -static icaltimezone * -get_zone_from_point (ETimezoneDialog *etd, - EMapPoint *point) -{ - ETimezoneDialogPrivate *priv; - icalarray *zones; - double longitude, latitude; - int i; - - priv = etd->priv; - - if (point == NULL) - return NULL; - - e_map_point_get_location (point, &longitude, &latitude); - - /* Get the array of builtin timezones. */ - zones = icaltimezone_get_builtin_timezones (); - - for (i = 0; i < zones->num_elements; i++) { - icaltimezone *zone; - double zone_longitude, zone_latitude; - - zone = icalarray_element_at (zones, i); - zone_longitude = icaltimezone_get_longitude (zone); - zone_latitude = icaltimezone_get_latitude (zone); - - if (zone_longitude - 0.005 <= longitude && - zone_longitude + 0.005 >= longitude && - zone_latitude - 0.005 <= latitude && - zone_latitude + 0.005 >= latitude) - { - return zone; - } - } - - g_assert_not_reached (); - - return NULL; -} - - -/** - * e_timezone_dialog_get_timezone: - * @etd: the timezone dialog - * - * Return value: the currently-selected timezone, or %NULL if no timezone - * is selected. - **/ -icaltimezone * -e_timezone_dialog_get_timezone (ETimezoneDialog *etd) -{ - ETimezoneDialogPrivate *priv; - - g_return_val_if_fail (E_IS_TIMEZONE_DIALOG (etd), NULL); - - priv = etd->priv; - - return priv->zone; -} - -/** - * e_timezone_dialog_set_timezone: - * @etd: the timezone dialog - * @zone: the timezone - * - * Sets the timezone of @etd to @zone. Updates the display name and - * selected location. The caller must ensure that @zone is not freed - * before @etd is destroyed. - **/ -void -e_timezone_dialog_set_timezone (ETimezoneDialog *etd, - icaltimezone *zone) -{ - ETimezoneDialogPrivate *priv; - - g_return_if_fail (E_IS_TIMEZONE_DIALOG (etd)); - - priv = etd->priv; - - priv->zone = zone; - - gtk_label_set_text (GTK_LABEL (priv->preview_label), - zone ? zone_display_name (zone) : ""); - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry), - zone ? zone_display_name (zone) : ""); - - set_map_timezone (etd, zone); -} - - -GtkWidget * -e_timezone_dialog_get_toplevel (ETimezoneDialog *etd) -{ - ETimezoneDialogPrivate *priv; - - g_return_val_if_fail (etd != NULL, NULL); - g_return_val_if_fail (E_IS_TIMEZONE_DIALOG (etd), NULL); - - priv = etd->priv; - - return priv->app; -} - - -static void -set_map_timezone (ETimezoneDialog *etd, icaltimezone *zone) -{ - ETimezoneDialogPrivate *priv; - EMapPoint *point; - double zone_longitude, zone_latitude; - - priv = etd->priv; - - if (zone) { - zone_longitude = icaltimezone_get_longitude (zone); - zone_latitude = icaltimezone_get_latitude (zone); - point = e_map_get_closest_point (priv->map, - zone_longitude, - zone_latitude, - FALSE); - } else - point = NULL; - - if (priv->point_selected) - e_map_point_set_color_rgba (priv->map, priv->point_selected, - E_TIMEZONE_DIALOG_MAP_POINT_NORMAL_RGBA); - - priv->point_selected = point; -} - - -static void -on_combo_changed (GtkEditable *entry, ETimezoneDialog *etd) -{ - ETimezoneDialogPrivate *priv; - const char *new_zone_name; - icalarray *zones; - icaltimezone *map_zone = NULL; - char *location; - int i; - - priv = etd->priv; - - new_zone_name = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (priv->timezone_combo)->entry)); - - if (!*new_zone_name) - priv->zone = NULL; - else if (!strcmp (new_zone_name, _("UTC"))) - priv->zone = icaltimezone_get_utc_timezone (); - else { - priv->zone = NULL; - - zones = icaltimezone_get_builtin_timezones (); - for (i = 0; i < zones->num_elements; i++) { - map_zone = icalarray_element_at (zones, i); - location = _(icaltimezone_get_location (map_zone)); - if (!strcmp (new_zone_name, location)) { - priv->zone = map_zone; - break; - } - } - } - - set_map_timezone (etd, map_zone); -} - -/** - * e_timezone_dialog_reparent: - * @etd: #ETimezoneDialog. - * @new_parent: The new parent widget. - * - * Takes the internal widgets out of the dialog and put them into @new_parent - */ -void -e_timezone_dialog_reparent (ETimezoneDialog *etd, - GtkWidget *new_parent) -{ - ETimezoneDialogPrivate *priv; - - priv = etd->priv; - - gtk_widget_reparent (priv->table, new_parent); -} - -E_MAKE_TYPE (e_timezone_dialog, "ETimezoneDialog", ETimezoneDialog, - e_timezone_dialog_class_init, e_timezone_dialog_init, G_TYPE_OBJECT) diff --git a/widgets/e-timezone-dialog/e-timezone-dialog.glade b/widgets/e-timezone-dialog/e-timezone-dialog.glade deleted file mode 100644 index 2f7bb95a0b..0000000000 --- a/widgets/e-timezone-dialog/e-timezone-dialog.glade +++ /dev/null @@ -1,362 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> -<requires lib="gnome"/> - -<widget class="GtkDialog" id="timezone-dialog"> - <property name="title" translatable="yes">Select a Time Zone</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="default_width">500</property> - <property name="default_height">400</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="cancel-button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-2</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="ok-button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-3</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="timezone-table"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkHBox" id="hbox3"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkImage" id="image1"> - <property name="visible">True</property> - <property name="stock">gtk-dialog-info</property> - <property name="icon_size">6</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Use the left mouse button to zoom in on an area of the map and select a time zone. -Use the right mouse button to zoom out.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label4"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Time Zones</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox2"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label5"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkScrolledWindow" id="map-window"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> - <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="preview-label"> - <property name="visible">True</property> - <property name="label" translatable="yes">America/New_York</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>_Selection</b></property> - <property name="use_underline">True</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">combo-entry1</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label6"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkCombo" id="timezone-combo"> - <property name="visible">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="combo-entry1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">False</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="convertwidget3"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - - <child> - <widget class="GtkListItem" id="convertwidget4"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget5"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/widgets/e-timezone-dialog/e-timezone-dialog.h b/widgets/e-timezone-dialog/e-timezone-dialog.h deleted file mode 100644 index d9e8366fbe..0000000000 --- a/widgets/e-timezone-dialog/e-timezone-dialog.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Evolution calendar - Timezone selector dialog - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: Damon Chaplin <damon@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef __E_TIMEZONE_DIALOG_H__ -#define __E_TIMEZONE_DIALOG_H__ - -#include <gtk/gtkwidget.h> -#include <libical/ical.h> - - - -#define E_TYPE_TIMEZONE_DIALOG (e_timezone_dialog_get_type ()) -#define E_TIMEZONE_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TIMEZONE_DIALOG, ETimezoneDialog)) -#define E_TIMEZONE_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TIMEZONE_DIALOG, \ - ETimezoneDialogClass)) -#define E_IS_TIMEZONE_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TIMEZONE_DIALOG)) -#define E_IS_TIMEZONE_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_TIMEZONE_DIALOG)) - - -typedef struct _ETimezoneDialog ETimezoneDialog; -typedef struct _ETimezoneDialogClass ETimezoneDialogClass; -typedef struct _ETimezoneDialogPrivate ETimezoneDialogPrivate; - -struct _ETimezoneDialog { - GObject object; - - /* Private data */ - ETimezoneDialogPrivate *priv; -}; - -struct _ETimezoneDialogClass { - GObjectClass parent_class; -}; - - -GType e_timezone_dialog_get_type (void); -ETimezoneDialog *e_timezone_dialog_construct (ETimezoneDialog *etd); - -ETimezoneDialog *e_timezone_dialog_new (void); - -icaltimezone *e_timezone_dialog_get_timezone (ETimezoneDialog *etd); -void e_timezone_dialog_set_timezone (ETimezoneDialog *etd, - icaltimezone *zone); - -GtkWidget *e_timezone_dialog_get_toplevel (ETimezoneDialog *etd); - -void e_timezone_dialog_reparent (ETimezoneDialog *etd, - GtkWidget *new_parent); - -#endif /* __E_TIMEZONE_DIALOG_H__ */ diff --git a/widgets/menus/.cvsignore b/widgets/menus/.cvsignore deleted file mode 100644 index 7708c3d120..0000000000 --- a/widgets/menus/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile -libmenus.la -Makefile.in -.deps -.libs -.pure -*.o -*.lo diff --git a/widgets/menus/Makefile.am b/widgets/menus/Makefile.am deleted file mode 100644 index 3a1ca3450b..0000000000 --- a/widgets/menus/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -noinst_LTLIBRARIES = libmenus.la - -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets/menus \ - -DG_LOG_DOMAIN=\"menus\" \ - $(GNOME_FULL_CFLAGS) - -libmenus_la_SOURCES = \ - gal-view-menus.c \ - gal-view-menus.h diff --git a/widgets/menus/gal-view-menus.c b/widgets/menus/gal-view-menus.c deleted file mode 100644 index 128969b5b8..0000000000 --- a/widgets/menus/gal-view-menus.c +++ /dev/null @@ -1,527 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-menus.c: Deploy a GalViewCollection in the menus. - * - * Author: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#include <config.h> - -#include "gal-view-menus.h" - -#include <stdlib.h> -#include <string.h> -#include <gtk/gtksignal.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> -#include <libgnomeui/gnome-dialog.h> -#include <libgnome/gnome-i18n.h> -#include <bonobo/bonobo-ui-util.h> -#include <gal/util/e-util.h> -#include <gal/util/e-xml-utils.h> -#include <gal/menus/gal-define-views-dialog.h> -#include <bonobo/bonobo-ui-util.h> -#include <e-util/e-list.h> - -struct _GalViewMenusPrivate { - GalViewInstance *instance; - int collection_changed_id; - int instance_changed_id; - BonoboUIComponent *component; - EList *listenerClosures; - GtkWidget *define_views_dialog; - - guint show_define_views : 1; -}; - -typedef struct { - GalViewInstance *instance; - char *id; - int ref_count; -} ListenerClosure; - -#define PARENT_TYPE G_TYPE_OBJECT - -static GObjectClass *gvm_parent_class; -static void collection_changed (GalViewCollection *collection, - GalViewMenus *gvm); -static void instance_changed (GalViewInstance *instance, - GalViewMenus *gvm); - -#define d(x) -#define CURRENT_VIEW_PATH "/menu/View/ViewBegin/CurrentView" - -static void -closure_free (void *data, void *user_data) -{ - ListenerClosure *closure = data; - GalViewMenus *gvm = user_data; - - closure->ref_count --; - if (closure->ref_count == 0) { - g_object_unref (closure->instance); - - bonobo_ui_component_remove_listener (gvm->priv->component, closure->id); - g_free (closure); - } -} - -static void * -closure_copy (const void *data, void *user_data) -{ - ListenerClosure *closure = (void *) data; - - closure->ref_count ++; - return closure; -} - -static void -remove_listeners (GalViewMenus *gvm) -{ - if (gvm->priv->listenerClosures) - g_object_unref (gvm->priv->listenerClosures); - - gvm->priv->listenerClosures = NULL; -} - -static void -remove_xml (GalViewMenus *gvm) -{ -} - -static void -remove_instance (GalViewMenus *gvm) -{ - if (gvm->priv->instance) { - if (gvm->priv->instance_changed_id != 0) - g_signal_handler_disconnect (gvm->priv->instance, gvm->priv->instance_changed_id); - - if (gvm->priv->instance->collection && gvm->priv->collection_changed_id != 0) - g_signal_handler_disconnect (gvm->priv->instance->collection, gvm->priv->collection_changed_id); - } - - gvm->priv->instance_changed_id = 0; - gvm->priv->collection_changed_id = 0; - - if (gvm->priv->instance) { - g_object_unref (gvm->priv->instance); - gvm->priv->instance = NULL; - } - - remove_listeners(gvm); - remove_xml(gvm); -} - -static void -add_instance (GalViewMenus *gvm, - GalViewInstance *instance) -{ - g_object_ref (instance); - - if (gvm->priv->instance != NULL) - remove_instance (gvm); - - gvm->priv->instance = instance; - - gal_view_instance_load (gvm->priv->instance); - - gvm->priv->instance_changed_id = g_signal_connect (instance, "changed", - G_CALLBACK (instance_changed), gvm); - gvm->priv->collection_changed_id = g_signal_connect (instance->collection, "changed", - G_CALLBACK (collection_changed), gvm); -} - -static void -clear_define_views_dialog (gpointer data, - GObject *where_the_object_was) -{ - GalViewMenus *gvm = GAL_VIEW_MENUS (data); - gvm->priv->define_views_dialog = NULL; -} - -static void -gvm_finalize (GObject *object) -{ - GalViewMenus *gvm = GAL_VIEW_MENUS (object); - - remove_instance (gvm); - - gal_view_menus_unmerge (gvm, NULL); - - if (gvm->priv->component) - bonobo_object_unref (gvm->priv->component); - - if (gvm->priv->define_views_dialog) - g_object_weak_unref (G_OBJECT (gvm->priv->define_views_dialog), clear_define_views_dialog, gvm); - - g_free(gvm->priv); - - (* G_OBJECT_CLASS (gvm_parent_class)->finalize) (object); -} - -static void -gvm_class_init (GObjectClass *klass) -{ - gvm_parent_class = gtk_type_class (PARENT_TYPE); - - klass->finalize = gvm_finalize; -} - -static void -gvm_init (GalViewMenus *gvm) -{ - gvm->priv = g_new(GalViewMenusPrivate, 1); - gvm->priv->instance = NULL; - gvm->priv->collection_changed_id = 0; - gvm->priv->instance_changed_id = 0; - gvm->priv->component = NULL; - gvm->priv->listenerClosures = NULL; - gvm->priv->define_views_dialog = NULL; - gvm->priv->show_define_views = TRUE; -} - -E_MAKE_TYPE(gal_view_menus, "GalViewMenus", GalViewMenus, gvm_class_init, gvm_init, PARENT_TYPE); - -GalViewMenus * -gal_view_menus_new (GalViewInstance *instance) -{ - GalViewMenus *gvm; - - g_return_val_if_fail (instance != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_INSTANCE (instance), NULL); - - gvm = g_object_new (GAL_VIEW_MENUS_TYPE, NULL); - gal_view_menus_construct(gvm, instance); - - return gvm; -} - -GalViewMenus * -gal_view_menus_construct (GalViewMenus *gvm, - GalViewInstance *instance) -{ - g_return_val_if_fail (gvm != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_MENUS (gvm), NULL); - g_return_val_if_fail (instance != NULL, NULL); - g_return_val_if_fail (GAL_IS_VIEW_INSTANCE (instance), NULL); - - add_instance (gvm, instance); - - return gvm; -} - -static void -dialog_response(GtkWidget *dialog, int id, GalViewMenus *menus) -{ - if (id == GTK_RESPONSE_OK) { - gal_view_collection_save(menus->priv->instance->collection); - } - gtk_widget_destroy(dialog); -} - -static void -define_views(BonoboUIComponent *component, - GalViewMenus *menus, - char *cname) -{ - if (menus->priv->define_views_dialog) { - gdk_window_raise (menus->priv->define_views_dialog->window); - } else { - GtkWidget *dialog = gal_define_views_dialog_new(menus->priv->instance->collection); - - g_signal_connect (dialog, "response", G_CALLBACK (dialog_response), menus); - menus->priv->define_views_dialog = dialog; - g_object_weak_ref (G_OBJECT (dialog), clear_define_views_dialog, menus); - gtk_widget_show(dialog); - } -} - -static void -save_current_view(BonoboUIComponent *component, - GalViewMenus *menus, - char *cname) -{ - gal_view_instance_save_as (menus->priv->instance); -} - -static void -toggled_cb (BonoboUIComponent *component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - gpointer user_data) -{ - ListenerClosure *closure = user_data; - - /* do nothing on state change to untoggled */ - if (!strcmp (state, "0")) - return; - - g_print ("%s\n", path); - - gal_view_instance_set_current_view_id (closure->instance, closure->id); -} - -static char * -build_menus(GalViewMenus *menus) -{ - BonoboUINode *root, *menu, *submenu, *place, *menuitem, *commands, *command; - char *xml; - xmlChar *string; - int length; - int i; - GalViewInstance *instance = menus->priv->instance; - GalViewCollection *collection = instance->collection; - char *id; - gboolean found = FALSE; - - root = bonobo_ui_node_new("Root"); - menu = bonobo_ui_node_new_child(root, "menu"); - commands = bonobo_ui_node_new_child (root, "commands"); - - submenu = bonobo_ui_node_new_child(menu, "submenu"); - bonobo_ui_node_set_attr(submenu, "name", "View"); - - place = bonobo_ui_node_new_child(submenu, "placeholder"); - bonobo_ui_node_set_attr(place, "name", "ViewBegin"); - - submenu = bonobo_ui_node_new_child(place, "submenu"); - bonobo_ui_node_set_attr(submenu, "name", "CurrentView"); - bonobo_ui_node_set_attr(submenu, "_label", N_("_Current View")); - - id = gal_view_instance_get_current_view_id (instance); - - - length = gal_view_collection_get_count(collection); - - menus->priv->listenerClosures = e_list_new (closure_copy, closure_free, menus); - - for (i = 0; i < length; i++) { - GalViewCollectionItem *item = gal_view_collection_get_view_item(collection, i); - ListenerClosure *closure; - char *label; - - menuitem = bonobo_ui_node_new_child(submenu, "menuitem"); - bonobo_ui_node_set_attr(menuitem, "name", item->id); - bonobo_ui_node_set_attr(menuitem, "id", item->id); - bonobo_ui_node_set_attr(menuitem, "group", "GalViewMenus"); - bonobo_ui_node_set_attr(menuitem, "type", "radio"); - - command = bonobo_ui_node_new_child (commands, "cmd"); - bonobo_ui_node_set_attr(command, "name", item->id); - bonobo_ui_node_set_attr(command, "group", "GalViewMenus"); - - label = bonobo_ui_util_encode_str (item->title); - bonobo_ui_node_set_attr(menuitem, "label", label); - g_free (label); - - closure = g_new (ListenerClosure, 1); - closure->instance = instance; - closure->id = item->id; - closure->ref_count = 1; - - if (!found && id && !strcmp (item->id, id)) { - found = TRUE; - } - - g_object_ref (closure->instance); - - bonobo_ui_component_add_listener (menus->priv->component, item->id, toggled_cb, closure); - e_list_append (menus->priv->listenerClosures, closure); - - closure_free (closure, menus); - } - - if (menus->priv->show_define_views) { - if (!found) { - - menuitem = bonobo_ui_node_new_child(submenu, "separator"); - bonobo_ui_node_set_attr(menuitem, "name", "GalView:first_sep"); - bonobo_ui_node_set_attr(menuitem, "f", ""); - - - menuitem = bonobo_ui_node_new_child(submenu, "menuitem"); - bonobo_ui_node_set_attr(menuitem, "name", "custom_view"); - bonobo_ui_node_set_attr(menuitem, "id", "custom_view"); - bonobo_ui_node_set_attr(menuitem, "group", "GalViewMenus"); - bonobo_ui_node_set_attr(menuitem, "type", "radio"); - /* bonobo displays this string so it must be in locale */ - bonobo_ui_node_set_attr(menuitem, "_label", N_("Custom View")); - - command = bonobo_ui_node_new_child (commands, "cmd"); - bonobo_ui_node_set_attr(command, "name", "custom_view"); - bonobo_ui_node_set_attr(command, "group", "GalViewMenus"); - - - menuitem = bonobo_ui_node_new_child(submenu, "menuitem"); - bonobo_ui_node_set_attr(menuitem, "name", "SaveCurrentView"); - bonobo_ui_node_set_attr(menuitem, "_label", N_("Save Custom View...")); - bonobo_ui_node_set_attr(menuitem, "verb", ""); - - command = bonobo_ui_node_new_child(commands, "cmd"); - bonobo_ui_node_set_attr(command, "name", "SaveCurrentView"); - } - - menuitem = bonobo_ui_node_new_child(submenu, "separator"); - bonobo_ui_node_set_attr(menuitem, "name", "GalView:second_sep"); - bonobo_ui_node_set_attr(menuitem, "f", ""); - - menuitem = bonobo_ui_node_new_child(submenu, "menuitem"); - bonobo_ui_node_set_attr(menuitem, "name", "DefineViews"); - bonobo_ui_node_set_attr(menuitem, "_label", N_("Define Views...")); - bonobo_ui_node_set_attr(menuitem, "verb", ""); - - command = bonobo_ui_node_new_child(commands, "cmd"); - bonobo_ui_node_set_attr(command, "name", "DefineViews"); - } - - string = bonobo_ui_node_to_string(root, TRUE); - xml = g_strdup(string); - bonobo_ui_node_free_string(string); - - bonobo_ui_node_free(root); - - g_free (id); - - /* d(g_print (xml));*/ - - return xml; -} - -static BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("DefineViews", define_views), - BONOBO_UI_UNSAFE_VERB ("SaveCurrentView", save_current_view), - BONOBO_UI_VERB_END -}; - -static void -set_state (GalViewMenus *gvm, char *path, CORBA_Environment *ev) -{ - char *full_path = g_strdup_printf ("/commands/%s", path); - - bonobo_ui_component_set_prop (gvm->priv->component, full_path, "state", "1", ev); - g_free (full_path); -} - -static void -set_radio (GalViewMenus *gvm, - CORBA_Environment *ev) -{ - char *id; - - id = gal_view_instance_get_current_view_id (gvm->priv->instance); - - if (id) { - set_state (gvm, id, ev); - } else { - set_state (gvm, "custom_view", ev); - } - g_free (id); -} - -static void -build_stuff (GalViewMenus *gvm, - CORBA_Environment *ev) -{ - char *xml; - - g_object_ref (gvm); - - gal_view_menus_unmerge (gvm, ev); - - remove_listeners(gvm); - remove_xml(gvm); - xml = build_menus(gvm); - bonobo_ui_component_set_translate(gvm->priv->component, "/", xml, ev); - g_free(xml); - - bonobo_ui_component_add_verb_list_with_data(gvm->priv->component, verbs, gvm); - - set_radio (gvm, ev); - - g_object_unref (gvm); -} - -void -gal_view_menus_set_show_define_views (GalViewMenus *gvm, - gboolean show_define_views) -{ - if (gvm->priv->show_define_views == show_define_views) - return; - - gvm->priv->show_define_views = show_define_views; - - if (gvm->priv->component) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - build_stuff(gvm, &ev); - CORBA_exception_free (&ev); - } -} - -void -gal_view_menus_apply (GalViewMenus *gvm, - BonoboUIComponent *component, - CORBA_Environment *opt_ev) -{ - if (gvm->priv == NULL) - return; - - if (component != gvm->priv->component) { - if (component) - bonobo_object_ref (BONOBO_OBJECT (component)); - - if (gvm->priv->component) - bonobo_object_unref (BONOBO_OBJECT (gvm->priv->component)); - } - - gvm->priv->component = component; - - build_stuff (gvm, opt_ev); -} - -void -gal_view_menus_unmerge (GalViewMenus *gvm, - CORBA_Environment *opt_ev) -{ - d(g_print ("%s:\n", G_GNUC_FUNCTION)); - if (bonobo_ui_component_get_container (gvm->priv->component) != NULL - && bonobo_ui_component_path_exists (gvm->priv->component, CURRENT_VIEW_PATH, opt_ev)) { - d(g_print ("%s: Removing path\n", G_GNUC_FUNCTION)); - bonobo_ui_component_rm (gvm->priv->component, CURRENT_VIEW_PATH, opt_ev); - } -} - -static void -collection_changed (GalViewCollection *collection, - GalViewMenus *gvm) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - build_stuff(gvm, &ev); - CORBA_exception_free (&ev); -} - -static void -instance_changed (GalViewInstance *instance, - GalViewMenus *gvm) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - build_stuff(gvm, &ev); - CORBA_exception_free (&ev); -} - -void -gal_view_menus_set_instance (GalViewMenus *gvm, - GalViewInstance *instance) -{ - remove_instance (gvm); - add_instance (gvm, instance); - instance_changed (instance, gvm); -} diff --git a/widgets/menus/gal-view-menus.h b/widgets/menus/gal-view-menus.h deleted file mode 100644 index e4de898187..0000000000 --- a/widgets/menus/gal-view-menus.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _GAL_VIEW_MENUS_H_ -#define _GAL_VIEW_MENUS_H_ - -#include <libxml/tree.h> -#include <bonobo/bonobo-ui-component.h> -#include <gal/menus/gal-view-instance.h> - -#include <glib-object.h> - -#define GAL_VIEW_MENUS_TYPE (gal_view_menus_get_type ()) -#define GAL_VIEW_MENUS(o) (GTK_CHECK_CAST ((o), GAL_VIEW_MENUS_TYPE, GalViewMenus)) -#define GAL_VIEW_MENUS_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GAL_VIEW_MENUS_TYPE, GalViewMenusClass)) -#define GAL_IS_VIEW_MENUS(o) (GTK_CHECK_TYPE ((o), GAL_VIEW_MENUS_TYPE)) -#define GAL_IS_VIEW_MENUS_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GAL_VIEW_MENUS_TYPE)) - -typedef struct _GalViewMenusPrivate GalViewMenusPrivate; - -typedef struct { - GObject base; - GalViewMenusPrivate *priv; -} GalViewMenus; - -typedef struct { - GObjectClass parent_class; -} GalViewMenusClass; - -GtkType gal_view_menus_get_type (void); -GalViewMenus *gal_view_menus_new (GalViewInstance *instance); -GalViewMenus *gal_view_menus_construct (GalViewMenus *menus, - GalViewInstance *instance); - -void gal_view_menus_set_show_define_views (GalViewMenus *menus, - gboolean show_define_views); - -void gal_view_menus_apply (GalViewMenus *menus, - BonoboUIComponent *component, - CORBA_Environment *opt_ev); -void gal_view_menus_unmerge (GalViewMenus *gvm, - CORBA_Environment *opt_ev); -void gal_view_menus_set_instance (GalViewMenus *gvm, - GalViewInstance *instance); - -#endif /* _GAL_VIEW_MENUS_H_ */ diff --git a/widgets/misc/.cvsignore b/widgets/misc/.cvsignore deleted file mode 100644 index 4bc7214f51..0000000000 --- a/widgets/misc/.cvsignore +++ /dev/null @@ -1,17 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -e-system-errors.xml -e-util-marshal.c -e-util-marshal.h -test-calendar -test-dateedit -test-dropdown-button -test-error -test-multi-config-dialog -test-source-option-menu -test-source-selector -test-title-bar diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog deleted file mode 100644 index ac88cc8b95..0000000000 --- a/widgets/misc/ChangeLog +++ /dev/null @@ -1,748 +0,0 @@ -2004-09-13 Rodney Dawes <dobey@novell.com> - - * e-multi-config-dialog.c (impl_response): - Point at "config-prefs" instead of "config" for the help section - -2004-08-03 JP Rosevear <jpr@novell.com> - - * Makefile.am: Really dist the pilot sources this time - -2004-08-03 JP Rosevear <jpr@novell.com> - - * Makefile.am: Dist the pilot sources - -2004-08-01 JP Rosevear <jpr@novell.com> - - * e-pilot-settings.c (e_pilot_settings_get_source): accessor - (e_pilot_settings_set_source): ditto - (build_ui): show the source option menu - (e_pilot_settings_new): use above - - * e-pilot-settings.h: add prototypes - -2004-07-20 JP Rosevear <jpr@novell.com> - - * Makefile.am: build pilot setting - -2004-07-26 JP Rosevear <jpr@novell.com> - - * e-search-bar.c (setup_bonobo_menus): use ctrl-shift-q to clear - search bar - -2004-07-20 Not Zed <NotZed@Ximian.com> - - * e-error.c: include config.h. See #61395. - -2004-07-20 JP Rosevear <jpr@novell.com> - - * e-source-selector.h: remove proto - - * e-source-selector.c (selection_func): don't force the item to be - checked - (cell_toggled_callback): allow the cell to be untoggled even if - its primary - (init): set the pixbuf renderable - (e_source_selector_set_toggle_selection): no longer necessary - -2004-07-16 Chris Toshok <toshok@ximian.com> - - * e-clipped-label.c (e_clipped_label_recalc_chars_displayed): - remove debug spew and fix the display when - pango_layout_line_x_to_index returns FALSE (before we were drawing - both the ellipses and the text). - -2004-07-12 Jeffrey Stedfast <fejj@novell.com> - - * e-charset-picker.c: s/GB-2312/GB2312/ - fixes bug #61385. - -2004-06-24 Rodney Dawes <dobey@novell.com> - - * e-error.c (e_error_newv): Fix alignment of the icon to be 0x0 - - Fixes #60493 - -2004-06-24 Rodney Dawes <dobey@novell.com> - - * e-source-selector.[ch]: Add new "select_new" property to - private structure of the ESourceSelector - (rebuild_cb): Add code to select the new source, and cause the - selection_changed signal to get emitted, if we select new sources - (init): Don't select new sources by default - (e_source_selector_set_select_new): Add function to set whether or not - we want to select new sources when we add them - -2004-06-16 Not Zed <NotZed@Ximian.com> - - * e-source-selector.c (cell_toggled_callback): fix a path leak and - maek the code more structured. - (e_source_selector_set_toggle_selection): set the mode on whether - you can toggle the currnet selection or not. - (cell_toggled_callback): implement set_toggle_selection behaviour. - -2004-06-03 William Jon McCann <mccann@jhu.edu> - - * e-error.c (e_error_newv): Add HIG border width for dialog window. - -2004-06-01 Christian Neumair <chris@gnome-de.org> - - * Makefile.am (test_error_LDADD): Link test-error against libeutil. - -2004-06-01 Anders Carlsson <andersca@gnome.org> - - * e-expander.c (e_expander_expose): Don't propagate the expose - to the label widget, the parent expose handler does that. - -2004-05-28 Anders Carlsson <andersca@gnome.org> - - * e-error.c (e_error_newv): Use the constructed title string. - -2004-05-27 Rodney Dawes <dobey@novell.com> - - * Makefile.am (EXTRA_DIST): Add $(error_i18n) - -2004-05-21 Not Zed <NotZed@Ximian.com> - - * e-error.c (e_error_default_parent): set a default error parent - fallback. - (e_error_newv): if parent is null, see if we have a default still - alive, and use that. warn if not. - (e_error_default_parent): uh, fix the sense of the - if-we-dont-have-it test. - -2004-05-20 JP Rosevear <jpr@novell.com> - - * e-task-widget.c (e_task_widget_construct): only unref the mask - if there is one - -2004-05-19 JP Rosevear <jpr@novell.com> - - * Makefile.am: don't dist the error .h file - -2004-05-18 Not Zed <NotZed@Ximian.com> - - * e-error.c (ee_load): load the <help> tag if present. - (ee_response): handle the help response and swallow the signal. - (e_error_newv): setup help button if we have a help uri. - -2004-05-17 Jeffrey Stedfast <fejj@novell.com> - - * e-url-entry.c (init): Use E_ICON_SIZE_BUTTON for the icon size - in the e_icon_factory_get_icon() call. - - * e-combo-button.c (create_empty_image_widget): Don't hard-code - the size of the icon in pixels, instead use the appropriate - E_ICON_SIZE_ enum. - -2004-05-17 JP Rosevear <jpr@novell.com> - - Fixes #58460 - - * e-task-widget.c (e_task_widget_construct): bitmap_unref the - mask, don't object_unref it - -2004-05-12 Not Zed <NotZed@Ximian.com> - - * e-error.c (ee_load): duh, use the right node pointer for title - and secondary text. - - * e-system-errors.xml: make the Because cases the same. - - * e-system-errors.xml.h: add for translators. - - * e-error.c (ee_load): just use _() to do i18n rather than the - nasty lang stuff. - (find_node): no longer needed. - - * Makefile.am (%.xml.h): setup the build rules for the i18n file - for the errors. - - * e-system-errors.xml.in: Removed, renamed to .xml and removed the - _ stuff. - -2004-05-04 Xan Lopez <xan@gnome.org> - - * Makefile.am: - - Build fixes. - -2004-05-03 Not Zed <NotZed@Ximian.com> - - * e-error.c (ee_build_label): blah, need to do entity decoding. - #57918. - -2004-04-29 JP Rosevear <jpr@ximian.com> - - * e-activity-handler.c (impl_dispose): pass the correct data when - weak unreffing - -2004-04-29 Not Zed <NotZed@Ximian.com> - - * e-error.c (e_error_newv): make the label selectable. - (e_error_newv): if we have stock and label set, then use a stock - button with an override label. - -2004-04-28 Not Zed <NotZed@Ximian.com> - - * e-system-errors.xml.in: holder for system errors. - - * test-error.c: helper to show an error message/test it. - - * e-error.[ch]: Api for disk-based, hig-compliant error messages - and query boxes. - -2004-04-19 Jeffrey Stedfast <fejj@ximian.com> - - * e-info-label.c (e_info_label_new): Updated to sue E_ICON_SIZE enums. - -2004-04-19 Rodney Dawes <dobey@ximian.com> - - * e-info-label.c (e_info_label_new): Update to use EIconFactory to - get the filename for the component icons using the icon theme - -2004-04-19 Michael Terry <mike@mterry.name> - - * e-combo-buddon.c: - * e-url-entry.c: Update these to use EIconFactory and GtkImages - directly instead of GdkPixmaps - -2004-04-09 Rodney Dawes <dobey@ximian.com> - - * e-charset-picker.c: Include gtkhbox.h in here to avoid the warnings - (activate_other): - (e_charset_picker_dialog): Make these dialogs be more HIG-compliant - * e-filter-bar.c (do_advanced): - (menubar_activated): Make these dialogs be more HIG-compliant - -2004-04-08 Not Zed <NotZed@Ximian.com> - - * e-info-label.c (e_info_label_set_info): ugh, fix some last - minute changes which broke shit. - - * e-info-label.[ch]: A widget to show component info for the - current component/view. - -2004-04-07 Jeffrey Stedfast <fejj@ximian.com> - - * e-multi-config-dialog.c: Updated for changes to e-config-page.c - (init): Removed the OK and Apply buttons. - - * e-config-page.c (e_config_page_apply): Removed. - (e_config_page_is_applied): Removed. - (e_config_page_changed): Removed. - -2004-04-01 Dan Winship <danw@ximian.com> - - * e-url-entry.c (init): Make the button initially insensitive. - Connect to the entry's "changed" signal. - (entry_changed_cb): sensitize the button iff the entry is - non-empty - (button_clicked_cb): simplify a bit by using gtk_entry_get_text - rather than gtk_editable_get_chars. - -2004-04-01 Jeffrey Stedfast <fejj@ximian.com> - - * e-charset-picker.c (e_charset_picker_new): Create a new class - for "Western European, New" to fix a translation issue. - -2004-03-31 Not Zed <NotZed@Ximian.com> - - * e-filter-bar.c (menubar_activated): start the rule editor with - the right label. - -2004-03-26 Rodney Dawes <dobey@ximian.com> - - * e-multi-config-dialog.c (init): Remove the dialog separator - Set the border widths of the dialog's vbox and action area to be more - HIG-compliant - Set the border width of the dialog's child to 12 for HIG-compliance - -2004-03-15 JP Rosevear <jpr@ximian.com> - - * e-calendar-item.c (e_calendar_item_class_init): change arg name - (e_calendar_item_init): ditto - (e_calendar_item_get_arg): ditto - (e_calendar_item_set_arg): ditto - (e_calendar_item_preserve_day_selection): set the selection day to - the given selection - (e_calendar_item_set_first_month): use above to preserve selected - day of week - - * e-calendar-item.h: change field name - -2004-03-13 Trent Lloyd <lathiat@sixlabs.org> - - * e-search-bar.c (remove_bonobo_menus): move function above - setup_bonobo_menus, fixes implicit declaration. - -2004-03-12 Kidd Wang <kidd.wang@sun.com> - - * e-dateedit.c (create_children): enlarge the text box to - accomodate the time info in different locales. - -2004-03-11 Jeffrey Stedfast <fejj@ximian.com> - - Fix for bug #55267. - - * e-filter-bar.c (set_property): Use efb->setquery properly (set - to TRUE before calling set_item_id and FALSE afterwards). Also - setquery to TRUE before emitting the "search-activated" signal so - that we don't run the callback for the signal we are emitting. - -2004-03-02 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (set_property): Emit the "search-activated" - signal. Fixes bug #55054. - -2004-02-26 Rodney Dawes <dobey@ximian.com> - - * e-cell-renderer-combo.c (ecrc_get_size): - * e-dateedit.c (create_children): - * e-dropdown-button.c (e_dropdown_button_construct): Create the - arrows in these widgets as GTK_SHADOW_NONE, since the default arrow - type in GTK+ 2.x is flat triangle arrows, and shadow types are - generally ignored for arrows anyway, and so we don't look ugly with - themes that handle shadow types on arrows correctly - -2004-02-26 Bill Zhu <bill.zhu@sun.com> - - * e-search-bar.c (setup_bonobo_menus): Before Update the bonobo ui - component, remove it first. - - Fixes #54788 - -2004-02-11 Rodney Dawes <dobey@ximian.com> - - * e-multi-config-dialog.c (impl_response): Change the filename and - section that we pass to gnome_help_display_desktop so that the help - browser displays the documentation correctly - -2004-02-10 Rodney Dawes <dobey@ximian.com> - - * e-multi-config-dialog.c (init): Add a Help button - (impl_response): Handle the Help button and open the documentation - - Fixes #30681 - -2004-02-05 Rodney Dawes <dobey@ximian.com> - - * e-task-bar.c: Don't show the task label by default - -2004-02-03 Dan Winship <danw@ximian.com> - - * e-activity-handler.c: - * e-activity-handler.h: - * e-task-bar.c: - * e-task-bar.h: - * e-task-widget.c: - * e-task-widget.h: Moved here from shell/, since they are now used - only by the components, not the shell itself. - - * Makefile.am (widgetsinclude_HEADERS, - libemiscwidgets_la_SOURCES): add new files - -2004-02-02 Chris Toshok <toshok@ximian.com> - - * e-image-chooser.c (set_image_from_data): set - image_buf/image_buf_size here instead of in all callers. also - emit the "changed" signal here. - (image_drag_data_received_cb): remove the copying to image_buf and - emitting of "changed" from here. - (e_image_chooser_set_from_file): only g_free (data) here if - set_image_from_data failed. - (e_image_chooser_set_image_data): copy the image data we're passed - before calling set_image_data. free it if rv == FALSE. - -2004-01-30 Chris Toshok <toshok@ximian.com> - - * e-image-chooser.c (e_image_chooser_init): add an alignment - around the image. This might not be enough. hrm. - (set_image_from_data): handle the case where there's no image - (image_height == image_width == 0). - (e_image_chooser_get_image_data): new function. - (e_image_chooser_set_image_data): new function. - - * e-image-chooser.h: add prototypes for set/get_image_data. - -2004-01-30 Chris Toshok <toshok@ximian.com> - - * e-image-chooser.[ch]: abstract out the drag and droppable image - widget from the contact list editor and stick it here. There's - some code for a "Browse..." button here but it's not enabled. - - * Makefile.am (widgetsinclude_HEADERS): add e-image-chooser.h. - (libemiscwidgets_la_SOURCES): add e-image-chooser.c - -2004-01-30 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (get_property): Only save the search-bar state OR - the filter-bar state - decided based on what the search is. If the - search is an advanced search, then save the filter-bar state, - otherwise save the search-bar state. - (set_property): Only need to restore the first state we find - (filter-bar vs search-bar). If we are restoring filter-bar state, - set efb->setquery to TRUE and then set the item_id to - E_FILTERBAR_ADVANCED_ID. - -2004-01-29 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (option_changed): Don't call efb->config() if the - current_query is NULL. - -2004-01-28 Jeffrey Stedfast <fejj@ximian.com> - - * e-search-bar.c (impl_get_property): Same. - - * e-filter-bar.c (get_property): Use - g_value_set_string_take_ownership() instead of - g_value_take_string() since we need snaps to work with glib-2.0 - earlier than 2.3.x. - -2004-01-28 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c: Added a new property "state" which is READ-WRITE - so that we can save/restore state in the mailer code if we want - to. Sort of a work-in-progress toward fixing bug #53195. - (class_init): Ported to use the GObject property stuff instead of - the deprecated GtkArg stuff. - (get_property): Ported from impl_get_arg(). - (set_property): New object::set_property implementation to set the - query state. - -2004-01-24 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (cell_toggled_callback): if the source is - primary, don't allow it to be un-selected - -2004-01-20 Rodney Dawes <dobey@ximian.com> - - * e-combo-button.c (paint): Be even more exactly like the GtkButton - painting stuff - - Fixes #52988 - -2004-01-20 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (rebuild_model): set a primary selection if - there is one before the rebuild - (e_source_selector_set_primary_selection): block the signals when - clearing the tree selection to make the op atomic; emit the - selection_changed signal if a hidden selection is not currently - selectecd - -2004-01-20 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (find_source_iter): provide parent iter - in/out arg - (test_collapse_row_callback): use priv shortcut - (e_source_selector_select_source): pass parent iter - (e_source_selector_unselect_source): ditto - (e_source_selector_peek_primary_selection): return the right thing - if the primary selection is currently hidden - (e_source_selector_set_primary_selection): set the primary - selection properly if the source node is currently hidden - -2004-01-20 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (clear_saved_primary_selection): util - routine to clear the row reference to the saved primary selection - (find_source_iter): unref the model data retrieved - (rebuild_existing_cb): ditto - (toggle_cell_data_func): ditto - (text_cell_data_func): ditto - (selection_func): ditto; clear the saved primary selection if - something else is selected - (cell_toggled_callback): ditto - (test_collapse_row_callback): clear the toggled_last flag - (row_expanded_callback): once we've restored the saved primary - selection, clear it - (selector_button_press_event): unref the model data - (impl_dispose): use clear_saved_primary_selection - (init): the store column holds object not pointer type - (e_source_selector_peek_primary_selection): unref the model data - -2004-01-20 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (test_collapse_row_callback): check if the - collapsing node has its child selected, if so take a row reference - to remember the selection - (row_expanded_callback): check if the expanding node has the saved - primary selection under it and re-select if so - (init): listen for signals - (impl_dispose): free the primary selection - -2004-01-19 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (create_rebuild_data): create the data - structure for rebuilding the model - (free_rebuild_data): free it - (rebuild_existing_cb): check for the sources that are still - existing or deleted - (rebuild_model): do incremental updates - (selection_func): if the last thing we did was toggle, we don't - actually want to highlight and if the source is not checked, check - it - (cell_toggled_callback): indicate that a toggle just occurred - (init): initial toggled last to false - (e_source_selector_set_primary_selection): set some preconditions - - Fixes #51787 - -2004-01-19 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (cell_toggled_callback): indicate that a toggle just occurred - -2004-01-19 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c - - (selector_button_press_event): when right clicking, make sure the - calendar is highlighted and that groups can't be right clicked on - -2004-01-14 Rodney Dawes <dobey@ximian.com> - - * e-expander.[ch]: Fix remaining usages of GTK_*EXPANDER* defines - -2003-12-22 Rodney Dawes <dobey@ximian.com> - - Fix for bug #46349 - - * e-combo-button.c: Use the appropriate style painting for a - button widget, since we are a button - -2003-12-18 Harry Lu <harry.lu@sun.com> - - * e-cell-date-edit.c: (e_cell_date_edit_do_popup): call - gdk_window_focus() so that keyboard works correctly. - -2003-12-04 Harry Lu <harry.lu@sun.com> - - Fix for bugzilla bug #51624 and #51627. - - * e-calendar-item.c: (e_calendar_item_selection_add_days): - set the date to the first day of the month so that user can use - keyboard's arrow key to select a date. - (e_calendar_item_set_selection_if_emission): only set selection_changed - if emission is TRUE. - * e-calendar.c: (e_calendar_init): add back the "clicked" handler so - that user can use keyboard to click the button. - (e_calendar_start_auto_move): no need to move since it is already - handled by the clicked handler - (e_calendar_on_prev_clicked), (e_calendar_on_next_clicked): move the - month here. - * e-dateedit.c: (e_date_edit_show_date_popup): use gdk_window_focus - instead of gdk_keyboard_grab so that the focus won't lost if user click - the button with keyboard. - (hide_date_popup): no need to call gdk_keyboard_ungrab. - -2003-12-02 Ettore Perazzoli <ettore@ximian.com> - - * e-source-selector.c (init): Set the mode on the text cell - renderer to GTK_CELL_RENDERER_MODE_ACTIVATABLE so clicking on the - text doesn't change the status of the checkbox. [Many thanks to - Jonathan Blandford for telling me how to do this!] - -2003-12-01 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (class_init): list the signal args properly - -2003-11-30 ERDI Gergo <cactus@cactus.rulez.org> - - * e-calendar.c: canned the _clicked handlers as those make it - impossible to move just one month at a time - -2003-11-30 Ettore Perazzoli <ettore@ximian.com> - - * e-util-marshal.list: Add NONE:POINTER. - - * test-source-option-menu.c (source_selected_callback): New - callback to test the "source_selected" signal. - (on_idle_create_widget): Connect. - - * e-source-option-menu.c: Add "source_selected" signal. - (select_source): Assume source != NULL and emit "source_selected". - -2003-11-30 Ettore Perazzoli <ettore@ximian.com> - - * test-source-option-menu.c: New test. - - * e-source-option-menu.h: New. - * e-source-option-menu.c: New. - -2003-11-23 ERDI Gergo <cactus@cactus.rulez.org> - - * e-expander.c: Added the late eggexpander - - * e-expander.c (e_expander_button_release): Emit 'activate' signal when - appropriate - - -2003-11-17 Charles Zhang <charles.zhang@sun.com> - - * e-search-bar.c(add_button): allow new lable with mnemonic - (e_search_bar_construct): alter lable name. [50810] - -2003-11-16 JP Rosevear <jpr@ximian.com> - - * e-source-selector.c (e_source_selector_set_primary_selection): - use find_source_iter and get the selection from the right spot - (find_source_iter): util function to find the iter given the - source - (e_source_selector_select_source): signal that the model changed - (e_source_selector_unselect_source): ditto - -2003-11-14 JP Rosevear <jpr@ximian.com> - - * e-source-selector.h: include e-source stuff from e-d-s - - * Makefile.am: use new cflags/libs to build - -2003-11-13 Bolian Yin <bolian.yin@sun.com> - - * e-calendar-item.c: remove a declaration of a deleted func. - -2003-11-12 JP Rosevear <jpr@ximian.com> - - * e-calendar-item.c (e_calendar_item_class_init): a canvas item - does not inherit from gtkwidget - -2003-11-11 Bolian Yin <bolian.yin@sun.com> - - Fixes #50538 - - * e-calendar-item: make e_calendar_item_normalize_date public func. - add "selection_preview_changed" signal. - move some definition of constants to .h - -2003-11-10 Ettore Perazzoli <ettore@ximian.com> - - * e-source-selector.c (e_source_selector_new): Expand all the - nodes. - -2003-11-07 JP Rosevear <jpr@ximian.com> - - * Makefile.am: make sure the marshal stuff is in the sources and - remove the built files when disting - -2003-10-28 Rodrigo Moya <rodrigo@ximian.com> - - * e-source-selector.c (class_init): fill_popup_menu signal has - 2 arguments. - -2003-10-28 Rodrigo Moya <rodrigo@ximian.com> - - * e-source-selector.[ch]: added "fill_popup_menu" signal, to - allow the addition of new items to the popup menu. - (class_init): create new signal. - (init): connect to "button_press_event" for the tree view. - (selector_button_press_event): callback for "button_press_event". - (e_source_selector_selection_shown): use g_return_val_if_fail. - -2003-10-22 Dan Winship <danw@ximian.com> - - * e-bonobo-widget.[ch]: Remove these (unused since 1.2) - -2003-09-30 Mike Kestner <mkestner@ximian.com> - - * e-cell-renderer-combo.* : new, treeview renderer for combo cells - * e-combo-cell-editable.* : new, GtkCellEditable for combo cells - * Makefile.am : build the new files - -2003-08-18 Ettore Perazzoli <ettore@ximian.com> - - * e-source-selector.c (e_source_selector_selection_shown) - (e_source_selector_show_selection): Add precondition. - -2003-08-18 Ettore Perazzoli <ettore@ximian.com> - - * test-source-selector.c (on_idle_create_widget): Add a - checkbutton to the test window for toggling the checkboxes on and - off. Also, put the list in a scrolled window and set a default - size for the main window. - (check_toggled_callback): Callback for the checkbutton. - - * e-source-selector.c: New member checkboxes_shown in struct - ESourceSelectorPrivate. - (init): Set to TRUE. - (e_source_selector_show_selection): New. - (e_source_selector_selection_shown): New. - (toggle_cell_data_func): Don't show the toggle if checkboxes_shown - is FALSE. - -2003-08-17 Ettore Perazzoli <ettore@ximian.com> - - * e-source-selector.c: New signal "primary_selection_changed", - removed members list_changed_callback_id and - selection_changed_callback_id in ESourceSelectorPrivate. - (rebuild_model): If the new set of selected sources is smaller - than the old one, emit "selection_changed". - (e_source_selector_peek_primary_selection): New. - (e_source_selector_set_primary_selection): New. - (selection_changed_callback): New callback for the "changed" - signal on our associated GtkTreeSelection. - (init): Connect. - (impl_dispose): Disconnect. - (setup_model): Use signal_connect_object() instead of saving the - ID. - -2003-08-15 Ettore Perazzoli <ettore@ximian.com> - - * e-source-selector.c (cell_toggled_callback): Call - gtk_tree_model_row_changed() to let the model know that we changed - the data. - -2003-08-15 Ettore Perazzoli <ettore@ximian.com> - - * test-source-selector.c: New test program. - - * e-source-selector.c: New file. - * e-source-selector.h: New file. - -2003-07-23 Dan Winship <danw@ximian.com> - - * Makefile.am: use EVO_MARSHAL_RULE - - * e-combo-button.c (create_empty_pixmap_widget): Create the pixbuf - from empty.xpm rather than just calling gdk_pixbuf_new(), which - doesn't actually initialize the pixel data. - - * e-messagebox.c: Remove this, since it claims to be deprecated, - and nothing is actually using it any more. - - * Makefile.am: Remove e-messagebox.[ch] - -2003-07-11 Federico Mena Quintero <federico@ximian.com> - - * e-dateedit.c (e_date_edit_mnemonic_activate): Added a handler - for GtkWidget::mnemonic_activate(). - - * e-url-entry.c (mnemonic_activate): Likewise. - -2003-07-09 Federico Mena Quintero <federico@ximian.com> - - * e-url-entry.c (destroy): Chain to the parent handler. Fixes #45236. - -2003-06-23 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (set_menu): Translate the text. [#45112] - -2003-06-18 Suresh Chandrasekharan <suresh.chandrasekharan@sun.com> - - * e-charset-picker.c: Fix for #45082: GB18030 BIG5HKSCS and EUC-TW - charsets not supported in evolution mail - -2003-06-17 Jeffrey Stedfast <fejj@ximian.com> - - * e-charset-picker.c (e_charset_picker_bonobo_ui_populate): Don't - use the charset class in the menu label if it is 'Unknown'. - (e_charset_picker_bonobo_ui_populate): For user-defined charsets, - just use the name of the charset rather than "Unknown". - (add_charset): Don't escape _'s anymore, this seems to not be - needed int gtk2. - (add_other_charset): g_strdup() the charset name. Fixes bug - #43917. - -2003-06-11 Larry Ewing <lewing@ximian.com> - - * e-search-bar.c (impl_get_property): take ownership of the duped - string. - diff --git a/widgets/misc/ChangeLog.pre-1-4 b/widgets/misc/ChangeLog.pre-1-4 deleted file mode 100644 index 7a5cae8211..0000000000 --- a/widgets/misc/ChangeLog.pre-1-4 +++ /dev/null @@ -1,1903 +0,0 @@ -2003-05-29 JP Rosevear <jpr@ximian.com> - - Fixes #43775 - - * e-calendar-item.c (layout_set_day_text): calculate the day - character correctly - (e_calendar_item_draw_month): use it - - * e-dateedit.c (rebuild_time_popup): use e_utf8_strftime - (e_date_edit_update_date_entry): ditto - (e_date_edit_update_time_entry): ditto - - * e-calendar-item.c (layout_set_day_text): calculate the day - character correctly - (e_calendar_item_draw_month): use e_utf8_strftime and above - (e_calendar_item_show_popup_menu): use e_utf8_strftime - (e_calendar_item_recalc_sizes): use layout_set_day_text - -2003-05-19 Anna Marie Dirks <anna@ximian.com> - - * e-multi-config-dialog.c (init): Added HIG-appropriate spacing/ - padding to the main hbox into which the icons and page widgets - are packed. - -2003-05-19 Larry Ewing <lewing@ximian.com> - - * e-charset-picker.c: port to GtkDialog. - -2003-05-14 JP Rosevear <jpr@ximian.com> - - * e-combo-button.c (impl_destroy): guard against multiple destroys - -2003-05-13 Ettore Perazzoli <ettore@ximian.com> - - [#42628] - * e-search-bar.c (search_now_verb_cb): Call - emit_search_activated() instead of emit_query_changed(). - -2003-05-11 Chris Toshok <toshok@ximian.com> - - [ fixes bug #42177 ] - * e-dateedit.c (e_date_edit_init): remove the CAN_FOCUS flag. - -2003-05-09 Ettore Perazzoli <ettore@ximian.com> - - * e-combo-button.c (menu_deactivate_callback): Set in_button to - FALSE; this makes sure the button gets the right appearance after - the menu is popped down (the reason why this is necessary is that - the widget doesn't never gets to the leave_notify event). - -2003-05-07 JP Rosevear <jpr@ximian.com> - - * e-search-bar.c (e_search_bar_set_text): trash e_utf8_gtk function - (e_search_bar_get_text): ditto - -2003-04-29 Dan Winship <danw@ximian.com> - - * e-dateedit.c (e_date_edit_forall): Remove this so that - GtkContainer's destroy method will destroy all of the internal - widgets. (This is how other compound-widgets-that-aren't- - meant-to-be-used-as-containers behave.) #41458 - -2003-04-16 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (remove_bonobo_menus): Only do the actual remove - if the ui component actually has a container; this suppresses a - BonoboUI warning at each folder view switch. - -2003-04-15 Hans Petter Jansson <hpj@ximian.com> - - * e-calendar-item.c (e_calendar_item_update): Unref the metrics. - (e_calendar_item_draw): Re-use the widget's context instead of - creating a new one. Unref the metrics. - (e_calendar_item_draw_month): Unref the metrics. Don't create the - layout where it might be leaked by an early return. Unref the layout - before returning if we're outside the clip area. - (e_calendar_item_draw_day_numbers): Unref the metrics. - (e_calendar_item_recalc_sizes): Unref the metrics. - (e_calendar_item_convert_position_to_day): Unref the metrics. - - * e-calendar.c (e_calendar_size_allocate): Unref the metrics. - -2003-04-11 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (do_advanced): Change the border width and - padding to comply with the HIG. Fixes bug #41202. - (do_advanced): Changed the button ordering from Cancel/Save/OK to - Save/Cancel/OK to comply with the HIG. Fixes bug #41207. - -2003-04-08 Mike Kestner <mkestner@ximian.com> - - * e-search-bar.c (set_option): kill an old e_utf8_gtk usage - -2003-04-06 Chris Toshok <toshok@ximian.com> - - * e-cell-percent.h: e_cell_percent_get_type returns GType, not - GtkType. - - * e-cell-percent.c (e_cell_percent_new): use g_object_new, not - gtk_object_new. - -2003-04-02 Hans Petter Jansson <hpj@ximian.com> - - * e-calendar-item.c (e_calendar_item_set_selection): For example; - a selection ending 2003-apr-02 does not fit into the remaining - shown days after 1969-dec. Stop assuming that it does. - -2003-04-01 Hans Petter Jansson <hpj@ximian.com> - - * e-calendar-item.c (e_calendar_item_class_init) - (e_calendar_item_destroy) - (e_calendar_item_get_arg) - (e_calendar_item_set_arg) - (e_calendar_item_update) - (e_calendar_item_draw) - (e_calendar_item_draw_month) - (e_calendar_item_draw_day_numbers) - (e_calendar_item_recalc_sizes) - (e_calendar_item_convert_position_to_day): Nuke GdkFont and use - Pango's font measuring for everything. - - * e-calendar-item.h: Ditto. - - * e-calendar.c (e_calendar_init) - (e_calendar_size_allocate): Ditto. - -2003-03-30 Hans Petter Jansson <hpj@ximian.com> - - * e-calendar-item.c (e_calendar_item_destroy): Handle multiple - destroys. - -2003-03-28 JP Rosevear <jpr@ximian.com> - - * e-search-bar.c (clear_search): set the sub item to the default - as well - -2003-03-25 Dan Winship <danw@ximian.com> - - * e-calendar.c: #include gtkarrow.h - * e-combo-button.c: Likewise - - * e-charset-picker.c: Update for e_notice move - -2003-03-19 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c: Updated to use GtkDialog instead of - GnomeDialog. Also fixed bug #39550 while I was at it. - -2003-03-10 Rodney Dawes <dobey@ximian.com> - - * e-calendar.c: Use GtkArrow instead of pixmaps - * e-combo-button.c: Use GtkArrow instead of pixmaps - * e-filter-bar.c: gtk_window_set_policy () is deprecated - * e-url-entry.c: Load the icon in a pixbuf instead of GdkPixmap - -2003-03-06 Ettore Perazzoli <ettore@ximian.com> - - * e-url-entry.c (destroy): Removed unused variable. - -2003-03-06 Ettore Perazzoli <ettore@ximian.com> - - * e-dropdown-button.c (menu_deactivate_cb): Removed debugging - spew. - -2003-02-27 Chris Toshok <toshok@ximian.com> - - * e-url-entry.c (destroy): guard this so we don't try to free priv - multiple times. - -2003-02-25 Dan Winship <danw@ximian.com> - - * e-map.c (e_map_destroy): Use - g_signal_handlers_disconnect_by_func since - gtk_signal_disconnect_by_data doesn't seem to work right. - (e_map_set_scroll_adjustments): Likewise. - -2003-02-25 Jeffrey Stedfast <fejj@ximian.com> - - * e-dateedit.c (on_date_popup_date_selected): Same as below. - - * e-cell-date-edit.c (e_cell_date_edit_on_ok_clicked): Also - updated to use the new GDate API from glib 2.0 - - * test-calendar.c (on_selection_changed): Fixed to use glib 2.0's - GDate API. - - * e-calendar-item.c (e_calendar_item_get_week_number): Port to - glib 2.0's GDate API. - (e_calendar_item_set_selection): Same. - - * e-search-bar.c (append_xml_menu_item): Use - g_string_append_printf instead of g_string_sprintfa since the - latter is now deprecated. - (setup_bonobo_menus): Same. - - * e-filter-bar.c (do_advanced): Use gtk_window_set_resizable() - - * e-charset-picker.c: Fixes to make it build cleanly with - -DG_DISABLE_DEPRECATED - (add_charset): Escape _'s so we don't get underline weirdness due - to GtkLabel thinking the _ means to underline the next char. - (e_charset_picker_bonobo_ui_populate): Same here. - -2003-02-20 Dan Winship <danw@ximian.com> - - * Makefile.am: Make libemiscwidgets and libefilterbar dynamic - libraries instead of static so they can be portably linked into - the shlib components - -2003-02-05 Dan Winship <danw@ximian.com> - - * Makefile.am (INCLUDES): Define MAP_DIR in terms of $(imagesdir). - (widgetsincludedir): Define in terms of $(privincludedir) - -2003-02-02 Hans Petter Jansson <hpj@ximian.com> - - * e-calendar-item.[ch]: Use Pango to draw. - (e_calendar_item_class_init): Add font_desc and week_number_font_desc - args. - (e_calendar_item_get_arg): Ditto. - (e_calendar_item_set_arg): Ditto. - (e_calendar_item_draw_month): Use Pango. - (e_calendar_item_draw_day_numbers): Ditto. - - * e-calendar.c: Use Pango to draw. Specify just the size of the small - font to use, instead of all aspects of it. - (e_calendar_init): Produce the small font description and pass it to - the ECalendarItem. - -2003-02-01 Hans Petter Jansson <hpj@ximian.com> - - * e-dateedit.c (create_children): Don't request combo boxes that are - 0 pixels tall. - (position_date_popup): Make this work when the button doesn't have - its own window. - -2003-01-26 Chris Toshok <toshok@ximian.com> - - * e-clipped-label.c (e_clipped_label_new): init the layout to - NULL. - -2003-01-23 Ettore Perazzoli <ettore@ximian.com> - - * e-title-bar.c (e_title_bar_construct): Make the label bold using - the new args to e_clipped_label_new(). - - * e-clipped-label.c (build_layout): Honor ->font_size and ->layout - in the newly created PangoLayout. - (e_clipped_label_new): New args font_weight, font_size. - (e_clipped_label_size_request): Removed unused variables. - (e_clipped_label_expose): Likewise. - (e_clipped_label_expose): Likewise. - (e_clipped_label_set_text): Likewise. - (e_clipped_label_recalc_chars_displayed): Likewise. - - * e-clipped-label.h (struct _EClippedLabel): Add font_size, layout - members. - -2003-01-22 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (widgetsincludedir): Version using $(BASE_VERSION). - -2003-01-14 Ettore Perazzoli <ettore@ximian.com> - - * e-multi-config-dialog.c (init): Change dialog from - OK/Apply/Cancel to Apply/Close/OK to be closer to the HIG. - -2003-01-14 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (widgetsinclude_HEADERS): Ooops, remove - e-bonobo-widget.h. - (libemiscwidgets_a_SOURCES): Likewise, remove e-bonobo-widget.c. - -2003-01-14 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am (EXTRA_DIST): e-util-marshal.list, not - e-book-marshal.list. - (widgetsinclude_HEADERS): Add e-bonobo-widget.h. - (libemiscwidgets_a_SOURCES): Add e-bonobo-widget.c. - -2003-01-08 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Images are now in $(datadir)/evolution/images - instead of $(datadir)/images/evolution. - -2002-12-10 Not Zed <NotZed@Ximian.com> - - * e-multi-config-dialog.c (impl_response): Removed the - g_assert_not_reached(). If you hit the close button on your - window it would abort, treat same as close. - -2002-12-09 Chris Toshok <toshok@ximian.com> - - * e-clipped-label.[ch]: rework this to be faster and deal more - correctly with the ellipsis. - -2002-12-03 Not Zed <NotZed@Ximian.com> - - * e-search-bar.c (impl_dispose): dispose can be run multiple times - too ... bloody gobject crap. - -2002-11-27 Not Zed <NotZed@Ximian.com> - - * e-charset-picker.c: Add include of gnome-dialog.h - - * *.[ch]: ran fix.sh script over everything. - -2002-11-26 Not Zed <NotZed@Ximian.com> - - * e-combo-button.c (impl_button_press_event): Dont grab_add - anymore on the button, gtk_button is changed in gtk2 not to do - this anymore. - -2002-11-15 Chris Toshok <toshok@ximian.com> - - * e-clipped-label.c (build_layout): new function, build pango - layout for string. - (e_clipped_label_size_request): pango-ize this, make the size - requested dependent on the label. - (e_clipped_label_expose): pango-ize this. - (e_clipped_label_recalc_chars_displayed): pango-ize this. - -2002-11-14 Ettore Perazzoli <ettore@ximian.com> - - * e-clipped-label.c (e_clipped_label_finalize): New. - (e_clipped_label_destroy): Removed. - - * e-title-bar.c (destroy): Removed. - (impl_finalize): New. - (class_init): Install GObject::finalize handler instead of - GtkObject::destroy handler. - -2002-11-14 Ettore Perazzoli <ettore@ximian.com> - - * e-filter-bar.c: Changed to use g_object_*() and g_signal_*() - functions instead of gtk_object_*() and gtk_signal_*(). - (destroy): Removed. - (dispose): New. - (class_init): Install GObject::dispose handler instead of - GtkObject::destroy handler. - -2002-11-11 Chris Toshok <toshok@ximian.com> - - * e-dateedit.[ch]: port to GObject. - -2002-11-11 Ettore Perazzoli <ettore@ximian.com> - - * e-multi-config-dialog.c (init): Use GObject functions instead of - GtkObject throughout. - -2002-11-11 Ettore Perazzoli <ettore@ximian.com> - - * e-multi-config-dialog.c (impl_destroy): Removed. - (impl_finalize): New. - (class_init): Override GObject::finalize, not GtkObject::destroy. - - * e-config-page.c (impl_destroy): Removed. - (impl_finalize): New. - (class_init): Override GObject::finalize, not GtkObject::destroy. - - * e-multi-config-dialog.c: Converted to a GtkDialog subclass - [instead of GnomeDialog]. - -2002-11-07 JP Rosevear <jpr@ximian.com> - - * e-filter-bar.c: include gnome-dialog.h - -2002-11-06 Chris Toshok <toshok@ximian.com> - - * .cvsignore: ignore the generated marshal source. - - * Makefile.am: add marshal stuff. - - * e-util-marshal.list: marshaller list. - - * e-search-bar.[ch]: gobjectify this. - -2002-11-04 Ettore Perazzoli <ettore@ximian.com> - - * e-combo-button.c (impl_expose_event): Use - gtk_container_propagate_expose(). - -2002-11-01 Ettore Perazzoli <ettore@ximian.com> - - * test-title-bar.c: #include <libgnomeui/gnome-ui-init.h> instead - of <libgnomeui/gnome-init.h>. - (main): Use a GtkLabel, not a GtkText. - - * test-dropdown-button.c: #include <libgnomeui/gnome-ui-init.h> - instead of <libgnomeui/gnome-init.h>, and - <libgnomeui/gnome-stock-icons.h> instead of - <libgnomeui/gnome-stock.h>. - - * test-dateedit.c: #include <libgnomeui/gnome-ui-init.h> instead - of <libgnomeui/gnome-init.h>. - (main): Use gnome_program_init(). - - * test-calendar.c: #include <libgnomeui/gnome-ui-init.h>. - - * e-url-entry.c (button_clicked_cb): Pass NULL as the error arg to - gnome_url_show(). - - * e-title-bar.c (class_init): GTK2-ified. Use GTK_TYPE_POINTER - instead of GTK_TYPE_GDK_EVENT. - - * e-search-bar.c: Removed #include <libgnome/gnome-defs.h>. - #include <string.h>. - (class_init): GTK2-ified. - (e_search_bar_set_menu): Use GTK_OBJECT_GET_CLASS. - (e_search_bar_set_option): Likewise. - - * e-messagebox.c (e_message_box_class_init): Updated to put - finalize in GObjectClass intead of GtkObjectClass. - (e_message_box_finalize): Likewise. - (e_message_box_construct): Just check if pixmap is NULL, instead - of pixmap->pixmap. - - * e-messagebox.h: No {BEGIN,END}_GNOME_DECLS. - (e_message_box_get_type): Fix prototype, should return GtkType - instead of guint. - - * e-map.c: Removed e_map_signals, which was unused. - (e_map_finalize): Update for the fact that finalize is now in - GObjectClass. - (e_map_class_init): Likewise. Also GTK2-ify. - (e_map_draw): Removed. - (load_map_background): Pass NULL as the gdk_pixbuf_new_from_file() - error arg. - - * e-dropdown-button.c (menu_position_cb): Added arg push_in. - - * e-dateedit.c (e_date_edit_class_init): GTK2-ified. - (e_date_edit_show_date_popup): Constify local variable. - (e_date_edit_check_date_changed): Likewise. - (e_date_edit_check_time_changed): Likewise. - (e_date_edit_check_date_changed): Likewise. - (field_set_to_none): Constify arg text. - (e_date_edit_parse_date): Constify arg date_text. - (e_date_edit_parse_time): Constify arg time_text. - - * e-dateedit.h: No {BEGIN,END}_GNOME_DECLS. - - * e-combo-button.c (menu_position_func): New arg push_in. - (impl_draw): Removed. - (class_init): GTK2-ified. - (init): style->xthickness instead of style->klass->xthickness. - - * e-config-page.c (class_init): GTK2-ified. - - * e-clipped-label.c (e_clipped_label_size_request): Use - gtk_style_get_font(). - (e_clipped_label_recalc_chars_displayed): Likewise. - (e_clipped_label_expose): Likewise. - - * e-charset-picker.c: No #include <libgnome/gnome-defs.h> or - <libgnome/gnome-i18n.h> or <libgnome/gnome-stock.h>. Also no - <gal/gunicode.h>. On the other hand, #include <gtk/gtkvbox.h>. - (e_charset_picker_new): Make locale_charset const. - (e_charset_picker_bonobo_ui_populate): Make locale_charset const. - - * e-cell-percent.c: #include <stdio.h> for sscanf(). - - * e-cell-percent.h: Removed BEGIN_GNOME_DECLS, END_GNOME_DECLS. - - * e-cell-percent.c: Do not #include <libgnomeui/gnome-stock.h>. - - * e-cell-date-edit.c: Do not #include <libgnomeui/gnome-stock.h>. - Added a bunch of #includes for GTK stuff. - (e_cell_date_edit_on_ok_clicked): Constified variable. - - * e-calendar-item.c: Do not #include <libgnome/gnome-defs.h>. - (e_calendar_item_class_init): Use GTK_TYPE_POINTER instead of - GTK_TYPE_GDK_POINTER. - (e_calendar_item_class_init): GTK_CLASS_TYPE() instead of - object_class->type. - (e_calendar_item_class_init): No gtk_object_class_add_signals(). - (e_calendar_item_update): style->[xy]thickness instead of - style->klass->[xy]thickness. - (e_calendar_item_draw): Likewise. - (e_calendar_item_draw_month): Likewise. - (e_calendar_item_draw_month): Likewise. - (e_calendar_item_recalc_sizes): Likewise. - (e_calendar_item_convert_position_to_day): Likewise. - (e_calendar_item_update): Use gtk_style_get_font(). - (e_calendar_item_draw_month): Likewise. - (e_calendar_item_draw_day_numbers): Likewise. - (e_calendar_item_convert_position_to_day): Likewise. - (e_calendar_item_recalc_sizes): Likewise. - (e_calendar_item_signal_emission_idle_cb): Removed check for - GTK_OBJECT_DESTROY. - (e_calendar_item_position_menu): Add push_in arg. - - * e-calendar.c (e_calendar_draw): Remove. - (e_calendar_size_request): style->[xy]thickness instead of - style->klass->[xy]thickness. - (e_calendar_size_allocate): Likewise. - (e_calendar_get_border_size): Likewise. - (e_calendar_size_allocate): Get font from style with - gtk_style_get_font(). - - * e-calendar-item.h: #include <libgnomecanvas/gnome-canvas.h> - instead of <libgnomeui/gnome-canvas.h>. - * e-calendar.c: Likewise for - <libgnomecanvas/gnome-canvas-widget.h>. - - * Makefile.am: Don't compile e-bonobo-widget.c, e-bonobo-widget.h. - [Unused right now, so we can avoid porting until, and if, they are - needed.] - - * e-filter-bar.c: Do not #include <libgnome/gnome-defs.h>. Do not - #include <libgnomeui/gnome-stock.h>. #include <gtk/gtksignal.h>. - Also remove gal #includes. - (do_advanced): Add some GTK_SIGNAL_FUNC() casts. - (menubar_activated): Likewise. - (menubar_activated): Likewise. - -2002-10-30 Ettore Perazzoli <ettore@ximian.com> - - * e-map.h: Do not #include <libgnome/gnome-defs.h>. - -2002-10-28 Jeffrey Stedfast <fejj@ximian.com> - - * e-search-bar.c (clear_search): Emit a search_activated signal. - (e_search_bar_set_item_id): Revert to original implementation. - -2002-10-23 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (option_changed): If the clear button was - pressed, we want the entry to be sensitive (not insensitive). - - * e-search-bar.c (e_search_bar_set_item_id): If the item id is - CLEAR_ID, we want to select the first item (0) but still set the - esb->item_id to CLEAR_ID. - (set_find_now_sensitive): Don't bother getting the GtkEntry text, - we don't even use it? - (clear_search): Set the item id as E_SEARCHBAR_CLEAR_ID rather - than 0 so that it can be checked for. - -2002-10-23 Ettore Perazzoli <ettore@ximian.com> - - [#26128, thanks to Federico Mena Quintero <federico@ximian.com> - for providing this fix.] - - * e-search-bar.c (activate_by_subitems): gtk_widget_grab_focus() - on the entry when adding it in. - -2002-10-11 JP Rosevear <jpr@ximian.com> - - * e-calendar-item.c (e_calendar_item_ensure_days_visible): check - if the selection fits in the leftover days - -2002-09-30 Ettore Perazzoli <ettore@ximian.com> - - [Add a small delay to the switching of pages in the multi-config - dialog. This makes keyboard navigation slightly nicer, and also - happens to fix mysterious bug #28931.] - - * e-multi-config-dialog.c: New constant SWITCH_PAGE_INTERVAL. New - members set_page_timeout_id and set_page_timeout_page in - EMultiConfigDialogPrivate. - (init): Initialize new member variables. - (table_cursor_change_callback): Set up a timeout instead of - switching right away. - (set_page_timeout_callback): Timeout function to switch page after - a small delay. - (impl_destroy): Remove a pending timeout. - -2002-09-27 Ettore Perazzoli <ettore@ximian.com> - - * e-multi-config-dialog.c (create_page_container): Don't set up - the description label here. - -2002-09-24 Not Zed <NotZed@Ximian.com> - - * e-search-bar.c (clear_search): Clear search by setting text to - "" and search to first search. - - * e-filter-bar.c (option_changed): Revert change of 2002-08-29 - below, always do advanced search if we have the advanced id. - Handle clear elsewhere. - (menubar_activated): If we get the advanced menu, set the advanced - option menu, and let that handle it, rather than doing it - ourselves. For #31060 & #29625. - -2002-09-22 Dan Winship <danw@ximian.com> - - * e-filter-bar.c: Fix some non-ANSI switch statements. - -2002-08-29 Chris Toshok <toshok@ximian.com> - - * e-search-bar.c (subitem_activated_cb): need to make the find now - button sensitive when you select something from a submenu. - -2002-08-29 Peter Williams <peterw@ximian.com> - - * e-filter-bar.c (option_changed): If the item is ADVANCED_ID, check - the query and efb->setquery to see whether we should pop up the advanced - dialog or clear an advanced search. Fixes #29625. - -2002-08-21 Peter Williams <peterw@ximian.com> - - * e-search-bar.c (clear_search): Don't set the item id; clear search - isn't in the menu anymore. Fixes #29211. - -2002-08-22 JP Rosevear <jpr@ximian.com> - - * e-dateedit.c (e_date_edit_parse_date): don't adjust for two - digit dates here, the e_time_parse routines do that now - -2002-08-06 Not Zed <NotZed@Ximian.com> - - * e-filter-bar.c (menubar_activated): Set the query text into the - filter name when saving it, for #10979. - -2002-07-24 Ettore Perazzoli <ettore@ximian.com> - - * e-calendar-item.c (e_calendar_item_signal_emission_idle_cb): Add - missing cast. - (e_calendar_item_signal_emission_idle_cb): Likewise. - - * e-search-bar.c (init): Don't initialize dropdown_menu here - anymore since we got rid of it. - - * e-search-bar.h (struct _ESearchBar): Removed member - dropdown_menu. - -2002-07-22 Peter Williams <peterw@ximian.com> - - * e-filter-bar.c (do_advanced): Break out the code for creating - the advanced rule editor into a separate function, so that... - (menubar_activated): ... can also create an Advanced dialog; - needed when the Search menu's advanced button is used. - (option_changed): Change this to call the function instead of - having all the code to itself. - - * e-search-bar.h: Add id's for the FIND_NOW and CLEAR actions - so that other code (eg, EFilterBar) doesn't get confused by - an old id being used when the search-activated signal gets - emitted. - - * e-search-bar.c (clear_search): Set the item_id to CLEAR - before emitting the signal. - (search_now_verb_cb): Just make this emit query_changed, - as the button in the toolbar does. - -2002-07-17 Ettore Perazzoli <ettore@ximian.com> - - [Fix #27854, spurious warnings from ESearchBar.] - - * e-search-bar.c (setup_standard_verbs): Set the <commands> part - of the XML manually with bonobo_ui_component_set() otherwise the - verbs don't get added on the other side for us to be able to do - bonobo_ui_component_set_prop(). - (setup_bonobo_menus): New, menu setup code taken from - update_bonobo_menus(). - (remove_bonobo_menus): New; removes the Bonobo menus. - (update_bonobo_menus): Rewritten, just call remove_bonobo_menus() - first and setup_bonobo_menus() then. - (e_search_bar_set_ui_component): Call setup_bonobo_menus() and - remove_bonobo_menus() as appropriate instead of just - update_bonobo_menus(). - -2002-07-02 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (update_sensitivity): Removed. - (set_find_now_sensitive): New. - (entry_changed_cb): Always make the "Find Now" button and menu - item sensitive here. - (emit_search_activated): ...And here, always insensitive. - (setup_standard_verbs): Always start up insensitive. - (activate_button_clicked_cb): Make the entry grab the focus. - (clear_button_clicked_cb): Likewise. - -2002-07-02 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (subitem_activated_cb): Don't emit - "search_activated" here. - (e_search_bar_set_subitem_id): And not here either. - (e_search_bar_set_text): Same. - -2002-07-02 Ettore Perazzoli <ettore@ximian.com> - - [Fix #7736.] - - * e-search-bar.c (activate_by_subitems): Don't set the entry to be - an empty string here. - -2002-06-18 Ettore Perazzoli <ettore@ximian.com> - - * e-filter-bar.c (build_items): Put the numbers in front of the - rules only if type is zero [i.e. not in the option menu]. - -2002-05-30 Ettore Perazzoli <ettore@ximian.com> - - * e-filter-bar.c (dup_item_no_subitems): New helper function. - (build_items): g_strdup() the text for all the items. Prepend the - user-defined items with an order number. - (free_built_items): New function to free the array returned by - build_items, freeing the text strings too [since now they are - newly allocated instead of just pointing to the exiting ones]. - (generate_menu): Call free_built_items() on the built items - instead of just g_array_free(). - (set_option): Likewise. - -2002-05-22 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (update_bonobo_menus): Put the stuff in - /menu/Searchplaceholder/Search instead of /menu/Search. - - * e-combo-button.c (impl_draw): New, overrides GtkWidget::draw. - (impl_expose_event): New, overrides GtkWidget::expose_event. - -2002-05-20 Ettore Perazzoli <ettore@ximian.com> - - * e-filter-bar.c (build_items): Prepend the advanced menu with a - separator. - - * e-filter-bar.h: Add E_FILTERBAR_SEPARATOR. Rename the "Advanced - Search..." menu item into "Advanced...". - -2002-05-20 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (activate_by_subitems): Strip underscores from - the menu item labels. - -2002-04-26 Christopher James Lahey <clahey@ximian.com> - - * e-multi-config-dialog.c (fill_in_pixbufs): Don't print out the - colors here unless debugging is turned on. - -2002-04-22 Christopher James Lahey <clahey@ximian.com> - - * e-multi-config-dialog.c (e_multi_config_dialog_add_page): - Updated this to match the changed function name in gal. - -2002-04-09 Dan Winship <danw@ximian.com> - - * e-search-bar.c (e_search_bar_construct, add_button): Oops. The - previous change made the search bar widgets get packed in the - wrong order. So use gtk_box_pack_end instead in add_button and add - the two buttons in reverse order. It's all good now. Noticed by - Ettore, who I then promptly blamed for it. Sorry Ettore! - -2002-04-08 Dan Winship <danw@ximian.com> - - * e-search-bar.c (e_search_bar_construct): Construct the buttons - earlier so that the option-menu-setup code that tries to adjust - the button sensitivity won't fail and g_warn. - -2002-04-06 JP Rosevear <jpr@ximian.com> - - * e-multi-config-dialog.c (e_multi_config_dialog_show_page): show - a specific page number - - * e-multi-config-dialog.h: new proto - -2002-03-29 Ettore Perazzoli <ettore@ximian.com> - - * e-multi-config-dialog.c: Change the ETable specs so it doesn't - sort. - -2002-03-20 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (update_bonobo_menus): Add accelerators for "Find - Now" and "Clear". - - * e-filter-bar.h: Change search labels as suggested in Anna's - redesign [#16246]. - -2002-03-20 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (update_bonobo_menus): Remove all the SearchBar - items before setting them up again. - (free_menu_items): New. - (impl_destroy): Call it. - (set_menu): Call it here too before adding the new items. - -2002-03-18 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (verb_name_from_id): New. - (e_search_bar_set_menu_sensitive): Rewritten using it. - -2002-03-18 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (update_bonobo_menus): No accelerator for - "FindNow". - (add_button): Add a one-pixel padding to the button. - -2002-03-18 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (update_bonobo_menus): Rename the "Search Now" - menu entry to "Find Now". Rename the corresponding verb to - "ESearchBar:FindNow". - (update_sensitivity): Updated accordingly. - (setup_standard_verbs): Likewise. - -2002-03-18 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (update_sensitivity): New halper function to - update the sensitivity of the commands. - (entry_changed_cb): New callback to make the activate_button and - the "Find Now" verb sensitive only if the entry has some contents. - (activate_by_subitems): Connect the callback here. - (setup_standard_verbs): Call update_sensitivity() here. - -2002-03-18 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (init): Init clear_button to NULL. - (add_button): New helper function to add a button to the search - bar with the right spacing etc. - (clear_search): New helper function. - (add_activate_button): Removed. - (clear_button_clicked_cb): New. - (e_search_bar_construct): Just add the button here using - `add_button'. Also add a clear_button. - (clear_verb_cb): Rewritten by means of `clear_search()'. - - * e-search-bar.h (ESearchBar): Add clear_button. - -2002-03-18 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (search_now_verb_cb): New, implementation for a - new "SearchNow" verb. - (setup_standard_verbs): Create verb here. - (update_bonobo_menus): Add SearchNow menu item. - -2002-03-18 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (clear_verb_cb): New. - (setup_standard_verbs): New. - (e_search_bar_set_ui_component): Call it if a new - BonoboUIComponent is set. - (append_xml_menu_item): New helper function. - (update_bonobo_menus): Use it. Also add a "Clear" menu item. - (e_search_bar_construct): @menu_items can be NULL now. - (e_search_bar_new): Same here. - (set_menu): Work with NULL items. - - * e-filter-bar.c (menubar_activated): Don't handle - E_FILTERBAR_RESET_ID anymore. - - * e-filter-bar.h: Remove `E_FILTERBAR_RESET_ID' and `E_FILTERBAR_RESET'. - -2002-03-15 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (init): Init various members to NULL. - (set_dropdown): Removed. - (add_dropdown): Removed. - (set_menu): New. - (add_menu_items): New. - (set_option): No need to setup the dropdown size here anymore. - (verb_cb): Function implementing the search menu verbs. - (update_bonobo_menus): New. - (e_search_bar_set_ui_component): New. - - * e-search-bar.h: Remove the dropdown button stuff from struct - ESearchBar. Add `uic' and `items' members. - - * e-filter-bar.c (e_filter_bar_new): Get a @uic arg. - -2002-03-15 Christopher James Lahey <clahey@ximian.com> - - * e-multi-config-dialog.c (init): Set horizontal scroll policy to - GTK_POLICY_NEVER here. Don't set usize here. Changed RGBA_COLOR - to RGB_COLOR. Turned on horizontal resize. - -2002-03-13 Jeffrey Stedfast <fejj@ximian.com> - - * e-charset-picker.c (add_charset): If the charset item doesn't - have a class (aka "Unknown"), don't write a class name, instead - just give the charset name as the menu item label. Fixes bug - #14753. - -2002-03-13 Christopher James Lahey <clahey@ximian.com> - - * e-multi-config-dialog.c: Added alpha blending here. - -2002-03-12 Christopher James Lahey <clahey@ximian.com> - - * e-multi-config-dialog.c: Removed Page struct. - (e_multi_config_dialog_add_page): Select the initial row after - appending to the model. - -2002-03-12 Christopher James Lahey <clahey@ximian.com> - - * e-multi-config-dialog.c (init): Use Use e_table_memory_store - instead of e_table_memory_callbacks. Use e_cell_vbox to include a - pixbuf cell and a text cell. - -2002-03-11 Ettore Perazzoli <ettore@ximian.com> - - * e-multi-config-dialog.c (init): Use GNOME_STOCK_BUTTON_CLOSE, - not GNOME_STOCK_BUTTON_CANCEL. - (do_close): Renamed from `cancel'. - (do_apply): Renamed from `apply'. - (do_ok): Renamed from `ok'. - -2002-03-09 Ettore Perazzoli <ettore@ximian.com> - - * e-multi-config-dialog.c: Rename Page.widget -> Page.page_widget; - it is now an EConfigPage instead of just a GtkWidget. Add - `num_unapplied' to EMultiConfigDialogPrivate. Derive from - GnomeDialog, not GtkWindow. - (update_buttons): New function to update the sensitiveness of the - buttons according to whether all the settings have been applied or - not. - (page_new): Likewise. - (create_page_container): Renamed from `create_page_widget'. - (init): Add Apply/OK/Cancel buttons to the dialog. Init - ->num_unapplied to zero. - (page_changed_callback): New, callback for the page's "changed" - signal. - (e_multi_config_dialog_add_page): Connect the callback, update - ->num_unapplied, update the buttons by calling `update_buttons'. - (ok): New function for handling the OK button. - (apply): New function for handling the Apply button. - (cancel): New function for handling the Cancel button. - (impl_clicked): Implementation for the GnomeDialog's ::clicked - signal. - (class_init): Install. - - * test-multi-config-dialog.c (add_pages): Update to use - EConfigPages instead of plain GtkWidgets. - - * e-multi-config-dialog.c, e-multi-config-dialog.h: Derive from - GnomeDialog, not GtkWindow. - - * e-config-page.c: New. - * e-config-page.h: New. - -2002-03-07 Ettore Perazzoli <ettore@ximian.com> - - * e-multi-config-dialog.c: Don't display a header in the table on - the left. - -2002-03-05 Ettore Perazzoli <ettore@ximian.com> - - * test-multi-config-dialog.c: New. - * test-multi-config-dialog.h: New. - - * e-multi-config-dialog.c: New. - * e-multi-config-dialog.h: New. - -2002-02-24 Chris Toshok <toshok@ximian.com> - - * e-filter-bar.c (init): preserve behavior - hook search_activated - signal to the same function as query_changed. - - * e-search-bar.c (emit_search_activated): new function. - (entry_activated_cb): use emit_search_activated instead of - emit_query_changed. - (subitem_activated_cb): same. - (activate_button_clicked_cb): same. - (class_init): add the search_activated signal. - (idle_activate_hack): rename idle_change_hack to this, and - emit_search_activated. - (e_search_bar_construct): idle_change_hack -> idle_activate_hack. - (e_search_bar_set_subitem_id): emit_search_activated instead of - emit_query_changed. - (e_search_bar_set_text): same. - - * e-search-bar.h (struct _ESearchBarClass): add a search_activated - signal. - -2002-02-21 Ettore Perazzoli <ettore@ximian.com> - - * e-combo-button.c (set_icon): gtk_widget_show() the icon_pixmap - if the specified icon is not NULL. - -2002-02-20 Ettore Perazzoli <ettore@ximian.com> - - * e-combo-button.c (set_icon): Work with a NULL @pixbuf as well - [in that case, just hide the current icon widget]. - (e_combo_button_set_icon): Remove the precondition about @pixbuf - being non-NULL. - -2002-02-08 JP Rosevear <jpr@ximian.com> - - * e-url-button.[hc]: remove briefly used files - -2002-02-08 JP Rosevear <jpr@ximian.com> - - * e-url-entry.[hc]: button/entry combo that launchs the gnome url - handler on the entry text when the button is clicked - - * Makefile.am: build new files - -2002-02-08 JP Rosevear <jpr@ximian.com> - - * Makefile.am: build new files - - * e-url-button.[hc]: button widget that when clicked slurps the - url of an entry and launchs the gnome url handler on the text - -2002-01-27 Ettore Perazzoli <ettore@ximian.com> - - * Makefile.am: Use GNOME_FULL_CFLAGS and GNOME_FULL_LIBS. - -2002-01-23 Ettore Perazzoli <ettore@ximian.com> - - * e-combo-button.c: Remove member `separator' from - `EComboButtonPrivate'. New members `icon', `label'. - (init): There shall be no separator no more. Init `icon' and - `label' to %NULL. - (e_combo_button_construct): Set no relief. - (e_combo_button_new): Don't get a @menu arg anymore. - (e_combo_button_construct): Likewise. - (e_combo_button_set_icon): New. - (e_combo_button_set_label): New. - (e_combo_button_set_menu): New. - (impl_clicked): New, overriding the "clicked" method for - GtkButton. - (class_init): Install. - (impl_button_release_event): Removed. - (class_init): No need to override ::release_event with this - anymore. - (impl_released): New, override for the GtkButton::released method. - (class_init): Install. - -2002-01-04 Jeffrey Stedfast <fejj@ximian.com> - - * e-charset-picker.c: Added iso-8859-8 (Hebrew; Visual) to the - list of charsets in the menu. Fixes bug #15655. - -2001-12-20 Ettore Perazzoli <ettore@ximian.com> - - * e-combo-button.c: New. - * e-combo-button.h: New. - -2001-11-21 Not Zed <NotZed@Ximian.com> - - * e-filter-bar.c (menubar_activated): Mark the dialogue as already - up so we dont allow multiple dialogues up. Behaviour fix part of - #15745. - -2001-11-28 Damon Chaplin <damon@ximian.com> - - * e-map.c: updated to new version from Ximian Setup Tools. - Fixes bug #7641. - -2001-11-27 Damon Chaplin <damon@ximian.com> - - * e-dateedit.c (e_date_edit_get_date): if allow_no_date_set is FALSE, - return the last valid date entered, even if the field is currently - empty. Fixes bug #15749. - -2001-11-05 JP Rosevear <jpr@ximian.com> - - * e-dateedit.c (e_date_edit_set_date_and_time_of_day): set both - the date and the time of day in one call, creating only a single - changed signal - - * e-dateedit.h: add proto - -2001-11-05 Christopher James Lahey <clahey@ximian.com> - -Based on a patch by Damon Chaplin <damon@ximian.com> - - * e-cell-date-edit.c: Connect to the button_press signal on the - popup and do the grab correctly so that this dialog behaves - properly when the user clicks it away. Also, changed all - instances of setting of popup_shown field of ECellPopup to call - e_cell_popup_set_shown. Fixes Ximian bug #14016. - -2001-10-31 <NotZed@Ximian.com> - - * e-filter-bar.c (build_items): Snotty code so we only disconnect - to rules we no longer have, etc. - -2001-11-01 Not Zed <NotZed@Ximian.com> - - * e-filter-bar.c (build_items): Ref and connect to rule changed - here, also clear out previous ref's. - (generate_menu): No longer connect to rules, or reset rule array. - (set_option): Dont reset option rules array. - (context_rule_removed): Disconnect changed event on rule. - (clear_rules): Fujnction to clear rules from an array. - (destroy): Disconnect from context signals, and clear rules arrays. - - * e-filter-bar.h: Remove hash table for change id's. - -2001-10-30 Damon Chaplin <damon@ximian.com> - - * e-dateedit.c (e_date_edit_set_time_of_day): emit signal when time - set to none/empty. - -2001-10-30 <NotZed@Ximian.com> - - * e-filter-bar.c (generate_menu): Hook to rule changed events. - (destroy): Free change id table/unconnect to signals. - (init): Setup change id table. - (e_filter_bar_new): Hook onto rule removed signal. - (context_rule_removed): If rule removed, disconnect from signal handler. - (rule_changed): For changed rules, also rebuild menu. Fixed #12233. - -2001-10-30 Damon Chaplin <damon@ximian.com> - - * e-cell-date-edit.c (e_cell_date_edit_set_popup_values): try to parse - just a date first, and if that works we assume it is a DATE value, - so we clear the time field in the popup. - (e_cell_date_edit_on_ok_clicked): if the time field is empty, use a - DATE value. - Also removed some debug messages. - -2001-10-30 <NotZed@Ximian.com> - - * e-filter-bar.c (set_option): Set the item to the option_base on - it, so the current item is set. Fix for #7081. - -2001-10-30 Christopher James Lahey <clahey@ximian.com> - - * e-cell-date-edit.c (e_cell_date_edit_get_popup_pos): Adapt to - the new ECellPopup signature. - -2001-10-29 Damon Chaplin <damon@ximian.com> - - * e-calendar-item.c (e_calendar_item_signal_emission_idle_cb): ref - the ECalendarItem and check if it gets destroyed, to try to avoid a - free memory write. - - * e-dateedit.c (e_date_edit_set_time_of_day): allow setting the time - to empty by passing hour as -1. - -2001-10-23 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (rule_editor_clicked): Don't add the menu item - here, do this in the context_changed signal callback instead. - (context_changed): rebuild the search menu. - (set_menu): Copy the items into a default_items list so we can - regenerate the menu when something changes. Then call - generate_menu(). - (generate_menu): Do what set_menu() used to do. - (e_filter_bar_new): Don't do a rule_context_load() anymore since - we don't need to. - (destroy): free the default_items list. - -2001-10-23 Damon Chaplin <damon@ximian.com> - - * e-search-bar.c (copy_subitems): copy the translate field over as - well. Should fix an uninitialized memory read. - -2001-10-23 Damon Chaplin <damon@ximian.com> - - * e-dateedit.c (e_date_edit_check_date_changed): - (e_date_edit_check_time_changed): clear the struct tm fields to keep - purify happy. - -2001-10-22 Damon Chaplin <damon@ximian.com> - - * e-cell-date-edit.c (e_cell_date_edit_set_popup_values): - (e_cell_date_edit_update_cell): use the new ECellText methods to get - the text and set the value. - - * e-cell-percent.c: new subclass of ECellText to display & edit a - percentage value. - -2001-10-20 Jon Trowbridge <trow@ximian.com> - - * e-dateedit.c (e_date_edit_check_date_changed): Keep us from - reading tmp_tm uninitialized, so purify won't complain. - -2001-10-09 Jeffrey Stedfast <fejj@ximian.com> - - * e-charset-picker.c (e_charset_picker_bonobo_ui_populate): Now - takes a menu path argument. - -2001-10-04 Rodrigo Moya <rodrigo@ximian.com> - - * Makefile.am: added BONOBO_GNOME_CFLAGS to make it compile with - latest Bonobo - -2001-10-04 Christopher James Lahey <clahey@ximian.com> - - * e-cell-date-edit.c (e_cell_date_edit_get_popup_pos): Call - gnome_canvas_world_to_window here. Finishes fixing Ximian bug - #2613. - -2001-09-18 Damon Chaplin <damon@ximian.com> - - * e-dateedit.c (e_date_edit_grab_focus): grab focus to the date entry - or the time entry, depending on which is visible. Fixes bug #7237. - -2001-09-16 Chris Toshok <toshok@ximian.com> - - * e-dateedit.h: add prototype for e_date_edit_set_editable. - - * e-dateedit.c (e_date_edit_set_editable): new function, analogous - to gtk_entry_set_editable: let's the user select but not edit (or - in this case, bring up the calendar view.) - -2001-09-13 Jeffrey Stedfast <fejj@ximian.com> - - * e-search-bar.c (set_dropdown): Don't unref the old dropdown, we - don't "own" it. - -2001-09-13 Larry Ewing <lewing@ximian.com> - - * e-search-bar.c (set_dropdown): unref the old dropdown_menu if - there is one. - -2001-09-12 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (menubar_activated): No longer need the context - in order to clone a FilterRule. - (option_changed): Same. - -2001-09-06 Anna Marie Dirks <anna@ximian.com> - - * e-filter-bar.c: added a default size for the saved search - dialog of 600 x 300 such that it opens at a usable size. - this fixes bug #7083. - -2001-09-05 Anna Marie Dirks <anna@ximian.com> - - * e-search-bar.c (add_activate_button): added a wee bit of - padding around the find now label in response to bug #7049. - -2001-08-23 Federico Mena Quintero <federico@ximian.com> - - * e-search-bar.c (e_search_bar_set_ids): New function to set the - item_id and the subitem_id simultaneously. - -2001-08-16 Damon Chaplin <damon@ximian.com> - - * e-dateedit.c: added e_date_edit_get/set_make_time_insensitive() - which makes the time field insensitive rather than hiding it. - I'm not sure we're going to actually use this now, though. - -2001-08-16 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (activate_by_subitems): Set the horizontal usize - of the entry to 4. - -2001-08-16 Jon Trowbridge <trow@ximian.com> - - * e-filter-bar.c (option_changed): Adjusted for renamed ESearchBar - functions. - (menubar_activated): Adjusted for renamed ESearchBar functions. - - * e-search-bar.c: Renames some of the horrible function names: - s/option_choice/item_id/, s/suboption_choice/subitem_id/. - -2001-08-14 Federico Mena Quintero <federico@ximian.com> - - * e-cell-date-edit.c (e_cell_date_edit_destroy): Destroy, do not - unref, the popup_window. - -2001-08-14 Federico Mena Quintero <federico@ximian.com> - - * e-search-bar.c (activate_by_subitems): Correctness fixes for - when the entry and submenu must be interchanged. - -2001-08-14 Federico Mena Quintero <federico@ximian.com> - - *Please* add accessor functions instead of just object arguments! - - * e-search-bar.c (e_search_bar_set_option_choice): New function. - (e_search_bar_set_suboption_choice): New function. - (e_search_bar_set_text): New function. - (impl_set_arg): Use the functions above instead of setting things - directly. - (add_dropdown): If the item is a separator, set it as insensitive. - (activate_by_subitems): Handle the translate field in the subitem - structure. Also, allow the creation of separators by having NULL - text strings in the subitems. - (set_option): If the item is a separator, set it as insensitive. - (set_option): Do not use the subitem_garbage hack. Do proper - memory management instead. - (e_search_bar_set_suboption): New function to change the suboption - items in a search bar. - - * e-search-bar.h (ESearchBarSubitem): Added a `translate' field. - This API sucks so much it is not funny. - (ESearchBar): Removed the subitem_garbage hack. Please do proper - memory management. - -2001-08-14 Jon Trowbridge <trow@ximian.com> - - * e-search-bar.c (activate_by_subitems): Oops... initial - suboption_choice should be subitems[0].id, not 0. - -2001-08-10 Jeffrey Stedfast <fejj@ximian.com> - - * e-search-bar.c (impl_destroy): Oops, we didn't need to unref all - of the widgets, just a few. - -2001-08-10 Jon Trowbridge <trow@ximian.com> - - * e-filter-bar.h: Set the subitems to NULL in the pre-defined - ESearchBarItems. - - * e-filter-bar.c (rule_editor_clicked): Set the ESearchBarItem's - subitems to NULL. - (build_items): Set the ESearchBarItem's subitems to NULL. - (e_filter_bar_new): Set the ESearchBarItem's subitems to NULL. - - * e-search-bar.c: Added support for subitems, so that a search - option can key off of another option menu rather than just an - entry. - -2001-08-10 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (destroy): Free all the goodies that we allocate - at construct time and unref the rule context. - (class_init): Override the destroy method. - -2001-08-09 Anna Marie Dirks <anna@ximian.com> - - Fixes bug #6918 - - * e-filter-bar.h: Changed the "Save As.." menu item to - "Add to Saved Searches". - -2001-08-09 Anna Marie Dirks <anna@ximian.com> - * e-filter-bar.h : changed the E_FILTERBAR_RESET label from - "Show All" to "Clear" to alleviate confusion about whether - "Show All" means that hidden messages are also shown or not. - (See ximian bug #6743) - -2001-08-09 Federico Mena Quintero <federico@ximian.com> - - * e-calendar-item.c (e_calendar_item_destroy): Chain to the - destroy handler in the parent class! - - * e-clipped-label.c (e_clipped_label_destroy): Likewise. Sigh. - - * e-dropdown-button.c (impl_destroy): Likewise. Double sigh. - -2001-08-08 Anna Marie Dirks <anna@ximian.com> - - * e-search-bar.c: Re-labeled the "Activate" button "Find Now". - -2001-08-08 Ettore Perazzoli <ettore@ximian.com> - - * e-bonobo-widget.c: New. - * e-bonobo-widget.h: New. - -2001-08-05 Ettore Perazzoli <ettore@ximian.com> - - [Added an "Activate" button to the search bar.] - - * e-search-bar.c (submit_button_clicked_cb): Callback for the - "clicked" signal on the activate button. - (add_submit): New function to add a "Activate" button on the right - of the entry. - (e_search_bar_construct): Call it. - (add_spacer): Removed. - (e_search_bar_construct): Don't call it. - (find_id): Remove debugging message. - (put_in_spacer_widget): New utility function to create a - GtkEventBox with a border width of one and put a widget into it. - -2001-08-04 Ettore Perazzoli <ettore@ximian.com> - - * e-title-bar.c: Make the close icon as large as the pin icon so - the bar doesn't change size when it switches between them. - (e_title_bar_construct): Add some horizontal padding to the label - to make it look nicer. - -2001-08-03 Federico Mena Quintero <federico@ximian.com> - - * e-calendar-item.c (e_calendar_item_mark_day): Request an update. - (e_calendar_item_mark_days): Likewise. - -2001-07-24 Damon Chaplin <damon@ximian.com> - - * e-calendar-item.c (e_calendar_item_show_popup_menu): don't show the - year in the popup submenu for the months, and center the months. - Fixes - -2001-07-18 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (rule_editor_destroyed): When the dialog gets - closed, always make sure the entry widget becomes sensitive again. - (menubar_activated): Don't use FILTER_SOURCE_INCOMING because - that's not what we want, we want (I think) NULL (at least with - NULL, bug #4490 goes away). - -2001-07-16 Federico Mena Quintero <federico@ximian.com> - - Fixes bug #2901. - - * e-dateedit.c (e_date_edit_parse_date): Use e_time_parse_date(). - (e_date_edit_parse_time): Use e_time_parse_time(). - -2001-07-17 jacob berkman <jacob@ximian.com> - - * e-search-bar.c (set_dropdown): don't unset _CAN_FOCUS - - * e-dropdown-button.c (menu_deactivate_cb): un-toggle ourself - (impl_toggled): override the toggled rather than clicked signal. - if we are active, popup the menu; else, popdown - - these fix ximian #2016 - -2001-07-02 Damon Chaplin <damon@ximian.com> - - * e-calendar-item.c: - * e-cell-date-edit.c: - * e-dateedit.c: added functions to set a callback to get the current - time, which is used instead of localtime(). We need this as we have to - use our own timezones. - -2001-07-02 Jeffrey Stedfast <fejj@ximian.com> - - * e-charset-picker.c (e_charset_picker_bonobo_ui_populate): Take a - callback function and user_data so that we can add listeners to - each of the menu items. - -2001-07-02 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am: Updated to build e-charset-picker.c - - * e-charset-picker.[c,h]: Moved here from gal. - (e_charset_picker_bonobo_ui_populate): New function to populate a - bonobo-ui with a charset picker menu. - -2001-06-14 Damon Chaplin <damon@ximian.com> - - * e-map.[hc]: copied the EMap widget verbatim from Ximian Setup Tools. - Hmm. Maybe it should go in gal, but its not a very general widget. - - * Makefile.am (INCLUDES): defined MAP_DIR for e-map.c. - (libemiscwidgets_a_SOURCES): added e-map.[hc]. - -2001-05-31 Federico Mena Quintero <federico@ximian.com> - - * e-dropdown-button.c (impl_button_press_event): Removed unused - variable. - - * e-cell-date-edit.c (e_cell_date_edit_rebuild_time_list): Removed - unused variable. - -2001-05-07 Gediminas Paulauskas <menesis@delfi.lt> - - * misc/e-filter-bar.h: xgettext does not find N_() in #defines. So - created fake enum. Also removed spaces before "..." - -2001-04-24 Kjartan Maraas <kmaraas@gnome.org> - - * e-calendar-item.c, e-calendar.c, e-cell-date-edit.c, - e-clipped-label.c, e-dateedit.c, e-dropdown-button: - Added #include <glib.h> and moved corresponding local headers - to the top. - -2001-04-15 Federico Mena Quintero <federico@ximian.com> - - * e-search-bar.c (e_search_bar_get_option_choice): New function, - because it is ridiculous to have to hunt down object arguments to - fetch values. - (e_search_bar_get_text): Likewise. - (impl_get_arg): Use the functions above so that we have to - maintain only one version of the getters. - -2001-04-04 Kjartan Maraas <kmaraas@gnome.org> - - * e-calendar.c: More header fixes. - * e-cell-date-edit.c: Same. - * e-dateedit.[ch]: Same. - * e-title-bar.c: Same here. - * e-search-bar.c: More header fixes. - * test-calendar.c: Same here. - -2001-03-29 Kjartan Maraas <kmaraas@gnome.org> - - * e-dropdown-button.c: Replace #include <gtk/gtk.h> - * e-dropdown-button.h: Remove #include <gnome.h> - * e-filter-bar.c: Replace #include <gtk/gtk.h> - * e-filter-bar.h: Replace #include <gtk/gtk.h> - * e-messagebox.c: Add #includes to count for removed <gnome.h> in - e-messagebox.h: - * e-messagebox.h: Replace #include <gnome.h> - * e-search-bar.c: Replace #include <gnome.h> - * e-search-bar.h: Same here - * test-calendar.c: Remove #include <gnome.h> - * test-dateedit.c: Replace #include <gnome.h> - * test-dropdown-button.c: Same here. - * test-title-bar.c: Same here. - -2001-03-22 Jeffrey Stedfast <fejj@ximian.com> - - * e-filter-bar.c (rule_editor_clicked): Validate the filter rule. - -2001-03-18 Damon Chaplin <damon@ximian.com> - - * e-cell-date-edit.c (e_cell_date_edit_show_time_invalid_warning): - use gnome_dialog_run() to make the warning dialog modal. Also created - a better warning message showing the format expected. - Also used e_time_format_time() to format all times. - -2001-03-15 Not Zed <NotZed@Ximian.com> - - * e-filter-bar.c (menubar_activated): If we click on the edit - menu, then bring up a rule editor. If the user adds/removes rules - though, they are neither saved, nor added to the menu's. sigh. - -2001-03-04 Damon Chaplin <damon@ximian.com> - - * e-cell-date-edit.c: pretty much working now. - -2001-03-01 Not Zed <NotZed@Ximian.com> - - * e-filter-bar.c: New type of search bar that interacts with - filter contexts to save filters etc. Still probably needs a - little cleanpu. - -2001-02-28 Not Zed <NotZed@Ximian.com> - - * e-search-bar.c (add_dropdown): Save the dropdown menu in the - struct too. Sigh, this is only so we can scan its content later, - ick. - (e_search_bar_set_menu_sensitive): New function to se tthe - sentisitivty of menyu items based on id. - (find_id): New function to find the row and widget for a specific - id. - (add_option): Renamed to set_option. - (add_dropdown): Renamed to set_dropdown. - (add_dropdown): ?New function to add a single item. - (set_dropdown): Call add_dropdown to add each item. - (e_search_bar_add_menu): New public function to add a single item. - -2001-02-27 Not Zed <NotZed@Ximian.com> - - * Makefile.am (libemiscwidgets_a_SOURCES): Added filter-bar.[ch]. - - * e-search-bar.c (class_init): Init virtual functions. - (e_search_bar_set_option): - (e_search_bar_set_menu): virtualise calling. - (e_search_bar_construct): Call virtual functions to setup menus. - - * e-search-bar.h (struct _ESearchBarClass): Virtualise - add_dropdown/add_option, so certain base options can be created. - -2001-02-25 Damon Chaplin <damon@ximian.com> - - * e-cell-date-edit.[hc]: new files to implement an ECell for showing - and editing dates & times. (Unfinished) - - * Makefile.am (libemiscwidgets_a_SOURCES): added e-cell-date-edit.[hc] - -2001-02-24 Not Zed <NotZed@Ximian.com> - - * e-search-bar.c (add_dropdown): Move the event box into the - esb->dropdown_holder. Changed so it can be called again on the - same esb, to rebuild the menu. - (e_search_bar_set_menu): New function to (re)set the menu. - (add_option): Setup so it can be re-called to rebuild the option - list. - (e_search_bar_set_option): New function to build the menu's. - -2001-02-05 Jeffrey Stedfast <fejj@ximian.com> - - * .cvsignore: Ignore test-dropdown-button - -2001-01-28 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (add_spacer): Make the spacer 4 pixels wider. - (add_dropdown): Put the dropdown button into an event box with a - 1-pixel border, so that we match the [Hardcoded! Stupid GTK+!] - border around the option menu. - -2001-01-28 Ettore Perazzoli <ettore@ximian.com> - - * e-dropdown-button.c (menu_deactivate_cb): New function to change - the state of the toggle button when the pop-up menu disappears. - (impl_clicked): Removed. - (impl_button_press_event): New, implementation for - `::button_press_event'. Pop-up the menu, and toggle the button. - (class_init): Override `::button_press_event' with - `impl_button_press_event'; don't override `::clicked' anymore. - - * e-dropdown-button.h, e-dropdown-button.c: Derive from - `GtkToggleButton', instead of plain `GtkButton'. - -2001-01-27 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (add_dropdown): Make the dropdown button - non-focusable. - -2001-01-27 Ettore Perazzoli <ettore@ximian.com> - - * e-search-bar.c (e_search_bar_init): Don't create the widgets - here. - (e_search_bar_construct): New. Do it here instead. - (e_search_bar_new): Call it. Added preconditions. - (esb_pack_menubar): Removed. - (add_dropdown): New. - (add_option): New. - (add_entry): New. - (e_search_bar_construct): Use `add_dropdown()', `add_option()', - `add_entry()'. - (class_init): Renamed from `e_seearch_bar_class_init'. - (init): Renamed from `e_search_bar_init'. - (impl_destroy): Renamed from `e_search_bar_destroy'. - (emit_menu_activated): Renamed from `esb_menu_activated'. - (emit_query_changed): Renamed from `esb_query_changed'. - (menubar_activated_cb): Renamed from `esb_menubar_activated'. - (option_activated_cb): Renamed from `esb_option_activated'. - (esb_entry_activated): Renamed from `esb_entry_activated'. - (impl_set_arg): Renamed from `e_search_bar_set_arg'. - (impl_get_arg): Renamed from `e_search_bar_get_arg'. - - * e-search-bar.h (struct _ESearchBar): Removed member `menubar'; - replaced it with `dropdown'. - -2001-01-27 Ettore Perazzoli <ettore@ximian.com> - - * e-dropdown-button.c (e_dropdown_button_construct): Removed - @ui_info and @data args. Obviously I am not very smart at this - time of the night. - (e_dropdown_button_new): Likewise. - -2001-01-27 Ettore Perazzoli <ettore@ximian.com> - - * e-dropdown-button.c, e-dropdown-button.h: New. - -2001-01-25 Damon Chaplin <damon@ximian.com> - - * e-calendar-item.[hc]: e_calendar_item_get_date_range() now returns - a boolean, which is FALSE if no dates are currently shown. - Plus a couple of minor sanity checks. - -2001-01-19 Federico Mena Quintero <federico@ximian.com> - - * e-calendar.c (e_calendar_init): Unset the GTK_CAN_FOCUS flag on - the ECalendar. - (e_calendar_focus_in): Removed function since it did nothing. - (e_calendar_focus_out): Likewise. - (e_calendar_key_press): Likewise. - (e_calendar_init): Turn off the GTK_CAN_FOCUS flag for both arrow - buttons. - -2001-01-17 Federico Mena Quintero <federico@ximian.com> - - * e-calendar-item.c (e_calendar_item_set_max_days_sel): Make zero - the minimum number of days that can be specified. - (e_calendar_item_set_arg): We do need an update when the maximum - number of selected days is changed. - (e_calendar_item_set_max_days_sel): Request an update of the - canvas item. - (e_calendar_item_button_press): Do not start selecting days if the - max_days_selected is less than 1. - -2001-01-17 Jeffrey Stedfast <fejj@ximian.com> - - * e-messagebox.c (e_message_box_get_id): Oops. Delete this. I - never meant for this to get commit'd. - -2001-01-17 JP Rosevear <jpr@ximian.com> - - * e-messagebox.c (e_message_box_get_id): Dont remove the function, give - it the proper name - -2001-01-17 Ettore Perazzoli <ettore@ximian.com> - - * e-messagebox.c (e_message_box_get_checkbox): Remove the version - returning `const char *' as of course it doesn't compile. Please - compile before committing. - -2001-01-17 Jeffrey Stedfast <fejj@ximian.com> - - * Makefile.am: Added e-messagebox to the build. - - * e-messagebox.[c,h]: Added a new messagebox window that contains - a checkbox for "Don't show me this again." - -2001-01-16 Jason Leach <jasonleach@usa.net> - - * e-search-bar.[ch]: Moved here from $(toplevel)/filter. - -2000-12-22 JP Rosevear <jpr@helixcode.com> - - * e-calendar-item.h: add prototypes - - * e-calendar-item.c (e_calendar_item_init): Set max_days_selected to - 1 and days_to_start_week_selection to -1 as documented in header - (e_calendar_item_set_arg): use new accessor methods - (e_calendar_item_get_arg): ditto - (e_calendar_item_get_max_days_sel): accessor - (e_calendar_item_set_max_days_sel): ditto - (e_calendar_item_get_days_start_week_sel): ditto - (e_calendar_item_set_days_start_week_sel): ditto - (e_calendar_item_class_init): add display_popup argument - (e_calendar_item_init): initialize display_popup member - (e_calendar_item_get_arg): get display_popup member - (e_calendar_item_set_arg): set display_popup member - (e_calendar_item_button_press): only show the popup menu if the - member is set - (e_calendar_item_get_display_popup): acessor - (e_calendar_item_set_display_popup): ditto - -2000-12-14 Federico Mena Quintero <federico@helixcode.com> - - * e-dateedit.h: #include <time.h> - -2000-12-08 JP Rosevear <jpr@helixcode.com> - - * e-calendar.c (e_calendar_destroy): Call the parent class destroyer - as well - -2000-10-26 Damon Chaplin <damon@helixcode.com> - - * e-dateedit.[hc]: updated to emit "changed" when appropriate, which - turned out to be amazingly difficult :( - Also added e_date_edit_get/set_date() to get/set just the date. - Added e_date_edit_date_is_valid() & e_date_edit_time_is_valid() so - you can check if the user has tried to enter an invalid date. - (All the get_date/time functions return the last valid date entered.) - - * test-dateedit.c: updated a bit. - -2000-11-02 Federico Mena Quintero <federico@helixcode.com> - - * e-dateedit.h (EDateEditClass): Removed the "time_changed" - signal, since it was never being emitted in the first place. Time - values *are* both date and time together anyways, so whenever one - changes we should notify about the whole date/time value being - changed. - Renamed the remaining "date_changed" signal to just "changed". - - * e-dateedit.c (e_date_edit_class_init): Do not create the - "time_changed" signal; rename the other one to "changed". - (set_time): Moved the core functionality from - e_date_edit_set_time() to here. This function just sets the - widgets' values without emitting any signals. - (e_date_edit_set_time): Emit the "changed" signal unconditionally. - This is to be consistent with the rest of the GTK+ widgets, and it - actually makes writing client code easier. - (e_date_edit_new): Use set_time(). - (on_date_popup_now_button_clicked): Do not emit the signal here. - (on_date_popup_none_button_clicked): Likewise. - (e_date_edit_set_time_of_day): Emit the signal, since we do not - call e_date_edit_set_time(). - -2000-10-30 Kjartan Maraas <kmaraas@gnome.org> - - * e-calendar-item.c: #include <string.h> to get rid of warning. - * e-clipped-label.c: Same here. - -2000-10-27 Federico Mena Quintero <federico@helixcode.com> - - * e-dateedit.c (e_date_edit_destroy): Do not unref the cal_popup - since we already destroyed it. - -2000-10-11 Damon Chaplin <damon@helixcode.com> - - * e-calendar-item.c (e_calendar_item_recalc_sizes): fixed to - recalculate min_cell_width/height in case the show_week_numbers option - is changed. - - * e-dateedit.c: added support for hiding the date field, and added - get/set_time_of_day() functions to get/set just the time. - -2000-09-30 Damon Chaplin <damon@helixcode.com> - - * e-calendar-item.c: - * e-dateedit.c: better i18n of strftime strings. - -2000-09-29 Ettore Perazzoli <ettore@helixcode.com> - - * e-title-bar.c: New member `pin_gtk_pixmap' in - `ETitleBarPrivate'. Signal "close_button_clicked" renamed to - "button_clicked". Signal "title_button_press_event" renamed to - "label_button_press_event". - (init): Init new members. - (close_button_realize_cb): Create the pin pixmap. Call - `show_and_hide_pixmaps_according_to_mode()'. - (e_title_bar_show_close_button): Renamed to - `e_title_bar_show_button'. - (e_title_bar_get_button_mode): New. - (e_title_bar_set_button_mode): New. - -2000-09-23 Damon Chaplin <damon@helixcode.com> - - * e-calendar.c: use pixmaps instead of GtkArrows to look better. - Also set the canvas window's background when realized so that we can - set the button reliefs to none. - -2000-09-22 Damon Chaplin <damon@helixcode.com> - - * test-dateedit.c: updated a bit, adding a few EDateEdits with - different options. - - * e-calendar-item.c (e_calendar_item_set_selection): aborted any - current selection operation and initialize all of the selection fields. - (e_calendar_item_unmap): new function to abort any current selection - operation. Otherwise GnomeCanvas gets in a muddle about grabs. - - * e-dateedit.c: marked some strftime()/strptime() format strings for - translation and used "%m/%d/%Y" instead of "%x" so we get the complete - year number. Also changed e_date_edit_get_time() so it returns -2 if - it can't parse the date or time, and -1 if it is explicitly set to - None. - (e_date_edit_parse_date): new function to parse the date string and - add on the current century if a year of 0-99 is entered. - -2000-09-21 Damon Chaplin <damon@helixcode.com> - - * e-dateedit.c (on_date_button_clicked): only check return of strptime - for NULL. It should now select the correct day set in the popup. - - * e-calendar.c: - * e-calendar-item.c: - * test-calendar.c: removed support for buttons within the ECalendar. - It is cleaner to add them outside it, as EDateEdit does. - -2000-09-18 Dan Winship <danw@helixcode.com> - - * e-dateedit.c (_XOPEN_SOURCE): set this to 4 to specify how much - X/Open we want with that. - -2000-09-18 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and - $(EXTRA_GNOME_LIBS). Removed unneeded libraries. - - * e-calendar-item.c, e-calendar.c, e-calendar.h, e-title-bar.c: - Fixed the #include lines to deal properly with gal. - - * e-scroll-frame.c, e-scroll-frame.h: Moved to gal. - -2000-09-11 Damon Chaplin <damon@helixcode.com> - - * Makefile.am (libemiscwidgets_a_SOURCES): added e-dateedit.[hc] - and the test-dateedit app. - - * e-dateedit.[hc]: new widget to use instead of GnomeDateEdit. It - uses the new ECalendar widget for the calendar and also supports - "None", "Today" and "Now" buttons, and goes away with a single click. - - * test-dateedit.c: app to test the EDateEdit widget. - - * e-calendar-item.c: updated to support the EDateEdit better, - mainly by adding the "move_selection_when_moving" arg so we can turn - it off to keep the same day selected when changing the months shown. - -2000-09-05 Damon Chaplin <damon@helixcode.com> - - * e-calendar-item.c (e_calendar_item_draw_month): make sure we get - the start_weekday since we need it for draw_days(). Fixes a drawing - bug. - -2000-08-31 Damon Chaplin <damon@helixcode.com> - - * e-calendar-item.c (e_calendar_item_button_press): - (e_calendar_item_button_release): grab/ungrab the pointer so we - always get the button_release event. - -2000-08-30 Damon Chaplin <damon@helixcode.com> - - * e-calendar-item.[hc]: - * e-calendar.[hc]: Updated. - -2000-08-10 Christopher James Lahey <clahey@helixcode.com> - - * e-calendar-item.c, e-calendar.c: Fixed some warnings. - -2000-07-25 Damon Chaplin <damon@helixcode.com> - - * e-calendar-item.h: - * e-calendar.[hc]: new widget and canvas item to replace GtkCalendar. - Not quite finished yet. - -2000-07-21 Ettore Perazzoli <ettore@helixcode.com> - - * e-title-bar.c (e_title_bar_set_title): We have a `EClippedLabel', - not a `GtkLabel' here: use the right function to change the text. - -2000-07-12 Christopher James Lahey <clahey@helixcode.com> - - * e-scroll-frame.c: Tried rearranging the casts to try for a more - correct computation. - -2000-07-08 Dan Winship <danw@helixcode.com> - - * e-scroll-frame.c (e_scroll_frame_add): comment out true but - confused warning about non-scrollable widgets until Chris and/or - Federico fix this correctly. - (e_scroll_frame_size_allocate): If the available space for the - child is less than the width/height of the frame, give the child - an allocation of 0 rather than some small negative number cast to - unsigned. - -2000-07-05 Dan Winship <danw@helixcode.com> - - * Makefile.am (INCLUDES): Set G_LOG_DOMAIN=__FILE__ rather than - "e-title-bar" in all three widgets. - -2000-06-13 Anders Carlsson <andersca@gnu.org> - - * e-scroll-frame.c (e_scroll_frame_button_press): Control does - horizontal scrolling, a la gimp. - -2000-06-11 Anders Carlsson <andersca@gnu.org> - - * e-scroll-frame.c (e_scroll_frame_button_press): Add support - for mouse wheel scrolling in EScrollFrame. - -2000-06-10 Ettore Perazzoli <ettore@helixcode.com> - - * e-title-bar.c (close_button_realize_cb): Unref the pixmap and - the mask. - diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am deleted file mode 100644 index 6e1814b88d..0000000000 --- a/widgets/misc/Makefile.am +++ /dev/null @@ -1,203 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/a11y/widgets/ \ - -DMAP_DIR=\""$(imagesdir)"\" \ - -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \ - -DG_LOG_DOMAIN=__FILE__ \ - $(SOURCE_SEL_CFLAGS) - -privlib_LTLIBRARIES = \ - libemiscwidgets.la - -widgetsincludedir = $(privincludedir)/widgets - -if ENABLE_PILOT_CONDUITS -pilot_sources = e-pilot-settings.c -pilot_headers = e-pilot-settings.h -else -pilot_sources = -pilot_headers = -endif - -widgetsinclude_HEADERS = \ - $(pilot_headers) \ - e-activity-handler.h \ - e-calendar.h \ - e-calendar-item.h \ - e-cell-date-edit.h \ - e-cell-percent.h \ - e-cell-renderer-combo.h \ - e-charset-picker.h \ - e-clipped-label.h \ - e-combo-cell-editable.h \ - e-config-page.h \ - e-combo-button.h \ - e-dateedit.h \ - e-dropdown-button.h \ - e-error.h \ - e-expander.h \ - e-image-chooser.h \ - e-info-label.h \ - e-map.h \ - e-multi-config-dialog.h \ - e-search-bar.h \ - e-source-option-menu.h \ - e-source-selector.h \ - e-task-bar.h \ - e-task-widget.h \ - e-title-bar.h \ - e-url-entry.h - -libemiscwidgets_la_SOURCES = \ - $(MARSHAL_GENERATED) \ - $(widgetsinclude_HEADERS) \ - $(pilot_sources) \ - e-activity-handler.c \ - e-calendar.c \ - e-calendar-item.c \ - e-cell-date-edit.c \ - e-cell-percent.c \ - e-cell-renderer-combo.c \ - e-charset-picker.c \ - e-clipped-label.c \ - e-combo-cell-editable.c \ - e-config-page.c \ - e-combo-button.c \ - e-dateedit.c \ - e-dropdown-button.c \ - e-error.c \ - e-expander.c \ - e-image-chooser.c \ - e-info-label.c \ - e-map.c \ - e-multi-config-dialog.c \ - e-search-bar.c \ - e-source-option-menu.c \ - e-source-selector.c \ - e-task-bar.c \ - e-task-widget.c \ - e-title-bar.c \ - e-url-entry.c - -MARSHAL_GENERATED = e-util-marshal.c e-util-marshal.h -@EVO_MARSHAL_RULE@ - -error_DATA = e-system-errors.xml -error_i18n = $(error_DATA:.xml=.xml.h) -errordir = $(privdatadir)/errors -%.xml.h: %.xml - $(top_builddir)/e-util/e-error-tool $^ - -libemiscwidgets_la_LIBADD = $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/a11y/widgets/libevolution-widgets-a11y.la \ - $(SOURCE_SEL_LIBS) - -noinst_LTLIBRARIES = libefilterbar.la - -libefilterbar_la_SOURCES = \ - e-filter-bar.c \ - e-filter-bar.h - -noinst_PROGRAMS = \ - test-calendar \ - test-dateedit \ - test-dropdown-button \ - test-error \ - test-multi-config-dialog \ - test-source-option-menu \ - test-source-selector \ - test-title-bar - -# test-calendar - -test_calendar_SOURCES = \ - test-calendar.c - -test_calendar_LDADD = \ - ./libemiscwidgets.la \ - $(top_builddir)/e-util/libeutil.la \ - $(GNOME_FULL_LIBS) - -# test-dateedit - -test_dateedit_SOURCES = \ - test-dateedit.c - -test_dateedit_LDADD = \ - ./libemiscwidgets.la \ - $(top_builddir)/e-util/libeutil.la \ - $(GNOME_FULL_LIBS) - -# test-dropdown-button - -test_dropdown_button_SOURCES = \ - test-dropdown-button.c - -test_dropdown_button_LDADD = \ - ./libemiscwidgets.la \ - $(top_builddir)/e-util/libeutil.la \ - $(GNOME_FULL_LIBS) - -# test-multi-config-dialog - -test_multi_config_dialog_SOURCES = \ - test-multi-config-dialog.c - -test_multi_config_dialog_LDADD = \ - ./libemiscwidgets.la \ - $(top_builddir)/e-util/libeutil.la \ - $(GNOME_FULL_LIBS) - -# test-title-bar - -test_title_bar_SOURCES = \ - test-title-bar.c - -test_title_bar_LDADD = \ - ./libemiscwidgets.la \ - $(top_builddir)/e-util/libeutil.la \ - $(GNOME_FULL_LIBS) - -# test-source-selector - -test_source_selector_SOURCES = \ - test-source-selector.c - -test_source_selector_LDADD = \ - $(top_builddir)/e-util/libeutil.la \ - ./libemiscwidgets.la \ - $(SOURCE_SEL_LIBS) - - -# test-source-option-menu - -test_source_option_menu_SOURCES = \ - test-source-option-menu.c - -test_source_option_menu_LDADD = \ - $(top_builddir)/e-util/libeutil.la \ - ./libemiscwidgets.la \ - $(SOURCE_SEL_LIBS) - -test_error_SOURCES = \ - test-error.c - -test_error_LDADD = \ - $(top_builddir)/e-util/libeutil.la \ - ./libemiscwidgets.la \ - $(GNOME_FULL_LIBS) - - -BUILT_SOURCES = $(MARSHAL_GENERATED) $(error_i18n) -CLEANFILES = $(BUILT_SOURCES) - -EXTRA_DIST = \ - $(error_DATA) \ - $(error_i18n) \ - e-pilot-settings.h \ - e-pilot-settings.c \ - e-util-marshal.list \ - ChangeLog.pre-1-4 - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) diff --git a/widgets/misc/e-activity-handler.c b/widgets/misc/e-activity-handler.c deleted file mode 100644 index fd5fb9a275..0000000000 --- a/widgets/misc/e-activity-handler.c +++ /dev/null @@ -1,420 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-activity-handler.c - * - * Copyright (C) 2001, 2002, 2003 Novell, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-activity-handler.h" - -#include <gtk/gtksignal.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-popup-menu.h> - -#include <gal/util/e-util.h> -#include <gal/widgets/e-popup-menu.h> - - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class = NULL; - - -#define ICON_SIZE 16 - - -struct _ActivityInfo { - char *component_id; - GdkPixbuf *icon_pixbuf; - guint id; - char *information; - gboolean cancellable; - double progress; - GtkWidget *menu; -}; -typedef struct _ActivityInfo ActivityInfo; - -struct _EActivityHandlerPrivate { - uint next_activity_id; - GList *activity_infos; - GSList *task_bars; -}; - - -/* Utility functions. */ - -static unsigned int -get_new_activity_id (EActivityHandler *activity_handler) -{ - EActivityHandlerPrivate *priv; - - priv = activity_handler->priv; - - return priv->next_activity_id ++; -} - -static GList * -lookup_activity (GList *list, - guint activity_id, - int *order_number_return) -{ - GList *p; - int i; - - for (p = list, i = 0; p != NULL; p = p->next, i ++) { - ActivityInfo *activity_info; - - activity_info = (ActivityInfo *) p->data; - if (activity_info->id == activity_id) { - *order_number_return = i; - return p; - } - } - - *order_number_return = -1; - return NULL; -} - - -/* ETaskWidget actions. */ - -static int -task_widget_button_press_event_callback (GtkWidget *widget, - GdkEventButton *button_event, - void *data) -{ - ActivityInfo *activity_info; - - activity_info = (ActivityInfo *) data; - - if (button_event->button == 3) - return activity_info->cancellable; - - if (button_event->button != 1) - return FALSE; - - return TRUE; -} - - -/* Creating and destroying ActivityInfos. */ - -static ActivityInfo * -activity_info_new (const char *component_id, - guint id, - GdkPixbuf *icon, - const char *information, - gboolean cancellable) -{ - ActivityInfo *info; - - info = g_new (ActivityInfo, 1); - info->component_id = g_strdup (component_id); - info->id = id; - info->icon_pixbuf = g_object_ref (icon); - info->information = g_strdup (information); - info->cancellable = cancellable; - info->progress = -1.0; /* (Unknown) */ - info->menu = NULL; - - return info; -} - -static void -activity_info_free (ActivityInfo *info) -{ - g_free (info->component_id); - - g_object_unref (info->icon_pixbuf); - g_free (info->information); - - if (info->menu != NULL) - gtk_widget_destroy (info->menu); - - g_free (info); -} - -static ETaskWidget * -task_widget_new_from_activity_info (ActivityInfo *activity_info) -{ - GtkWidget *widget; - - widget = e_task_widget_new (activity_info->icon_pixbuf, - activity_info->component_id, - activity_info->information); - gtk_widget_show (widget); - - g_signal_connect (widget, "button_press_event", - G_CALLBACK (task_widget_button_press_event_callback), - activity_info); - - return E_TASK_WIDGET (widget); -} - - -/* Task Bar handling. */ - -static void -setup_task_bar (EActivityHandler *activity_handler, - ETaskBar *task_bar) -{ - EActivityHandlerPrivate *priv; - GList *p; - - priv = activity_handler->priv; - - for (p = g_list_last (priv->activity_infos); p != NULL; p = p->prev) { - e_task_bar_prepend_task (task_bar, - task_widget_new_from_activity_info ((ActivityInfo *) p->data)); - } -} - -static void -task_bar_destroy_notify (void *data, - GObject *task_bar_instance) -{ - EActivityHandler *activity_handler; - EActivityHandlerPrivate *priv; - - activity_handler = E_ACTIVITY_HANDLER (data); - priv = activity_handler->priv; - - priv->task_bars = g_slist_remove (priv->task_bars, task_bar_instance); -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - EActivityHandler *handler; - EActivityHandlerPrivate *priv; - GList *p; - GSList *sp; - - handler = E_ACTIVITY_HANDLER (object); - priv = handler->priv; - - for (p = priv->activity_infos; p != NULL; p = p->next) { - ActivityInfo *info; - - info = (ActivityInfo *) p->data; - activity_info_free (info); - } - - g_list_free (priv->activity_infos); - priv->activity_infos = NULL; - - for (sp = priv->task_bars; sp != NULL; sp = sp->next) - g_object_weak_unref (G_OBJECT (sp->data), task_bar_destroy_notify, handler); - priv->task_bars = NULL; - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EActivityHandler *handler; - EActivityHandlerPrivate *priv; - - handler = E_ACTIVITY_HANDLER (object); - priv = handler->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* GTK+ type stuff. */ - -static void -class_init (GObjectClass *object_class) -{ - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; -} - -static void -init (EActivityHandler *activity_handler) -{ - EActivityHandlerPrivate *priv; - - priv = g_new (EActivityHandlerPrivate, 1); - priv->next_activity_id = 1; - priv->activity_infos = NULL; - priv->task_bars = NULL; - - activity_handler->priv = priv; -} - - -EActivityHandler * -e_activity_handler_new (void) -{ - return g_object_new (e_activity_handler_get_type (), 0); -} - -void -e_activity_handler_set_message (EActivityHandler *activity_handler, - const char *message) -{ - EActivityHandlerPrivate *priv; - GSList *i; - - priv = activity_handler->priv; - - for (i = priv->task_bars; i; i = i->next) - e_task_bar_set_message (E_TASK_BAR (i->data), message); -} - -void -e_activity_handler_unset_message (EActivityHandler *activity_handler) -{ - EActivityHandlerPrivate *priv; - GSList *i; - - priv = activity_handler->priv; - - for (i = priv->task_bars; i; i = i->next) - e_task_bar_unset_message (E_TASK_BAR (i->data)); -} - -void -e_activity_handler_attach_task_bar (EActivityHandler *activity_handler, - ETaskBar *task_bar) -{ - EActivityHandlerPrivate *priv; - - g_return_if_fail (activity_handler != NULL); - g_return_if_fail (E_IS_ACTIVITY_HANDLER (activity_handler)); - g_return_if_fail (task_bar != NULL); - g_return_if_fail (E_IS_TASK_BAR (task_bar)); - - priv = activity_handler->priv; - - g_object_weak_ref (G_OBJECT (task_bar), task_bar_destroy_notify, activity_handler); - - priv->task_bars = g_slist_prepend (priv->task_bars, task_bar); - - setup_task_bar (activity_handler, task_bar); -} - -/* CORBA methods. */ - -guint -e_activity_handler_operation_started (EActivityHandler *activity_handler, - const char *component_id, - GdkPixbuf *icon_pixbuf, - const char *information, - gboolean cancellable) -{ - EActivityHandlerPrivate *priv; - ActivityInfo *activity_info; - unsigned int activity_id; - GSList *p; - - priv = activity_handler->priv; - - activity_id = get_new_activity_id (activity_handler); - - activity_info = activity_info_new (component_id, activity_id, icon_pixbuf, information, cancellable); - - for (p = priv->task_bars; p != NULL; p = p->next) { - e_task_bar_prepend_task (E_TASK_BAR (p->data), - task_widget_new_from_activity_info (activity_info)); - } - - priv->activity_infos = g_list_prepend (priv->activity_infos, activity_info); - - return activity_id; -} - -void -e_activity_handler_operation_progressing (EActivityHandler *activity_handler, - guint activity_id, - const char *information, - double progress) -{ - EActivityHandlerPrivate *priv = activity_handler->priv; - ActivityInfo *activity_info; - GList *p; - GSList *sp; - int order_number; - - p = lookup_activity (priv->activity_infos, activity_id, &order_number); - if (p == NULL) { - g_warning ("EActivityHandler: unknown operation %d", activity_id); - return; - } - - activity_info = (ActivityInfo *) p->data; - - g_free (activity_info->information); - activity_info->information = g_strdup (information); - - activity_info->progress = progress; - - for (sp = priv->task_bars; sp != NULL; sp = sp->next) { - ETaskBar *task_bar; - ETaskWidget *task_widget; - - task_bar = E_TASK_BAR (sp->data); - task_widget = e_task_bar_get_task_widget (task_bar, order_number); - - e_task_widget_update (task_widget, information, progress); - } -} - -void -e_activity_handler_operation_finished (EActivityHandler *activity_handler, - guint activity_id) -{ - EActivityHandlerPrivate *priv = activity_handler->priv; - GList *p; - GSList *sp; - int order_number; - - p = lookup_activity (priv->activity_infos, activity_id, &order_number); - if (p == NULL) { - g_warning ("e_activity_handler_operation_finished: Unknown activity %d\n", activity_id); - return; - } - - activity_info_free ((ActivityInfo *) p->data); - priv->activity_infos = g_list_remove_link (priv->activity_infos, p); - - for (sp = priv->task_bars; sp != NULL; sp = sp->next) { - ETaskBar *task_bar; - - task_bar = E_TASK_BAR (sp->data); - e_task_bar_remove_task (task_bar, order_number); - } -} - - -E_MAKE_TYPE (e_activity_handler, "EActivityHandler", EActivityHandler, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-activity-handler.h b/widgets/misc/e-activity-handler.h deleted file mode 100644 index b3fe4e386d..0000000000 --- a/widgets/misc/e-activity-handler.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-activity-handler.h - * - * Copyright (C) 2001, 2002, 2003 Novell, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_ACTIVITY_HANDLER_H_ -#define _E_ACTIVITY_HANDLER_H_ - -#include "e-task-bar.h" - -#include <glib-object.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_ACTIVITY_HANDLER (e_activity_handler_get_type ()) -#define E_ACTIVITY_HANDLER(obj) (GTK_CHECK_CAST ((obj), E_TYPE_ACTIVITY_HANDLER, EActivityHandler)) -#define E_ACTIVITY_HANDLER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_ACTIVITY_HANDLER, EActivityHandlerClass)) -#define E_IS_ACTIVITY_HANDLER(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_ACTIVITY_HANDLER)) -#define E_IS_ACTIVITY_HANDLER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_ACTIVITY_HANDLER)) - - -typedef struct _EActivityHandler EActivityHandler; -typedef struct _EActivityHandlerPrivate EActivityHandlerPrivate; -typedef struct _EActivityHandlerClass EActivityHandlerClass; - -struct _EActivityHandler { - GObject parent; - - EActivityHandlerPrivate *priv; -}; - -struct _EActivityHandlerClass { - GObjectClass parent_class; -}; - - -GtkType e_activity_handler_get_type (void); - -EActivityHandler *e_activity_handler_new (void); - -void e_activity_handler_attach_task_bar (EActivityHandler *activity_hanlder, - ETaskBar *task_bar); - -void e_activity_handler_set_message (EActivityHandler *activity_handler, - const char *message); - -void e_activity_handler_unset_message (EActivityHandler *activity_handler); - -guint e_activity_handler_operation_started (EActivityHandler *activity_handler, - const char *component_id, - GdkPixbuf *icon_pixbuf, - const char *information, - gboolean cancellable); - -void e_activity_handler_operation_progressing (EActivityHandler *activity_handler, - guint activity_id, - const char *information, - double progress); - -void e_activity_handler_operation_finished (EActivityHandler *activity_handler, - guint activity_id); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_ACTIVITY_HANDLER_H_ */ diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c deleted file mode 100644 index 8bf9db8e0b..0000000000 --- a/widgets/misc/e-calendar-item.c +++ /dev/null @@ -1,3286 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright 2000, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * ECalendarItem - canvas item displaying a calendar. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-calendar-item.h" -#include "ea-widgets.h" - -#include <time.h> -#include <string.h> -#include <glib.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtklabel.h> -#include <gtk/gtksignal.h> -#include <gdk/gdkkeysyms.h> -#include <libgnome/gnome-i18n.h> -#include <gal/util/e-util.h> - -static const int e_calendar_item_days_in_month[12] = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -#define DAYS_IN_MONTH(year, month) \ - e_calendar_item_days_in_month[month] + (((month) == 1 \ - && ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))) ? 1 : 0) - - -static void e_calendar_item_class_init (ECalendarItemClass *class); -static void e_calendar_item_init (ECalendarItem *calitem); -static void e_calendar_item_destroy (GtkObject *o); -static void e_calendar_item_get_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_calendar_item_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_calendar_item_realize (GnomeCanvasItem *item); -static void e_calendar_item_unrealize (GnomeCanvasItem *item); -static void e_calendar_item_unmap (GnomeCanvasItem *item); -static void e_calendar_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags); -static void e_calendar_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height); -static void e_calendar_item_draw_month (ECalendarItem *calitem, - GdkDrawable *drawable, - int x, - int y, - int width, - int height, - int row, - int col); -static void e_calendar_item_draw_day_numbers (ECalendarItem *calitem, - GdkDrawable *drawable, - int width, - int height, - int row, - int col, - int year, - int month, - int start_weekday, - gint cells_x, - gint cells_y); -static double e_calendar_item_point (GnomeCanvasItem *item, - double x, - double y, - int cx, - int cy, - GnomeCanvasItem **actual_item); -static void e_calendar_item_stop_selecting (ECalendarItem *calitem, - guint32 time); -static void e_calendar_item_selection_add_days (ECalendarItem *calitem, - gint n_days, - gboolean multi_selection); -static gint e_calendar_item_key_press_event (ECalendarItem *item, - GdkEvent *event); -static gint e_calendar_item_event (GnomeCanvasItem *item, - GdkEvent *event); -static void e_calendar_item_bounds (GnomeCanvasItem *item, double *x1, double *y1, - double *x2, double *y2); - -static gboolean e_calendar_item_button_press (ECalendarItem *calitem, - GdkEvent *event); -static gboolean e_calendar_item_button_release (ECalendarItem *calitem, - GdkEvent *event); -static gboolean e_calendar_item_motion (ECalendarItem *calitem, - GdkEvent *event); - -static gboolean e_calendar_item_convert_position_to_day (ECalendarItem *calitem, - gint x, - gint y, - gboolean round_empty_positions, - gint *month_offset, - gint *day, - gboolean *entire_week); -static void e_calendar_item_get_month_info (ECalendarItem *calitem, - gint row, - gint col, - gint *first_day_offset, - gint *days_in_month, - gint *days_in_prev_month); -static void e_calendar_item_recalc_sizes(ECalendarItem *calitem); - -static void e_calendar_item_get_day_style (ECalendarItem *calitem, - gint year, - gint month, - gint day, - gint day_style, - gboolean today, - gboolean prev_or_next_month, - gboolean selected, - gboolean has_focus, - gboolean drop_target, - GdkColor **bg_color, - GdkColor **fg_color, - GdkColor **box_color, - gboolean *bold); -static void e_calendar_item_check_selection_end (ECalendarItem *calitem, - gint start_month, - gint start_day, - gint *end_month, - gint *end_day); -static void e_calendar_item_check_selection_start(ECalendarItem *calitem, - gint *start_month, - gint *start_day, - gint end_month, - gint end_day); -static void e_calendar_item_add_days_to_selection(ECalendarItem *calitem, - gint days); -static void e_calendar_item_round_up_selection (ECalendarItem *calitem, - gint *month_offset, - gint *day); -static void e_calendar_item_round_down_selection (ECalendarItem *calitem, - gint *month_offset, - gint *day); -static gint e_calendar_item_get_inclusive_days (ECalendarItem *calitem, - gint start_month_offset, - gint start_day, - gint end_month_offset, - gint end_day); -static void e_calendar_item_ensure_valid_day (ECalendarItem *calitem, - gint *month_offset, - gint *day); -static gboolean e_calendar_item_ensure_days_visible (ECalendarItem *calitem, - gint start_year, - gint start_month, - gint start_day, - gint end_year, - gint end_month, - gint end_day, - gboolean emission); -static void e_calendar_item_show_popup_menu (ECalendarItem *calitem, - GdkEventButton *event, - gint month_offset); -static void e_calendar_item_on_menu_item_activate(GtkWidget *menuitem, - ECalendarItem *calitem); -static void e_calendar_item_position_menu (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data); -static void e_calendar_item_date_range_changed (ECalendarItem *calitem); -static void e_calendar_item_queue_signal_emission (ECalendarItem *calitem); -static gboolean e_calendar_item_signal_emission_idle_cb (gpointer data); -static void e_calendar_item_set_selection_if_emission (ECalendarItem *calitem, - GDate *start_date, - GDate *end_date, - gboolean emission); - -/* Our arguments. */ -enum { - ARG_0, - ARG_YEAR, - ARG_MONTH, - ARG_X1, - ARG_Y1, - ARG_X2, - ARG_Y2, - ARG_FONT_DESC, - ARG_WEEK_NUMBER_FONT, - ARG_WEEK_NUMBER_FONT_DESC, - ARG_ROW_HEIGHT, - ARG_COLUMN_WIDTH, - ARG_MINIMUM_ROWS, - ARG_MINIMUM_COLUMNS, - ARG_MAXIMUM_ROWS, - ARG_MAXIMUM_COLUMNS, - ARG_WEEK_START_DAY, - ARG_SHOW_WEEK_NUMBERS, - ARG_MAXIMUM_DAYS_SELECTED, - ARG_DAYS_TO_START_WEEK_SELECTION, - ARG_MOVE_SELECTION_WHEN_MOVING, - ARG_PRESERVE_DAY_WHEN_MOVING, - ARG_DISPLAY_POPUP -}; - -enum { - DATE_RANGE_CHANGED, - SELECTION_CHANGED, - SELECTION_PREVIEW_CHANGED, - LAST_SIGNAL -}; - - -static GnomeCanvasItemClass *parent_class; -static guint e_calendar_item_signals[LAST_SIGNAL] = { 0 }; - - -E_MAKE_TYPE (e_calendar_item, "ECalendarItem", ECalendarItem, - e_calendar_item_class_init, e_calendar_item_init, - GNOME_TYPE_CANVAS_ITEM) - - -static void -e_calendar_item_class_init (ECalendarItemClass *class) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - parent_class = g_type_class_peek_parent (class); - - object_class = GTK_OBJECT_CLASS (class); - item_class = GNOME_CANVAS_ITEM_CLASS (class); - - gtk_object_add_arg_type ("ECalendarItem::year", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_YEAR); - gtk_object_add_arg_type ("ECalendarItem::month", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MONTH); - gtk_object_add_arg_type ("ECalendarItem::x1", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, - ARG_X1); - gtk_object_add_arg_type ("ECalendarItem::y1", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, - ARG_Y1); - gtk_object_add_arg_type ("ECalendarItem::x2", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, - ARG_X2); - gtk_object_add_arg_type ("ECalendarItem::y2", - GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, - ARG_Y2); - gtk_object_add_arg_type ("ECalendarItem::font_desc", - GTK_TYPE_POINTER, GTK_ARG_READWRITE, - ARG_FONT_DESC); - gtk_object_add_arg_type ("ECalendarItem::week_number_font_desc", - GTK_TYPE_POINTER, GTK_ARG_READWRITE, - ARG_WEEK_NUMBER_FONT_DESC); - gtk_object_add_arg_type ("ECalendarItem::row_height", - GTK_TYPE_INT, GTK_ARG_READABLE, - ARG_ROW_HEIGHT); - gtk_object_add_arg_type ("ECalendarItem::column_width", - GTK_TYPE_INT, GTK_ARG_READABLE, - ARG_COLUMN_WIDTH); - gtk_object_add_arg_type ("ECalendarItem::minimum_rows", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MINIMUM_ROWS); - gtk_object_add_arg_type ("ECalendarItem::minimum_columns", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MINIMUM_COLUMNS); - gtk_object_add_arg_type ("ECalendarItem::maximum_rows", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MAXIMUM_ROWS); - gtk_object_add_arg_type ("ECalendarItem::maximum_columns", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MAXIMUM_COLUMNS); - gtk_object_add_arg_type ("ECalendarItem::week_start_day", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_WEEK_START_DAY); - gtk_object_add_arg_type ("ECalendarItem::show_week_numbers", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_SHOW_WEEK_NUMBERS); - gtk_object_add_arg_type ("ECalendarItem::maximum_days_selected", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_MAXIMUM_DAYS_SELECTED); - gtk_object_add_arg_type ("ECalendarItem::days_to_start_week_selection", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_DAYS_TO_START_WEEK_SELECTION); - gtk_object_add_arg_type ("ECalendarItem::move_selection_when_moving", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_MOVE_SELECTION_WHEN_MOVING); - gtk_object_add_arg_type ("ECalendarItem::preserve_day_when_moving", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_PRESERVE_DAY_WHEN_MOVING); - gtk_object_add_arg_type ("ECalendarItem::display_popup", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_DISPLAY_POPUP); - - e_calendar_item_signals[DATE_RANGE_CHANGED] = - gtk_signal_new ("date_range_changed", - GTK_RUN_FIRST, - GTK_CLASS_TYPE (object_class), - G_STRUCT_OFFSET (ECalendarItemClass, date_range_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - e_calendar_item_signals[SELECTION_CHANGED] = - gtk_signal_new ("selection_changed", - GTK_RUN_FIRST, - GTK_CLASS_TYPE (object_class), - G_STRUCT_OFFSET (ECalendarItemClass, selection_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - e_calendar_item_signals[SELECTION_PREVIEW_CHANGED] = - g_signal_new ("selection_preview_changed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ECalendarItemClass, selection_preview_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - object_class->destroy = e_calendar_item_destroy; - object_class->get_arg = e_calendar_item_get_arg; - object_class->set_arg = e_calendar_item_set_arg; - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_calendar_item_realize; - item_class->unrealize = e_calendar_item_unrealize; - item_class->unmap = e_calendar_item_unmap; - item_class->update = e_calendar_item_update; - item_class->draw = e_calendar_item_draw; - item_class->point = e_calendar_item_point; - item_class->event = e_calendar_item_event; - item_class->bounds = e_calendar_item_bounds; - - class->date_range_changed = NULL; - class->selection_changed = NULL; - class->selection_preview_changed = NULL; - - e_calendar_item_a11y_init (); -} - - -static void -e_calendar_item_init (ECalendarItem *calitem) -{ - struct tm *tmp_tm; - time_t t; - - /* Set the default time to the current month. */ - t = time (NULL); - tmp_tm = localtime (&t); - calitem->year = tmp_tm->tm_year + 1900; - calitem->month = tmp_tm->tm_mon; - - calitem->styles = NULL; - - calitem->min_cols = 1; - calitem->min_rows = 1; - calitem->max_cols = -1; - calitem->max_rows = -1; - - calitem->rows = 0; - calitem->cols = 0; - - calitem->show_week_numbers = FALSE; - calitem->week_start_day = 0; - calitem->expand = TRUE; - calitem->max_days_selected = 1; - calitem->days_to_start_week_selection = -1; - calitem->move_selection_when_moving = TRUE; - calitem->preserve_day_when_moving = FALSE; - calitem->display_popup = TRUE; - - calitem->x1 = 0.0; - calitem->y1 = 0.0; - calitem->x2 = 0.0; - calitem->y2 = 0.0; - - calitem->selecting = FALSE; - calitem->selecting_axis = NULL; - - calitem->selection_set = FALSE; - - calitem->selection_changed = FALSE; - calitem->date_range_changed = FALSE; - - calitem->style_callback = NULL; - calitem->style_callback_data = NULL; - calitem->style_callback_destroy = NULL; - - calitem->time_callback = NULL; - calitem->time_callback_data = NULL; - calitem->time_callback_destroy = NULL; - - /* Translators: These are the first characters of each day of the - week, 'M' for 'Monday', 'T' for Tuesday etc. */ - calitem->days = _("MTWTFSS"); - - calitem->signal_emission_idle_id = 0; -} - - -static void -e_calendar_item_destroy (GtkObject *o) -{ - ECalendarItem *calitem; - - calitem = E_CALENDAR_ITEM (o); - - e_calendar_item_set_style_callback (calitem, NULL, NULL, NULL); - e_calendar_item_set_get_time_callback (calitem, NULL, NULL, NULL); - - if (calitem->styles) { - g_free (calitem->styles); - calitem->styles = NULL; - } - - if (calitem->signal_emission_idle_id != 0) { - g_source_remove (calitem->signal_emission_idle_id); - calitem->signal_emission_idle_id = 0; - } - - if (calitem->font_desc) { - pango_font_description_free (calitem->font_desc); - calitem->font_desc = NULL; - } - - if (calitem->week_number_font_desc) { - pango_font_description_free (calitem->week_number_font_desc); - calitem->week_number_font_desc = NULL; - } - - if (calitem->selecting_axis) - g_free (calitem->selecting_axis); - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (o); -} - - -static void -e_calendar_item_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ECalendarItem *calitem; - - item = GNOME_CANVAS_ITEM (o); - calitem = E_CALENDAR_ITEM (o); - - switch (arg_id) { - case ARG_YEAR: - GTK_VALUE_INT (*arg) = calitem->year; - break; - case ARG_MONTH: - GTK_VALUE_INT (*arg) = calitem->month; - break; - case ARG_X1: - GTK_VALUE_DOUBLE (*arg) = calitem->x1; - break; - case ARG_Y1: - GTK_VALUE_DOUBLE (*arg) = calitem->y1; - break; - case ARG_X2: - GTK_VALUE_DOUBLE (*arg) = calitem->x2; - break; - case ARG_Y2: - GTK_VALUE_DOUBLE (*arg) = calitem->y2; - break; - case ARG_FONT_DESC: - GTK_VALUE_BOXED (*arg) = calitem->font_desc; - break; - case ARG_WEEK_NUMBER_FONT_DESC: - GTK_VALUE_BOXED (*arg) = calitem->week_number_font_desc; - break; - case ARG_ROW_HEIGHT: - e_calendar_item_recalc_sizes (calitem); - GTK_VALUE_INT (*arg) = calitem->min_month_height; - break; - case ARG_COLUMN_WIDTH: - e_calendar_item_recalc_sizes (calitem); - GTK_VALUE_INT (*arg) = calitem->min_month_width; - break; - case ARG_MINIMUM_ROWS: - GTK_VALUE_INT (*arg) = calitem->min_rows; - break; - case ARG_MINIMUM_COLUMNS: - GTK_VALUE_INT (*arg) = calitem->min_cols; - break; - case ARG_MAXIMUM_ROWS: - GTK_VALUE_INT (*arg) = calitem->max_rows; - break; - case ARG_MAXIMUM_COLUMNS: - GTK_VALUE_INT (*arg) = calitem->max_cols; - break; - case ARG_WEEK_START_DAY: - GTK_VALUE_INT (*arg) = calitem->week_start_day; - break; - case ARG_SHOW_WEEK_NUMBERS: - GTK_VALUE_BOOL (*arg) = calitem->show_week_numbers; - break; - case ARG_MAXIMUM_DAYS_SELECTED: - GTK_VALUE_INT (*arg) = e_calendar_item_get_max_days_sel (calitem); - break; - case ARG_DAYS_TO_START_WEEK_SELECTION: - GTK_VALUE_INT (*arg) = e_calendar_item_get_days_start_week_sel (calitem); - break; - case ARG_MOVE_SELECTION_WHEN_MOVING: - GTK_VALUE_BOOL (*arg) = calitem->move_selection_when_moving; - break; - case ARG_PRESERVE_DAY_WHEN_MOVING: - GTK_VALUE_BOOL (*arg) = calitem->preserve_day_when_moving; - break; - case ARG_DISPLAY_POPUP: - GTK_VALUE_BOOL (*arg) = e_calendar_item_get_display_popup (calitem); - break; - default: - g_warning ("Invalid arg"); - } -} - - -static void -e_calendar_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - ECalendarItem *calitem; - PangoFontDescription *font_desc; - gboolean need_update = FALSE; - gdouble dvalue; - gint ivalue; - gboolean bvalue; - - item = GNOME_CANVAS_ITEM (o); - calitem = E_CALENDAR_ITEM (o); - - switch (arg_id){ - case ARG_YEAR: - ivalue = GTK_VALUE_INT (*arg); - e_calendar_item_set_first_month (calitem, ivalue, - calitem->month); - break; - case ARG_MONTH: - ivalue = GTK_VALUE_INT (*arg); - e_calendar_item_set_first_month (calitem, calitem->year, - ivalue); - break; - case ARG_X1: - dvalue = GTK_VALUE_DOUBLE (*arg); - if (calitem->x1 != dvalue) { - calitem->x1 = dvalue; - need_update = TRUE; - } - break; - case ARG_Y1: - dvalue = GTK_VALUE_DOUBLE (*arg); - if (calitem->y1 != dvalue) { - calitem->y1 = dvalue; - need_update = TRUE; - } - break; - case ARG_X2: - dvalue = GTK_VALUE_DOUBLE (*arg); - if (calitem->x2 != dvalue) { - calitem->x2 = dvalue; - need_update = TRUE; - } - break; - case ARG_Y2: - dvalue = GTK_VALUE_DOUBLE (*arg); - if (calitem->y2 != dvalue) { - calitem->y2 = dvalue; - need_update = TRUE; - } - break; - case ARG_FONT_DESC: - font_desc = GTK_VALUE_BOXED (*arg); - if (calitem->font_desc) - pango_font_description_free (calitem->font_desc); - calitem->font_desc = pango_font_description_copy (font_desc); - need_update = TRUE; - break; - case ARG_WEEK_NUMBER_FONT_DESC: - font_desc = GTK_VALUE_BOXED (*arg); - if (calitem->week_number_font_desc) - pango_font_description_free (calitem->week_number_font_desc); - calitem->week_number_font_desc = pango_font_description_copy (font_desc); - need_update = TRUE; - break; - case ARG_MINIMUM_ROWS: - ivalue = GTK_VALUE_INT (*arg); - ivalue = MAX (1, ivalue); - if (calitem->min_rows != ivalue) { - calitem->min_rows = ivalue; - need_update = TRUE; - } - break; - case ARG_MINIMUM_COLUMNS: - ivalue = GTK_VALUE_INT (*arg); - ivalue = MAX (1, ivalue); - if (calitem->min_cols != ivalue) { - calitem->min_cols = ivalue; - need_update = TRUE; - } - break; - case ARG_MAXIMUM_ROWS: - ivalue = GTK_VALUE_INT (*arg); - if (calitem->max_rows != ivalue) { - calitem->max_rows = ivalue; - need_update = TRUE; - } - break; - case ARG_MAXIMUM_COLUMNS: - ivalue = GTK_VALUE_INT (*arg); - if (calitem->max_cols != ivalue) { - calitem->max_cols = ivalue; - need_update = TRUE; - } - break; - case ARG_WEEK_START_DAY: - ivalue = GTK_VALUE_INT (*arg); - if (calitem->week_start_day != ivalue) { - calitem->week_start_day = ivalue; - need_update = TRUE; - } - break; - case ARG_SHOW_WEEK_NUMBERS: - bvalue = GTK_VALUE_BOOL (*arg); - if (calitem->show_week_numbers != bvalue) { - calitem->show_week_numbers = bvalue; - need_update = TRUE; - } - break; - case ARG_MAXIMUM_DAYS_SELECTED: - ivalue = GTK_VALUE_INT (*arg); - e_calendar_item_set_max_days_sel (calitem, ivalue); - break; - case ARG_DAYS_TO_START_WEEK_SELECTION: - ivalue = GTK_VALUE_INT (*arg); - e_calendar_item_set_days_start_week_sel (calitem, ivalue); - break; - case ARG_MOVE_SELECTION_WHEN_MOVING: - bvalue = GTK_VALUE_BOOL (*arg); - calitem->move_selection_when_moving = bvalue; - break; - case ARG_PRESERVE_DAY_WHEN_MOVING: - bvalue = GTK_VALUE_BOOL (*arg); - calitem->preserve_day_when_moving = bvalue; - break; - case ARG_DISPLAY_POPUP: - bvalue = GTK_VALUE_BOOL (*arg); - e_calendar_item_set_display_popup (calitem, bvalue); - break; - default: - g_warning ("Invalid arg"); - } - - if (need_update) { - gnome_canvas_item_request_update (item); - } -} - -static void -e_calendar_item_realize (GnomeCanvasItem *item) -{ - ECalendarItem *calitem; - GdkColormap *colormap; - gboolean success[E_CALENDAR_ITEM_COLOR_LAST]; - gint nfailed; - - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->realize) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->realize) (item); - - calitem = E_CALENDAR_ITEM (item); - - colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas)); - - calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX].red = 65535; - calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX].green = 0; - calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX].blue = 0; - - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG].red = 65535; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG].green = 65535; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG].blue = 65535; - - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED].red = 4700; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED].green = 4700; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED].blue = 65535; - - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG].red = 47000; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG].green = 47000; - calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG].blue = 48000; - - calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG].red = 47000; - calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG].green = 47000; - calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG].blue = 48000; - - nfailed = gdk_colormap_alloc_colors (colormap, calitem->colors, - E_CALENDAR_ITEM_COLOR_LAST, FALSE, - TRUE, success); - if (nfailed) - g_warning ("Failed to allocate all colors"); -} - - -static void -e_calendar_item_unrealize (GnomeCanvasItem *item) -{ - ECalendarItem *calitem; - GdkColormap *colormap; - gint i; - - calitem = E_CALENDAR_ITEM (item); - - colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas)); - - for (i = 0; i < E_CALENDAR_ITEM_COLOR_LAST; i++) { - /* FIXME: gdk_colors_free expects gulong* here but the pixel value in GdkColor - is guint32. GDK bug? */ - gdk_colors_free (colormap, (gulong *) &calitem->colors[i].pixel, 1, 0); - } - - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->unrealize) (item); -} - - -static void -e_calendar_item_unmap (GnomeCanvasItem *item) -{ - ECalendarItem *calitem; - - calitem = E_CALENDAR_ITEM (item); - - if (calitem->selecting) { - gnome_canvas_item_ungrab (item, GDK_CURRENT_TIME); - calitem->selecting = FALSE; - } - - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->unmap) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->unmap) (item); -} - - -static void -e_calendar_item_update (GnomeCanvasItem *item, - double *affine, - ArtSVP *clip_path, - int flags) -{ - ECalendarItem *calitem; - GtkStyle *style; - gint char_height, width, height, space, space_per_cal, space_per_cell; - gint rows, cols, xthickness, ythickness; - PangoFontDescription *font_desc; - PangoContext *pango_context; - PangoFontMetrics *font_metrics; - - if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) - (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); - - calitem = E_CALENDAR_ITEM (item); - style = GTK_WIDGET (item->canvas)->style; - xthickness = style->xthickness; - ythickness = style->ythickness; - - item->x1 = calitem->x1; - item->y1 = calitem->y1; - item->x2 = calitem->x2 >= calitem->x1 ? calitem->x2 : calitem->x1; - item->y2 = calitem->y2 >= calitem->y1 ? calitem->y2 : calitem->y1; - - /* Set up Pango prerequisites */ - font_desc = style->font_desc; - pango_context = gtk_widget_get_pango_context (GTK_WIDGET (item->canvas)); - font_metrics = pango_context_get_metrics (pango_context, font_desc, - pango_context_get_language (pango_context)); - - /* - * Calculate the new layout of the calendar. - */ - - /* Make sure the minimum row width & cell height and the widths of - all the digits and characters are up to date. */ - e_calendar_item_recalc_sizes (calitem); - - /* Calculate how many rows & cols we can fit in. */ - width = item->x2 - item->x1; - height = item->y2 - item->y1; - - width -= xthickness * 2; - height -= ythickness * 2; - - if (calitem->min_month_height == 0) - rows = 1; - else - rows = height / calitem->min_month_height; - rows = MAX (rows, calitem->min_rows); - if (calitem->max_rows > 0) - rows = MIN (rows, calitem->max_rows); - - if (calitem->min_month_width == 0) - cols = 1; - else - cols = width / calitem->min_month_width; - cols = MAX (cols, calitem->min_cols); - if (calitem->max_cols > 0) - cols = MIN (cols, calitem->max_cols); - - if (rows != calitem->rows || cols != calitem->cols) - e_calendar_item_date_range_changed (calitem); - - calitem->rows = rows; - calitem->cols = cols; - - /* Split up the empty space according to the configuration. - If the calendar is set to expand, we divide the space between the - cells and the spaces around the calendar, otherwise we place the - calendars in the center of the available area. */ - - char_height = - PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + - PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - - calitem->month_width = calitem->min_month_width; - calitem->month_height = calitem->min_month_height; - calitem->cell_width = calitem->max_digit_width * 2 - + E_CALENDAR_ITEM_MIN_CELL_XPAD; - calitem->cell_height = char_height - + E_CALENDAR_ITEM_MIN_CELL_YPAD; - calitem->month_tpad = 0; - calitem->month_bpad = 0; - calitem->month_lpad = 0; - calitem->month_rpad = 0; - - space = height - calitem->rows * calitem->month_height; - if (space > 0) { - space_per_cal = space / calitem->rows; - calitem->month_height += space_per_cal; - - if (calitem->expand) { - space_per_cell = space_per_cal / E_CALENDAR_ROWS_PER_MONTH; - calitem->cell_height += space_per_cell; - space_per_cal -= space_per_cell * E_CALENDAR_ROWS_PER_MONTH; - } - - calitem->month_tpad = space_per_cal / 2; - calitem->month_bpad = space_per_cal - calitem->month_tpad; - } - - space = width - calitem->cols * calitem->month_width; - if (space > 0) { - space_per_cal = space / calitem->cols; - calitem->month_width += space_per_cal; - space -= space_per_cal * calitem->cols; - - if (calitem->expand) { - space_per_cell = space_per_cal / E_CALENDAR_COLS_PER_MONTH; - calitem->cell_width += space_per_cell; - space_per_cal -= space_per_cell * E_CALENDAR_COLS_PER_MONTH; - } - - calitem->month_lpad = space_per_cal / 2; - calitem->month_rpad = space_per_cal - calitem->month_lpad; - } - - space = MAX (0, space); - calitem->x_offset = space / 2; - - gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, - item->x2, item->y2); - - pango_font_metrics_unref (font_metrics); -} - - -/* - * DRAWING ROUTINES - functions to paint the canvas item. - */ - -static void -e_calendar_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, - int x, - int y, - int width, - int height) -{ - ECalendarItem *calitem; - GtkStyle *style; - GdkGC *base_gc, *bg_gc; - gint char_height, row, col, row_y, bar_height, col_x; - gint xthickness, ythickness; - PangoFontDescription *font_desc; - PangoContext *pango_context; - PangoFontMetrics *font_metrics; - -#if 0 - g_print ("In e_calendar_item_draw %i,%i %ix%i\n", - x, y, width, height); -#endif - calitem = E_CALENDAR_ITEM (canvas_item); - style = GTK_WIDGET (canvas_item->canvas)->style; - - /* Set up Pango prerequisites */ - font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; - pango_context = gtk_widget_get_pango_context (GTK_WIDGET (canvas_item->canvas)); - font_metrics = pango_context_get_metrics (pango_context, font_desc, - pango_context_get_language (pango_context)); - - char_height = - PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + - PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - xthickness = style->xthickness; - ythickness = style->ythickness; - base_gc = style->base_gc[GTK_STATE_NORMAL]; - bg_gc = style->bg_gc[GTK_STATE_NORMAL]; - - /* Clear the entire background. */ - gdk_draw_rectangle (drawable, base_gc, TRUE, - calitem->x1 - x, calitem->y1 - y, - calitem->x2 - calitem->x1 + 1, - calitem->y2 - calitem->y1 + 1); - - /* Draw the shadow around the entire item. */ - gtk_draw_shadow (style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - calitem->x1 - x, calitem->y1 - y, - calitem->x2 - calitem->x1 + 1, - calitem->y2 - calitem->y1 + 1); - - row_y = canvas_item->y1 + ythickness; - bar_height = ythickness * 2 - + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME + char_height - + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME; - - for (row = 0; row < calitem->rows; row++) { - /* Draw the background for the title bars and the shadow around - it, and the vertical lines between columns. */ - - gdk_draw_rectangle (drawable, bg_gc, TRUE, - calitem->x1 + xthickness - x, row_y - y, - calitem->x2 - calitem->x1 + 1 - - xthickness * 2, - bar_height); - - gtk_draw_shadow (style, drawable, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - calitem->x1 + xthickness - x, row_y - y, - calitem->x2 - calitem->x1 + 1 - - xthickness * 2, - bar_height); - - - for (col = 0; col < calitem->cols; col++) { - if (col != 0) { - col_x = calitem->x1 + calitem->x_offset - + calitem->month_width * col; - gtk_draw_vline (style, drawable, - GTK_STATE_NORMAL, - row_y + ythickness + 1 - y, - row_y + bar_height - - ythickness - 2 - y, - col_x - 1 - x); - } - - - e_calendar_item_draw_month (calitem, drawable, x, y, - width, height, row, col); - } - - row_y += calitem->month_height; - } - - pango_font_metrics_unref (font_metrics); -} - - -static void -layout_set_day_text (ECalendarItem *calitem, PangoLayout *layout, int day_index) -{ - char *day; - int char_size = 0; - - day = g_utf8_offset_to_pointer (calitem->days, day_index); - - /* we use strlen because we actually want to count bytes */ - if (day_index == 6) - char_size = strlen (day); - else - char_size = strlen (day) - strlen (g_utf8_find_next_char (day, NULL)); - - pango_layout_set_text (layout, day, char_size); -} - -static void -e_calendar_item_draw_month (ECalendarItem *calitem, - GdkDrawable *drawable, - int x, - int y, - int width, - int height, - int row, - int col) -{ - GnomeCanvasItem *item; - GtkWidget *widget; - GtkStyle *style; - PangoFontDescription *font_desc; - GdkGC *fg_gc; - struct tm tmp_tm; - GdkRectangle clip_rect; - gint char_height, xthickness, ythickness, start_weekday; - gint year, month; - gint month_x, month_y, month_w, month_h; - gint min_x, max_x, text_x, text_y; - gint day, day_index, cells_x, cells_y, min_cell_width, text_width; - gint clip_width, clip_height; - gchar buffer[64]; - PangoContext *pango_context; - PangoFontMetrics *font_metrics; - PangoLayout *layout; - -#if 0 - g_print ("In e_calendar_item_draw_month: %i,%i %ix%i row:%i col:%i\n", - x, y, width, height, row, col); -#endif - item = GNOME_CANVAS_ITEM (calitem); - widget = GTK_WIDGET (item->canvas); - style = widget->style; - - /* Set up Pango prerequisites */ - font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; - pango_context = gtk_widget_get_pango_context (widget); - font_metrics = pango_context_get_metrics (pango_context, font_desc, - pango_context_get_language (pango_context)); - - char_height = - PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + - PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - xthickness = style->xthickness; - ythickness = style->ythickness; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - - pango_font_metrics_unref (font_metrics); - - /* Calculate the top-left position of the entire month display. */ - month_x = item->x1 + xthickness + calitem->x_offset - + col * calitem->month_width - x; - month_w = item->x2 - item->x1 - xthickness * 2; - month_w = MIN (month_w, calitem->month_width); - month_y = item->y1 + ythickness + row * calitem->month_height - y; - month_h = item->y2 - item->y1 - ythickness * 2; - month_h = MIN (month_h, calitem->month_height); - - /* Just return if the month is outside the given area. */ - if (month_x >= width || month_x + calitem->month_width <= 0 - || month_y >= height || month_y + calitem->month_height <= 0) - return; - - month = calitem->month + row * calitem->cols + col; - year = calitem->year + month / 12; - month %= 12; - - /* Draw the month name & year, with clipping. Note that the top row - needs extra space around it for the buttons. */ - - layout = gtk_widget_create_pango_layout (widget, NULL); - - if (row == 0 && col == 0) - min_x = E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME_WITH_BUTTON; - else - min_x = E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME; - - max_x = month_w; - if (row == 0 && col == calitem->cols - 1) - max_x -= E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME_WITH_BUTTON; - else - max_x -= E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME; - - text_y = month_y + style->ythickness - + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME; - clip_rect.x = month_x + min_x; - clip_rect.x = MAX (0, clip_rect.x); - clip_rect.y = MAX (0, text_y); - - memset (&tmp_tm, 0, sizeof (tmp_tm)); - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = 1; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - start_weekday = (tmp_tm.tm_wday + 6) % 7; - - if (month_x + max_x - clip_rect.x > 0) { - clip_rect.width = month_x + max_x - clip_rect.x; - clip_rect.height = text_y + char_height - clip_rect.y; - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - /* This is a strftime() format. %B = Month name, %Y = Year. */ - e_utf8_strftime (buffer, sizeof (buffer), _("%B %Y"), &tmp_tm); - - pango_layout_set_font_description (layout, font_desc); - pango_layout_set_text (layout, buffer, -1); - - /* Ideally we place the text centered in the month, but we - won't go to the left of the minimum x position. */ - pango_layout_get_pixel_size (layout, &text_width, NULL); - text_x = (calitem->month_width - text_width) / 2; - text_x = MAX (min_x, text_x); - - gdk_draw_layout (drawable, fg_gc, - month_x + text_x, - text_y, - layout); - } - - /* Set the clip rectangle for the main month display. */ - clip_rect.x = MAX (0, month_x); - clip_rect.y = MAX (0, month_y); - clip_width = month_x + month_w - clip_rect.x; - clip_height = month_y + month_h - clip_rect.y; - - if (clip_width <= 0 || clip_height <= 0) { - g_object_unref (layout); - return; - } - - clip_rect.width = clip_width; - clip_rect.height = clip_height; - - gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); - - - /* Draw the day initials across the top of the month. */ - min_cell_width = calitem->max_digit_width * 2 - + E_CALENDAR_ITEM_MIN_CELL_XPAD; - - cells_x = month_x + E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS + calitem->month_lpad - + E_CALENDAR_ITEM_XPAD_BEFORE_CELLS; - if (calitem->show_week_numbers) - cells_x += calitem->max_week_number_digit_width * 2 - + E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS + 1; - text_x = cells_x + calitem->cell_width - - (calitem->cell_width - min_cell_width) / 2; - text_x -= E_CALENDAR_ITEM_MIN_CELL_XPAD / 2; - text_y = month_y + ythickness * 2 - + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME - + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME - + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS + calitem->month_tpad; - - cells_y = text_y + char_height - + E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS + 1 - + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS; - - day_index = calitem->week_start_day; - pango_layout_set_font_description (layout, font_desc); - for (day = 0; day < 7; day++) { - layout_set_day_text (calitem, layout, day_index); - gdk_draw_layout (drawable, fg_gc, - text_x - calitem->day_widths [day_index], - text_y, - layout); - - text_x += calitem->cell_width; - day_index++; - if (day_index == 7) - day_index = 0; - } - - - /* Draw the horizontal line beneath the day initials. */ - gdk_draw_line (drawable, fg_gc, - cells_x - E_CALENDAR_ITEM_XPAD_BEFORE_CELLS, - cells_y - E_CALENDAR_ITEM_YPAD_ABOVE_CELLS - 1, - cells_x + E_CALENDAR_COLS_PER_MONTH * calitem->cell_width - 1, - cells_y - E_CALENDAR_ITEM_YPAD_ABOVE_CELLS - 1); - - e_calendar_item_draw_day_numbers (calitem, drawable, width, height, - row, col, year, month, start_weekday, - cells_x, cells_y); - - /* Draw the vertical line after the week number. */ - if (calitem->show_week_numbers) { - gdk_draw_line (drawable, fg_gc, - cells_x - E_CALENDAR_ITEM_XPAD_BEFORE_CELLS - 1, - cells_y - E_CALENDAR_ITEM_YPAD_ABOVE_CELLS - 1, - cells_x - E_CALENDAR_ITEM_XPAD_BEFORE_CELLS - 1, - cells_y + E_CALENDAR_ROWS_PER_MONTH * calitem->cell_height - 1); - } - - gdk_gc_set_clip_rectangle (fg_gc, NULL); - g_object_unref (layout); -} - - -static void -e_calendar_item_draw_day_numbers (ECalendarItem *calitem, - GdkDrawable *drawable, - int width, - int height, - int row, - int col, - int year, - int month, - int start_weekday, - gint cells_x, - gint cells_y) -{ - GnomeCanvasItem *item; - GtkWidget *widget; - GtkStyle *style; - PangoFontDescription *font_desc, *wkfont_desc; - GdkGC *fg_gc; - GdkColor *bg_color, *fg_color, *box_color; - struct tm today_tm; - time_t t; - gint char_height, min_cell_width, min_cell_height; - gint day_num, drow, dcol, day_x, day_y; - gint text_x, text_y; - gint num_chars, digit; - gint week_num, mon, days_from_week_start; - gint years[3], months[3], days_in_month[3]; - gboolean today, selected, has_focus, drop_target = FALSE; - gboolean bold, draw_day, finished = FALSE; - gint today_year, today_month, today_mday, month_offset; - gchar buffer[2]; - gint day_style = 0; - PangoContext *pango_context; - PangoFontMetrics *font_metrics; - PangoLayout *layout; - - item = GNOME_CANVAS_ITEM (calitem); - widget = GTK_WIDGET (item->canvas); - style = widget->style; - - /* Set up Pango prerequisites */ - font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; - wkfont_desc = calitem->week_number_font_desc; - if (!wkfont_desc) - wkfont_desc = font_desc; - fg_gc = style->fg_gc[GTK_STATE_NORMAL]; - - pango_context = gtk_widget_get_pango_context (widget); - font_metrics = pango_context_get_metrics (pango_context, font_desc, - pango_context_get_language (pango_context)); - - char_height = - PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + - PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - - min_cell_width = calitem->max_digit_width * 2 - + E_CALENDAR_ITEM_MIN_CELL_XPAD; - min_cell_height = char_height + E_CALENDAR_ITEM_MIN_CELL_YPAD; - - layout = gtk_widget_create_pango_layout (widget, NULL); - - /* Calculate the number of days in the previous, current, and next - months. */ - years[0] = years[1] = years[2] = year; - months[0] = month - 1; - months[1] = month; - months[2] = month + 1; - if (months[0] == -1) { - months[0] = 11; - years[0]--; - } - if (months[2] == 12) { - months[2] = 0; - years[2]++; - } - - days_in_month[0] = DAYS_IN_MONTH (years[0], months[0]); - days_in_month[1] = DAYS_IN_MONTH (years[1], months[1]); - days_in_month[2] = DAYS_IN_MONTH (years[2], months[2]); - - /* Mon 0 is the previous month, which we may show the end of. Mon 1 is - the current month, and mon 2 is the next month. */ - mon = 0; - - month_offset = row * calitem->cols + col - 1; - day_num = days_in_month[0]; - days_from_week_start = (start_weekday + 7 - calitem->week_start_day) - % 7; - /* For the top-left month we show the end of the previous month, and - if the new month starts on the first day of the week we show a - complete week from the previous month. */ - if (days_from_week_start == 0) { - if (row == 0 && col == 0) { - day_num -= 6; - } else { - mon++; - month_offset++; - day_num = 1; - } - } else { - day_num -= days_from_week_start - 1; - } - - /* Get today's date, so we can highlight it. */ - if (calitem->time_callback) { - today_tm = (*calitem->time_callback) (calitem, calitem->time_callback_data); - } else { - t = time (NULL); - today_tm = *localtime (&t); - } - today_year = today_tm.tm_year + 1900; - today_month = today_tm.tm_mon; - today_mday = today_tm.tm_mday; - - /* We usually skip the last days of the previous month (mon = 0), - except for the top-left month displayed. */ - draw_day = (mon == 1 || (row == 0 && col == 0)); - - for (drow = 0; drow < 6; drow++) { - /* Draw the week number. */ - if (calitem->show_week_numbers) { - week_num = e_calendar_item_get_week_number (calitem, - day_num, - months[mon], - years[mon]); - - text_x = cells_x - E_CALENDAR_ITEM_XPAD_BEFORE_CELLS - 1 - - E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS; - text_y = cells_y + drow * calitem->cell_height + - + (calitem->cell_height - min_cell_height + 1) / 2; - - num_chars = 0; - if (week_num >= 10) { - digit = week_num / 10; - text_x -= calitem->week_number_digit_widths[digit]; - buffer[num_chars++] = digit + '0'; - } - - digit = week_num % 10; - text_x -= calitem->week_number_digit_widths[digit]; - buffer[num_chars++] = digit + '0'; - - gdk_gc_set_foreground (fg_gc, - &style->fg[GTK_STATE_NORMAL]); - - pango_layout_set_font_description (layout, wkfont_desc); - pango_layout_set_text (layout, buffer, num_chars); - gdk_draw_layout (drawable, fg_gc, - text_x, - text_y, - layout); - } - - for (dcol = 0; dcol < 7; dcol++) { - if (draw_day) { - day_x = cells_x + dcol * calitem->cell_width; - day_y = cells_y + drow * calitem->cell_height; - - today = years[mon] == today_year - && months[mon] == today_month - && day_num == today_mday; - - selected = calitem->selection_set - && (calitem->selection_start_month_offset < month_offset - || (calitem->selection_start_month_offset == month_offset - && calitem->selection_start_day <= day_num)) - && (calitem->selection_end_month_offset > month_offset - || (calitem->selection_end_month_offset == month_offset - && calitem->selection_end_day >= day_num)); - - if (calitem->styles) - day_style = calitem->styles[(month_offset + 1) * 32 + day_num]; - - /* Get the colors & style to use for the day.*/ - if ((GTK_WIDGET_HAS_FOCUS(item->canvas)) && - item->canvas->focused_item == item) - has_focus = TRUE; - else - has_focus = FALSE; - - if (calitem->style_callback) - (*calitem->style_callback) - (calitem, - years[mon], - months[mon], - day_num, - day_style, - today, - mon != 1, - selected, - has_focus, - drop_target, - &bg_color, - &fg_color, - &box_color, - &bold, - calitem->style_callback_data); - else - e_calendar_item_get_day_style - (calitem, - years[mon], - months[mon], - day_num, - day_style, - today, - mon != 1, - selected, - has_focus, - drop_target, - &bg_color, - &fg_color, - &box_color, - &bold); - - /* Draw the background, if set. */ - if (bg_color) { - gdk_gc_set_foreground (fg_gc, bg_color); - gdk_draw_rectangle (drawable, fg_gc, - TRUE, - day_x, day_y, - calitem->cell_width, - calitem->cell_height); - } - - /* Draw the box, if set. */ - if (box_color) { - gdk_gc_set_foreground (fg_gc, box_color); - gdk_draw_rectangle (drawable, fg_gc, - FALSE, - day_x, day_y, - calitem->cell_width - 1, - calitem->cell_height - 1); - } - - /* Draw the 1- or 2-digit day number. */ - day_x += calitem->cell_width - (calitem->cell_width - min_cell_width) / 2; - day_x -= E_CALENDAR_ITEM_MIN_CELL_XPAD / 2; - day_y += (calitem->cell_height - min_cell_height + 1) / 2; - day_y += E_CALENDAR_ITEM_MIN_CELL_YPAD / 2; - - num_chars = 0; - if (day_num >= 10) { - digit = day_num / 10; - day_x -= calitem->digit_widths[digit]; - buffer[num_chars++] = digit + '0'; - } - - digit = day_num % 10; - day_x -= calitem->digit_widths[digit]; - buffer[num_chars++] = digit + '0'; - - if (fg_color) { - gdk_gc_set_foreground (fg_gc, - fg_color); - } else { - gdk_gc_set_foreground (fg_gc, - &style->fg[GTK_STATE_NORMAL]); - } - - pango_layout_set_font_description (layout, font_desc); - pango_layout_set_text (layout, buffer, num_chars); - gdk_draw_layout (drawable, fg_gc, - day_x, - day_y, - layout); - - /* We use a stupid technique for bold. Just - draw it again 1 pixel to the left. */ - if (bold) - gdk_draw_layout (drawable, fg_gc, - day_x - 1, - day_y, - layout); - } - - /* See if we've reached the end of a month. */ - if (day_num == days_in_month[mon]) { - month_offset++; - mon++; - /* We only draw the start of the next month - for the bottom-right month displayed. */ - if (mon == 2 && (row != calitem->rows - 1 - || col != calitem->cols - 1)) { - /* Set a flag so we exit the loop. */ - finished = TRUE; - break; - } - day_num = 1; - draw_day = TRUE; - } else { - day_num++; - } - } - - /* Exit the loop if the flag is set. */ - if (finished) - break; - } - - /* Reset the foreground color. */ - gdk_gc_set_foreground (fg_gc, &style->fg[GTK_STATE_NORMAL]); - - g_object_unref (layout); - pango_font_metrics_unref (font_metrics); -} - - -gint -e_calendar_item_get_week_number (ECalendarItem *calitem, - gint day, - gint month, - gint year) -{ - GDate date; - guint weekday, yearday; - int offset, week_num; - - /* FIXME: check what happens at year boundaries. */ - - g_date_clear (&date, 1); - g_date_set_dmy (&date, day, month + 1, year); - - /* This results in a value of 0 (Monday) - 6 (Sunday). (or -1 on error - oops!!) */ - weekday = g_date_get_weekday (&date) - 1; - - /* Calculate the offset from the start of the week. */ - offset = (calitem->week_start_day + 7 - weekday) % 7; - - /* Calculate the day of the year, from 0 to 365. */ - yearday = g_date_get_day_of_year (&date) - 1; - - /* If the week starts on or after 29th December, it is week 1 of the - next year, since there are 4 days in the next year. */ - g_date_subtract_days (&date, offset); - if (g_date_get_month (&date) == 12 && g_date_get_day (&date) >= 29) - return 1; - - /* Calculate the week number, from 0. */ - week_num = (yearday - offset) / 7; - - /* If the first week starts on or after Jan 5th, then we need to add - 1 since the previous week will really be the first week. */ - if ((yearday - offset) % 7 >= 4) - week_num++; - - /* Add 1 so week numbers are from 1 to 53. */ - return week_num + 1; -} - - - -/* This is supposed to return the nearest item the the point and the distance. - Since we are the only item we just return ourself and 0 for the distance. - This is needed so that we get button/motion events. */ -static double -e_calendar_item_point (GnomeCanvasItem *item, double x, double y, - int cx, int cy, - GnomeCanvasItem **actual_item) -{ - *actual_item = item; - return 0.0; -} - -static void -e_calendar_item_stop_selecting (ECalendarItem *calitem, guint32 time) -{ - if (!calitem->selecting) - return; - - gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM (calitem), time); - - calitem->selecting = FALSE; - - /* If the user selects the grayed dates before the first month or - after the last month, we move backwards or forwards one month. - The set_month() call should take care of updating the selection. */ - if (calitem->selection_end_month_offset == -1) - e_calendar_item_set_first_month (calitem, calitem->year, - calitem->month - 1); - else if (calitem->selection_start_month_offset == calitem->rows * calitem->cols) - e_calendar_item_set_first_month (calitem, calitem->year, - calitem->month + 1); - - calitem->selection_changed = TRUE; - if (calitem->selecting_axis) { - g_free (calitem->selecting_axis); - calitem->selecting_axis = NULL; - } - - e_calendar_item_queue_signal_emission (calitem); - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); -} - -static void -e_calendar_item_selection_add_days (ECalendarItem *calitem, gint n_days, - gboolean multi_selection) -{ - GDate gdate_start, gdate_end; - - g_return_if_fail (E_IS_CALENDAR_ITEM (calitem)); - - if (!e_calendar_item_get_selection (calitem, &gdate_start, &gdate_end)) { - /* We set the date to the first day of the month */ - g_date_set_dmy (&gdate_start, 1, calitem->month + 1, calitem->year); - gdate_end = gdate_start; - } - - if (multi_selection && calitem->max_days_selected > 1) { - gint days_between; - - days_between = g_date_days_between (&gdate_start, &gdate_end); - if (!calitem->selecting_axis) { - calitem->selecting_axis = g_new (GDate, 1); - *(calitem->selecting_axis) = gdate_start; - } - if ((days_between != 0 && - g_date_compare (calitem->selecting_axis, &gdate_end) == 0) || - (days_between == 0 && n_days < 0)) { - if (days_between - n_days > calitem->max_days_selected - 1) - n_days = days_between + 1 - calitem->max_days_selected; - g_date_add_days (&gdate_start, n_days); - } - else { - if (days_between + n_days > calitem->max_days_selected - 1) - n_days = calitem->max_days_selected - 1 - days_between; - g_date_add_days (&gdate_end, n_days); - } - - if (g_date_compare (&gdate_end, &gdate_start) < 0) { - GDate tmp_date; - tmp_date = gdate_start; - gdate_start = gdate_end; - gdate_end = tmp_date; - } - } - else { - /* clear "selecting_axis", it is only for mulit-selecting */ - if (calitem->selecting_axis) { - g_free (calitem->selecting_axis); - calitem->selecting_axis = NULL; - } - g_date_add_days (&gdate_start, n_days); - gdate_end = gdate_start; - } - - calitem->selecting = TRUE; - - e_calendar_item_set_selection_if_emission (calitem, - &gdate_start, &gdate_end, - FALSE); - g_signal_emit_by_name (G_OBJECT (calitem), - "selection_preview_changed"); -} - -static gint -e_calendar_item_key_press_event (ECalendarItem *calitem, GdkEvent *event) -{ - guint keyval = event->key.keyval; - gboolean multi_selection = FALSE; - - if (event->key.state & GDK_CONTROL_MASK || - event->key.state & GDK_MOD1_MASK) - return FALSE; - - multi_selection = event->key.state & GDK_SHIFT_MASK; - switch (keyval) { - case GDK_Up: - e_calendar_item_selection_add_days (calitem, -7, - multi_selection); - break; - case GDK_Down: - e_calendar_item_selection_add_days (calitem, 7, - multi_selection); - break; - case GDK_Left: - e_calendar_item_selection_add_days (calitem, -1, - multi_selection); - break; - case GDK_Right: - e_calendar_item_selection_add_days (calitem, 1, - multi_selection); - break; - case GDK_space: - case GDK_Return: - e_calendar_item_stop_selecting (calitem, event->key.time); - break; - default: - return FALSE; - } - return TRUE; -} - -static gint -e_calendar_item_event (GnomeCanvasItem *item, GdkEvent *event) -{ - ECalendarItem *calitem; - - calitem = E_CALENDAR_ITEM (item); - - switch (event->type) { - case GDK_BUTTON_PRESS: - return e_calendar_item_button_press (calitem, event); - case GDK_BUTTON_RELEASE: - return e_calendar_item_button_release (calitem, event); - case GDK_MOTION_NOTIFY: - return e_calendar_item_motion (calitem, event); - case GDK_FOCUS_CHANGE: - gnome_canvas_item_request_update (item); - case GDK_KEY_PRESS: - return e_calendar_item_key_press_event (calitem, event); - default: - break; - } - - return FALSE; -} - -static void -e_calendar_item_bounds (GnomeCanvasItem *item, double *x1, double *y1, - double *x2, double *y2) -{ - ECalendarItem *calitem; - - g_return_if_fail (E_IS_CALENDAR_ITEM (item)); - - calitem = E_CALENDAR_ITEM (item); - *x1 = calitem->x1; - *y1 = calitem->y1; - *x2 = calitem->x2; - *y2 = calitem->y2; -} - -/* This checks if any fonts have changed, and if so it recalculates the - text sizes and the minimum month size. */ -static void -e_calendar_item_recalc_sizes (ECalendarItem *calitem) -{ - GnomeCanvasItem *canvas_item; - GtkStyle *style; - gchar *digits = "0123456789"; - gint day, digit, max_digit_width, max_week_number_digit_width; - gint char_height, width, min_cell_width, min_cell_height; - PangoFontDescription *font_desc, *wkfont_desc; - PangoContext *pango_context; - PangoFontMetrics *font_metrics; - PangoLayout *layout; - - canvas_item = GNOME_CANVAS_ITEM (calitem); - style = GTK_WIDGET (canvas_item->canvas)->style; - - if (!style) - return; - - /* Set up Pango prerequisites */ - font_desc = calitem->font_desc; - wkfont_desc = calitem->week_number_font_desc; - if (!font_desc) - font_desc = style->font_desc; - - pango_context = gtk_widget_create_pango_context (GTK_WIDGET (canvas_item->canvas)); - font_metrics = pango_context_get_metrics (pango_context, font_desc, - pango_context_get_language (pango_context)); - layout = pango_layout_new (pango_context); - - - char_height = - PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + - PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - - for (day = 0; day < 7; day++) { - layout_set_day_text (calitem, layout, day); - pango_layout_get_pixel_size (layout, &calitem->day_widths [day], NULL); - } - - max_digit_width = 0; - max_week_number_digit_width = 0; - for (digit = 0; digit < 10; digit++) { - pango_layout_set_text (layout, &digits [digit], 1); - pango_layout_get_pixel_size (layout, &width, NULL); - - calitem->digit_widths[digit] = width; - max_digit_width = MAX (max_digit_width, width); - - if (wkfont_desc) { - pango_context_set_font_description (pango_context, wkfont_desc); - pango_layout_context_changed (layout); - - pango_layout_set_text (layout, &digits [digit], 1); - pango_layout_get_pixel_size (layout, &width, NULL); - - calitem->week_number_digit_widths[digit] = width; - max_week_number_digit_width = MAX (max_week_number_digit_width, width); - - pango_context_set_font_description (pango_context, font_desc); - pango_layout_context_changed (layout); - } else { - calitem->week_number_digit_widths[digit] = width; - max_week_number_digit_width = max_digit_width; - } - } - calitem->max_digit_width = max_digit_width; - calitem->max_week_number_digit_width = max_week_number_digit_width; - - min_cell_width = calitem->max_digit_width * 2 - + E_CALENDAR_ITEM_MIN_CELL_XPAD; - min_cell_height = char_height + E_CALENDAR_ITEM_MIN_CELL_YPAD; - - calitem->min_month_width = E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS - + E_CALENDAR_ITEM_XPAD_BEFORE_CELLS + min_cell_width * 7 - + E_CALENDAR_ITEM_XPAD_AFTER_CELLS; - if (calitem->show_week_numbers) { - calitem->min_month_width += calitem->max_week_number_digit_width * 2 - + E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS + 1; - } - - calitem->min_month_height = style->ythickness * 2 - + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME + char_height - + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME + 1 - + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS - + char_height + E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS + 1 - + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS + min_cell_height * 6 - + E_CALENDAR_ITEM_YPAD_BELOW_CELLS; - - g_object_unref (layout); - g_object_unref (pango_context); - pango_font_metrics_unref (font_metrics); -} - - -static void -e_calendar_item_get_day_style (ECalendarItem *calitem, - gint year, - gint month, - gint day, - gint day_style, - gboolean today, - gboolean prev_or_next_month, - gboolean selected, - gboolean has_focus, - gboolean drop_target, - GdkColor **bg_color, - GdkColor **fg_color, - GdkColor **box_color, - gboolean *bold) -{ - *bg_color = NULL; - *fg_color = NULL; - *box_color = NULL; - *bold = FALSE; - - if (day_style == 1) - *bold = TRUE; - - if (today) - *box_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX]; - - if (prev_or_next_month) - *fg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG]; - - if (selected) { - *fg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG]; - if (has_focus) - *bg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED]; - else - *bg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG]; - - } -} - - - -static gboolean -e_calendar_item_button_press (ECalendarItem *calitem, - GdkEvent *event) -{ - gint month_offset, day; - gboolean all_week, round_up_end = FALSE, round_down_start = FALSE; - - if (event->button.button == 4) - e_calendar_item_set_first_month (calitem, calitem->year, - calitem->month - 1); - else if (event->button.button == 5) - e_calendar_item_set_first_month (calitem, calitem->year, - calitem->month + 1); - - if (!e_calendar_item_convert_position_to_day (calitem, - event->button.x, - event->button.y, - TRUE, - &month_offset, &day, - &all_week)) - return FALSE; - - if (event->button.button == 3 && day == -1 - && e_calendar_item_get_display_popup (calitem)) { - e_calendar_item_show_popup_menu (calitem, - (GdkEventButton*) event, - month_offset); - return TRUE; - } - - if (event->button.button != 1 || day == -1) - return FALSE; - - if (calitem->max_days_selected < 1) - return TRUE; - - if (gnome_canvas_item_grab (GNOME_CANVAS_ITEM (calitem), - GDK_POINTER_MOTION_MASK - | GDK_BUTTON_RELEASE_MASK, - NULL, event->button.time) != 0) - return FALSE; - - calitem->selection_set = TRUE; - calitem->selection_start_month_offset = month_offset; - calitem->selection_start_day = day; - calitem->selection_end_month_offset = month_offset; - calitem->selection_end_day = day; - - calitem->selection_real_start_month_offset = month_offset; - calitem->selection_real_start_day = day; - - calitem->selection_from_full_week = FALSE; - calitem->selecting = TRUE; - calitem->selection_dragging_end = TRUE; - - if (all_week) { - calitem->selection_from_full_week = TRUE; - round_up_end = TRUE; - } - - if (calitem->days_to_start_week_selection == 1) { - round_down_start = TRUE; - round_up_end = TRUE; - } - - /* Don't round up or down if we can't select a week or more. */ - if (calitem->max_days_selected < 7) { - round_down_start = FALSE; - round_up_end = FALSE; - } - - if (round_up_end) - e_calendar_item_round_up_selection (calitem, &calitem->selection_end_month_offset, &calitem->selection_end_day); - - if (round_down_start) - e_calendar_item_round_down_selection (calitem, &calitem->selection_start_month_offset, &calitem->selection_start_day); - - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); - - return TRUE; -} - -static gboolean -e_calendar_item_button_release (ECalendarItem *calitem, - GdkEvent *event) -{ - e_calendar_item_stop_selecting (calitem, event->button.time); - return FALSE; -} - - -static gboolean -e_calendar_item_motion (ECalendarItem *calitem, - GdkEvent *event) -{ - gint start_month, start_day, end_month, end_day, month_offset, day; - gint tmp_month, tmp_day, days_in_selection; - gboolean all_week, round_up_end = FALSE, round_down_start = FALSE; - - if (!calitem->selecting) - return FALSE; - - if (!e_calendar_item_convert_position_to_day (calitem, - event->button.x, - event->button.y, - TRUE, - &month_offset, &day, - &all_week)) - return FALSE; - - if (day == -1) - return FALSE; - - if (calitem->selection_dragging_end) { - start_month = calitem->selection_real_start_month_offset; - start_day = calitem->selection_real_start_day; - end_month = month_offset; - end_day = day; - } else { - start_month = month_offset; - start_day = day; - end_month = calitem->selection_real_start_month_offset; - end_day = calitem->selection_real_start_day; - } - - if (start_month > end_month || (start_month == end_month - && start_day > end_day)) { - tmp_month = start_month; - tmp_day = start_day; - start_month = end_month; - start_day = end_day; - end_month = tmp_month; - end_day = tmp_day; - - calitem->selection_dragging_end = !calitem->selection_dragging_end; - } - - if (calitem->days_to_start_week_selection > 0) { - days_in_selection = e_calendar_item_get_inclusive_days (calitem, start_month, start_day, end_month, end_day); - if (days_in_selection >= calitem->days_to_start_week_selection) { - round_down_start = TRUE; - round_up_end = TRUE; - } - } - - /* If we are over a week number and we are dragging the end of the - selection, we round up to the end of this week. */ - if (all_week && calitem->selection_dragging_end) - round_up_end = TRUE; - - /* If the selection was started from a week number and we are dragging - the start of the selection, we need to round up the end to include - all of the original week selected. */ - if (calitem->selection_from_full_week - && !calitem->selection_dragging_end) - round_up_end = TRUE; - - /* Don't round up or down if we can't select a week or more. */ - if (calitem->max_days_selected < 7) { - round_down_start = FALSE; - round_up_end = FALSE; - } - - if (round_up_end) - e_calendar_item_round_up_selection (calitem, &end_month, - &end_day); - if (round_down_start) - e_calendar_item_round_down_selection (calitem, &start_month, - &start_day); - - - /* Check we don't go over the maximum number of days to select. */ - if (calitem->selection_dragging_end) { - e_calendar_item_check_selection_end (calitem, - start_month, - start_day, - &end_month, - &end_day); - } else { - e_calendar_item_check_selection_start (calitem, - &start_month, - &start_day, - end_month, - end_day); - } - - if (start_month == calitem->selection_start_month_offset - && start_day == calitem->selection_start_day - && end_month == calitem->selection_end_month_offset - && end_day == calitem->selection_end_day) - return FALSE; - - calitem->selection_start_month_offset = start_month; - calitem->selection_start_day = start_day; - calitem->selection_end_month_offset = end_month; - calitem->selection_end_day = end_day; - - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); - - return TRUE; -} - - -static void -e_calendar_item_check_selection_end (ECalendarItem *calitem, - gint start_month, - gint start_day, - gint *end_month, - gint *end_day) -{ - gint year, month, max_month, max_day, days_in_month; - - if (calitem->max_days_selected <= 0) - return; - - year = calitem->year; - month = calitem->month + start_month; - e_calendar_item_normalize_date (calitem, &year, &month); - - max_month = start_month; - max_day = start_day + calitem->max_days_selected - 1; - - for (;;) { - days_in_month = DAYS_IN_MONTH (year, month); - if (max_day <= days_in_month) - break; - max_month++; - month++; - if (month == 12) { - year++; - month = 0; - } - max_day -= days_in_month; - } - - if (*end_month > max_month) { - *end_month = max_month; - *end_day = max_day; - } else if (*end_month == max_month && *end_day > max_day) { - *end_day = max_day; - } -} - - -static void -e_calendar_item_check_selection_start (ECalendarItem *calitem, - gint *start_month, - gint *start_day, - gint end_month, - gint end_day) -{ - gint year, month, min_month, min_day, days_in_month; - - if (calitem->max_days_selected <= 0) - return; - - year = calitem->year; - month = calitem->month + end_month; - e_calendar_item_normalize_date (calitem, &year, &month); - - min_month = end_month; - min_day = end_day - calitem->max_days_selected + 1; - - while (min_day <= 0) { - min_month--; - month--; - if (month == -1) { - year--; - month = 11; - } - days_in_month = DAYS_IN_MONTH (year, month); - min_day += days_in_month; - } - - if (*start_month < min_month) { - *start_month = min_month; - *start_day = min_day; - } else if (*start_month == min_month && *start_day < min_day) { - *start_day = min_day; - } -} - - -/* Converts a position within the item to a month & day. - The month returned is 0 for the top-left month displayed. - If the position is over the month heading -1 is returned for the day. - If the position is over a week number the first day of the week is returned - and entire_week is set to TRUE. - It returns FALSE if the position is completely outside all months. */ -static gboolean -e_calendar_item_convert_position_to_day (ECalendarItem *calitem, - gint event_x, - gint event_y, - gboolean round_empty_positions, - gint *month_offset, - gint *day, - gboolean *entire_week) -{ - GnomeCanvasItem *item; - GtkWidget *widget; - GtkStyle *style; - gint xthickness, ythickness, char_height; - gint x, y, row, col, cells_x, cells_y, day_row, day_col; - gint first_day_offset, days_in_month, days_in_prev_month; - gint week_num_x1, week_num_x2; - PangoFontDescription *font_desc; - PangoContext *pango_context; - PangoFontMetrics *font_metrics; - - item = GNOME_CANVAS_ITEM (calitem); - widget = GTK_WIDGET (item->canvas); - style = widget->style; - - font_desc = calitem->font_desc; - if (!font_desc) - font_desc = style->font_desc; - pango_context = gtk_widget_create_pango_context (widget); - font_metrics = pango_context_get_metrics (pango_context, font_desc, - pango_context_get_language (pango_context)); - - char_height = - PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) + - PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)); - xthickness = style->xthickness; - ythickness = style->ythickness; - - pango_font_metrics_unref (font_metrics); - - *entire_week = FALSE; - - x = event_x - xthickness - calitem->x_offset; - y = event_y - ythickness; - - if (x < 0 || y < 0) - return FALSE; - - row = y / calitem->month_height; - col = x / calitem->month_width; - - if (row >= calitem->rows || col >= calitem->cols) - return FALSE; - - *month_offset = row * calitem->cols + col; - - x = x % calitem->month_width; - y = y % calitem->month_height; - - if (y < ythickness * 2 + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME - + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME) { - *day = -1; - return TRUE; - } - - cells_y = ythickness * 2 + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME - + char_height + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME - + E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS + calitem->month_tpad - + char_height + E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS + 1 - + E_CALENDAR_ITEM_YPAD_ABOVE_CELLS; - y -= cells_y; - if (y < 0) - return FALSE; - day_row = y / calitem->cell_height; - if (day_row >= E_CALENDAR_ROWS_PER_MONTH) - return FALSE; - - week_num_x1 = E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS + calitem->month_lpad; - - if (calitem->show_week_numbers) { - week_num_x2 = week_num_x1 - + calitem->max_week_number_digit_width * 2; - if (x >= week_num_x1 && x < week_num_x2) - *entire_week = TRUE; - cells_x = week_num_x2 + E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS + 1; - } else { - cells_x = week_num_x1; - } - - if (*entire_week) { - day_col = 0; - } else { - cells_x += E_CALENDAR_ITEM_XPAD_BEFORE_CELLS; - x -= cells_x; - if (x < 0) - return FALSE; - day_col = x / calitem->cell_width; - if (day_col >= E_CALENDAR_COLS_PER_MONTH) - return FALSE; - } - - *day = day_row * E_CALENDAR_COLS_PER_MONTH + day_col; - - e_calendar_item_get_month_info (calitem, row, col, &first_day_offset, - &days_in_month, &days_in_prev_month); - if (*day < first_day_offset) { - if (*entire_week || (row == 0 && col == 0)) { - (*month_offset)--; - *day = days_in_prev_month + 1 - first_day_offset - + *day; - return TRUE; - } else if (round_empty_positions) { - *day = first_day_offset; - } else { - return FALSE; - } - } - - *day -= first_day_offset - 1; - - if (*day > days_in_month) { - if (row == calitem->rows - 1 && col == calitem->cols - 1) { - (*month_offset)++; - *day -= days_in_month; - return TRUE; - } else if (round_empty_positions) { - *day = days_in_month; - } else { - return FALSE; - } - } - - return TRUE; -} - - -static void -e_calendar_item_get_month_info (ECalendarItem *calitem, - gint row, - gint col, - gint *first_day_offset, - gint *days_in_month, - gint *days_in_prev_month) -{ - gint year, month, start_weekday, first_day_of_month; - struct tm tmp_tm = { 0 }; - - month = calitem->month + row * calitem->cols + col; - year = calitem->year + month / 12; - month = month % 12; - - *days_in_month = DAYS_IN_MONTH (year, month); - if (month == 0) - *days_in_prev_month = DAYS_IN_MONTH (year - 1, 11); - else - *days_in_prev_month = DAYS_IN_MONTH (year, month - 1); - - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = 1; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - - /* Convert to 0 (Monday) to 6 (Sunday). */ - start_weekday = (tmp_tm.tm_wday + 6) % 7; - - first_day_of_month = (start_weekday + 7 - calitem->week_start_day) % 7; - - if (row == 0 && col == 0 && first_day_of_month == 0) - *first_day_offset = 7; - else - *first_day_offset = first_day_of_month; -} - - -void -e_calendar_item_get_first_month(ECalendarItem *calitem, - gint *year, - gint *month) -{ - *year = calitem->year; - *month = calitem->month; -} - - -static void -e_calendar_item_preserve_day_selection (ECalendarItem *calitem, - gint selected_day, - gint *month_offset, - gint *day) -{ - gint year, month, weekday, days, days_in_month; - struct tm tmp_tm = { 0 }; - - year = calitem->year; - month = calitem->month + *month_offset; - e_calendar_item_normalize_date (calitem, &year, &month); - - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = *day; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - - /* Convert to 0 (Monday) to 6 (Sunday). */ - weekday = (tmp_tm.tm_wday + 6) % 7; - - /* Calculate how many days to the start of the row. */ - days = (weekday + 7 - selected_day) % 7; - - *day -= days; - if (*day <= 0) { - month--; - if (month == -1) { - year--; - month = 11; - } - days_in_month = DAYS_IN_MONTH (year, month); - (*month_offset)--; - *day += days_in_month; - } -} - -/* This also handles values of month < 0 or > 11 by updating the year. */ -void -e_calendar_item_set_first_month(ECalendarItem *calitem, - gint year, - gint month) -{ - gint new_year, new_month, months_diff, num_months; - gint old_days_in_selection, new_days_in_selection; - - new_year = year; - new_month = month; - e_calendar_item_normalize_date (calitem, &new_year, &new_month); - - if (calitem->year == new_year && calitem->month == new_month) - return; - - /* Update the selection. */ - num_months = calitem->rows * calitem->cols; - months_diff = (new_year - calitem->year) * 12 - + new_month - calitem->month; - - if (calitem->selection_set) { - if (!calitem->move_selection_when_moving - || (calitem->selection_start_month_offset - months_diff >= 0 - && calitem->selection_end_month_offset - months_diff < num_months)) { - calitem->selection_start_month_offset -= months_diff; - calitem->selection_end_month_offset -= months_diff; - calitem->selection_real_start_month_offset -= months_diff; - - calitem->year = new_year; - calitem->month = new_month; - } else { - gint selected_day; - struct tm tmp_tm = { 0 }; - - old_days_in_selection = e_calendar_item_get_inclusive_days (calitem, calitem->selection_start_month_offset, calitem->selection_start_day, - calitem->selection_end_month_offset, calitem->selection_end_day); - - /* Calculate the currently selected day */ - tmp_tm.tm_year = calitem->year - 1900; - tmp_tm.tm_mon = calitem->month + calitem->selection_start_month_offset; - tmp_tm.tm_mday = calitem->selection_start_day; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - - selected_day = (tmp_tm.tm_wday + 6) % 7; - - /* Make sure the selection will be displayed. */ - if (calitem->selection_start_month_offset < 0 - || calitem->selection_start_month_offset >= num_months) { - calitem->selection_end_month_offset -= calitem->selection_start_month_offset; - calitem->selection_start_month_offset = 0; - } - - /* We want to ensure that the same number of days are - selected after we have moved the selection. */ - calitem->year = new_year; - calitem->month = new_month; - - e_calendar_item_ensure_valid_day (calitem, &calitem->selection_start_month_offset, &calitem->selection_start_day); - e_calendar_item_ensure_valid_day (calitem, &calitem->selection_end_month_offset, &calitem->selection_end_day); - - if (calitem->preserve_day_when_moving) { - e_calendar_item_preserve_day_selection (calitem, selected_day, &calitem->selection_start_month_offset, &calitem->selection_start_day); - } - - new_days_in_selection = e_calendar_item_get_inclusive_days (calitem, calitem->selection_start_month_offset, calitem->selection_start_day, calitem->selection_end_month_offset, calitem->selection_end_day); - - if (old_days_in_selection != new_days_in_selection) - e_calendar_item_add_days_to_selection (calitem, old_days_in_selection - new_days_in_selection); - - /* Flag that we need to emit the "selection_changed" - signal. We don't want to emit it here since setting - the "year" and "month" args would result in 2 - signals emitted. */ - calitem->selection_changed = TRUE; - } - } else { - calitem->year = new_year; - calitem->month = new_month; - } - - e_calendar_item_date_range_changed (calitem); - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); -} - -/* Get the maximum number of days selectable */ -gint -e_calendar_item_get_max_days_sel (ECalendarItem *calitem) -{ - return calitem->max_days_selected; -} - - -/* Set the maximum number of days selectable */ -void -e_calendar_item_set_max_days_sel (ECalendarItem *calitem, - gint days) -{ - calitem->max_days_selected = MAX (0, days); - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); -} - - -/* Get the maximum number of days before whole weeks are selected */ -gint -e_calendar_item_get_days_start_week_sel(ECalendarItem *calitem) -{ - return calitem->days_to_start_week_selection; -} - - -/* Set the maximum number of days before whole weeks are selected */ -void -e_calendar_item_set_days_start_week_sel(ECalendarItem *calitem, - gint days) -{ - calitem->days_to_start_week_selection = days; -} - -gboolean -e_calendar_item_get_display_popup (ECalendarItem *calitem) -{ - return calitem->display_popup; -} - - -void -e_calendar_item_set_display_popup (ECalendarItem *calitem, - gboolean display) -{ - calitem->display_popup = display; -} - - -/* This will make sure that the given year & month are valid, i.e. if month - is < 0 or > 11 the year and month will be updated accordingly. */ -void -e_calendar_item_normalize_date (ECalendarItem *calitem, - gint *year, - gint *month) -{ - if (*month >= 0) { - *year += *month / 12; - *month = *month % 12; - } else { - *year += *month / 12 - 1; - *month = *month % 12; - if (*month != 0) - *month += 12; - } -} - - -/* Adds or subtracts days from the selection. It is used when we switch months - and the selection extends past the end of a month but we want to keep the - number of days selected the same. days should not be more than 30. */ -static void -e_calendar_item_add_days_to_selection (ECalendarItem *calitem, - gint days) -{ - gint year, month, days_in_month; - - year = calitem->year; - month = calitem->month + calitem->selection_end_month_offset; - e_calendar_item_normalize_date (calitem, &year, &month); - - calitem->selection_end_day += days; - if (calitem->selection_end_day <= 0) { - month--; - e_calendar_item_normalize_date (calitem, &year, &month); - calitem->selection_end_month_offset--; - calitem->selection_end_day += DAYS_IN_MONTH (year, month); - } else { - days_in_month = DAYS_IN_MONTH (year, month); - if (calitem->selection_end_day > days_in_month) { - calitem->selection_end_month_offset++; - calitem->selection_end_day -= days_in_month; - } - } -} - - -/* Gets the range of dates actually shown. Months are 0 to 11. - This also includes the last days of the previous month and the first days - of the following month, which are normally shown in gray. - It returns FALSE if no dates are currently shown. */ -gboolean -e_calendar_item_get_date_range (ECalendarItem *calitem, - gint *start_year, - gint *start_month, - gint *start_day, - gint *end_year, - gint *end_month, - gint *end_day) -{ - gint first_day_offset, days_in_month, days_in_prev_month; - - if (calitem->rows == 0 || calitem->cols == 0) - return FALSE; - - /* Calculate the first day shown. This will be one of the greyed-out - days before the first full month begins. */ - e_calendar_item_get_month_info (calitem, 0, 0, &first_day_offset, - &days_in_month, &days_in_prev_month); - *start_year = calitem->year; - *start_month = calitem->month - 1; - if (*start_month == -1) { - (*start_year)--; - *start_month = 11; - } - *start_day = days_in_prev_month + 1 - first_day_offset; - - - /* Calculate the last day shown. This will be one of the greyed-out - days after the last full month ends. */ - e_calendar_item_get_month_info (calitem, calitem->rows - 1, - calitem->cols - 1, &first_day_offset, - &days_in_month, &days_in_prev_month); - *end_month = calitem->month + calitem->rows * calitem->cols; - *end_year = calitem->year + *end_month / 12; - *end_month %= 12; - *end_day = E_CALENDAR_ROWS_PER_MONTH * E_CALENDAR_COLS_PER_MONTH - - first_day_offset - days_in_month; - - return TRUE; -} - - -/* Simple way to mark days so they appear bold. - A more flexible interface may be added later. */ -void -e_calendar_item_clear_marks (ECalendarItem *calitem) -{ - GnomeCanvasItem *item; - - item = GNOME_CANVAS_ITEM (calitem); - - g_free (calitem->styles); - calitem->styles = NULL; - - gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, - item->x2, item->y2); -} - - -void -e_calendar_item_mark_day (ECalendarItem *calitem, - gint year, - gint month, - gint day, - guint8 day_style) -{ - gint month_offset; - - month_offset = (year - calitem->year) * 12 + month - calitem->month; - if (month_offset < -1 || month_offset > calitem->rows * calitem->cols) - return; - - if (!calitem->styles) - calitem->styles = g_new0 (guint8, (calitem->rows * calitem->cols + 2) * 32); - - calitem->styles[(month_offset + 1) * 32 + day] = day_style; - - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); -} - - -void -e_calendar_item_mark_days (ECalendarItem *calitem, - gint start_year, - gint start_month, - gint start_day, - gint end_year, - gint end_month, - gint end_day, - guint8 day_style) -{ - gint month_offset, end_month_offset, day; - - month_offset = (start_year - calitem->year) * 12 + start_month - - calitem->month; - day = start_day; - if (month_offset > calitem->rows * calitem->cols) - return; - if (month_offset < -1) { - month_offset = -1; - day = 1; - } - - end_month_offset = (end_year - calitem->year) * 12 + end_month - - calitem->month; - if (end_month_offset < -1) - return; - if (end_month_offset > calitem->rows * calitem->cols) { - end_month_offset = calitem->rows * calitem->cols; - end_day = 31; - } - - if (month_offset > end_month_offset) - return; - - if (!calitem->styles) - calitem->styles = g_new0 (guint8, (calitem->rows * calitem->cols + 2) * 32); - - for (;;) { - if (month_offset == end_month_offset && day > end_day) - break; - - if (month_offset < -1 || month_offset > calitem->rows * calitem->cols) - g_warning ("Bad month offset: %i\n", month_offset); - if (day < 1 || day > 31) - g_warning ("Bad day: %i\n", day); - -#if 0 - g_print ("Marking Month:%i Day:%i\n", month_offset, day); -#endif - calitem->styles[(month_offset + 1) * 32 + day] = day_style; - - day++; - if (day == 32) { - month_offset++; - day = 1; - if (month_offset > end_month_offset) - break; - } - } - - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); -} - - -/* Rounds up the given day to the end of the week. */ -static void -e_calendar_item_round_up_selection (ECalendarItem *calitem, - gint *month_offset, - gint *day) -{ - gint year, month, weekday, days, days_in_month; - struct tm tmp_tm = { 0 }; - - year = calitem->year; - month = calitem->month + *month_offset; - e_calendar_item_normalize_date (calitem, &year, &month); - - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = *day; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - - /* Convert to 0 (Monday) to 6 (Sunday). */ - weekday = (tmp_tm.tm_wday + 6) % 7; - - /* Calculate how many days to the end of the row. */ - days = (calitem->week_start_day + 6 - weekday) % 7; - - *day += days; - days_in_month = DAYS_IN_MONTH (year, month); - if (*day > days_in_month) { - (*month_offset)++; - *day -= days_in_month; - } -} - - -/* Rounds down the given day to the start of the week. */ -static void -e_calendar_item_round_down_selection (ECalendarItem *calitem, - gint *month_offset, - gint *day) -{ - gint year, month, weekday, days, days_in_month; - struct tm tmp_tm = { 0 }; - - year = calitem->year; - month = calitem->month + *month_offset; - e_calendar_item_normalize_date (calitem, &year, &month); - - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = *day; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - - /* Convert to 0 (Monday) to 6 (Sunday). */ - weekday = (tmp_tm.tm_wday + 6) % 7; - - /* Calculate how many days to the start of the row. */ - days = (weekday + 7 - calitem->week_start_day) % 7; - - *day -= days; - if (*day <= 0) { - month--; - if (month == -1) { - year--; - month = 11; - } - days_in_month = DAYS_IN_MONTH (year, month); - (*month_offset)--; - *day += days_in_month; - } -} - - -static gint -e_calendar_item_get_inclusive_days (ECalendarItem *calitem, - gint start_month_offset, - gint start_day, - gint end_month_offset, - gint end_day) -{ - gint start_year, start_month, end_year, end_month, days = 0; - - start_year = calitem->year; - start_month = calitem->month + start_month_offset; - e_calendar_item_normalize_date (calitem, &start_year, &start_month); - - end_year = calitem->year; - end_month = calitem->month + end_month_offset; - e_calendar_item_normalize_date (calitem, &end_year, &end_month); - - while (start_year < end_year || start_month < end_month) { - days += DAYS_IN_MONTH (start_year, start_month); - start_month++; - if (start_month == 12) { - start_year++; - start_month = 0; - } - } - - days += end_day - start_day + 1; - - return days; -} - - -/* If the day is off the end of the month it is set to the last day of the - month. */ -static void -e_calendar_item_ensure_valid_day (ECalendarItem *calitem, - gint *month_offset, - gint *day) -{ - gint year, month, days_in_month; - - year = calitem->year; - month = calitem->month + *month_offset; - e_calendar_item_normalize_date (calitem, &year, &month); - - days_in_month = DAYS_IN_MONTH (year, month); - if (*day > days_in_month) - *day = days_in_month; -} - - -gboolean -e_calendar_item_get_selection (ECalendarItem *calitem, - GDate *start_date, - GDate *end_date) -{ - gint start_year, start_month, start_day; - gint end_year, end_month, end_day; - - g_date_clear (start_date, 1); - g_date_clear (end_date, 1); - - if (!calitem->selection_set) - return FALSE; - - start_year = calitem->year; - start_month = calitem->month + calitem->selection_start_month_offset; - e_calendar_item_normalize_date (calitem, &start_year, &start_month); - start_day = calitem->selection_start_day; - - end_year = calitem->year; - end_month = calitem->month + calitem->selection_end_month_offset; - e_calendar_item_normalize_date (calitem, &end_year, &end_month); - end_day = calitem->selection_end_day; - - g_date_set_dmy (start_date, start_day, start_month + 1, start_year); - g_date_set_dmy (end_date, end_day, end_month + 1, end_year); - - return TRUE; -} - - -static void -e_calendar_item_set_selection_if_emission (ECalendarItem *calitem, - GDate *start_date, - GDate *end_date, - gboolean emission) -{ - gint start_year, start_month, start_day; - gint end_year, end_month, end_day; - gint new_start_month_offset, new_start_day; - gint new_end_month_offset, new_end_day; - gboolean need_update; - - g_return_if_fail (E_IS_CALENDAR_ITEM (calitem)); - - /* If start_date is NULL, we clear the selection without changing the - month shown. */ - if (start_date == NULL) { - calitem->selection_set = FALSE; - calitem->selection_changed = TRUE; - e_calendar_item_queue_signal_emission (calitem); - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); - return; - } - - if (end_date == NULL) - end_date = start_date; - - g_return_if_fail (g_date_compare (start_date, end_date) <= 0); - - start_year = g_date_get_year (start_date); - start_month = g_date_get_month (start_date) - 1; - start_day = g_date_get_day (start_date); - end_year = g_date_get_year (end_date); - end_month = g_date_get_month (end_date) - 1; - end_day = g_date_get_day (end_date); - - need_update = e_calendar_item_ensure_days_visible (calitem, - start_year, - start_month, - start_day, - end_year, - end_month, - end_day, - emission); - - new_start_month_offset = (start_year - calitem->year) * 12 - + start_month - calitem->month; - new_start_day = start_day; - - /* This may go outside the visible months, but we don't care. */ - new_end_month_offset = (end_year - calitem->year) * 12 - + end_month - calitem->month; - new_end_day = end_day; - - - if (!calitem->selection_set - || calitem->selection_start_month_offset != new_start_month_offset - || calitem->selection_start_day != new_start_day - || calitem->selection_end_month_offset != new_end_month_offset - || calitem->selection_end_day != new_end_day) { - need_update = TRUE; - if (emission) { - calitem->selection_changed = TRUE; - e_calendar_item_queue_signal_emission (calitem); - } - calitem->selection_set = TRUE; - calitem->selection_start_month_offset = new_start_month_offset; - calitem->selection_start_day = new_start_day; - calitem->selection_end_month_offset = new_end_month_offset; - calitem->selection_end_day = new_end_day; - - calitem->selection_real_start_month_offset = new_start_month_offset; - calitem->selection_real_start_day = new_start_day; - calitem->selection_from_full_week = FALSE; - } - - if (need_update) - gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (calitem)); -} - -void -e_calendar_item_set_selection (ECalendarItem *calitem, - GDate *start_date, - GDate *end_date) -{ - /* If the user is in the middle of a selection, we must abort it. */ - if (calitem->selecting) { - gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM (calitem), - GDK_CURRENT_TIME); - calitem->selecting = FALSE; - } - - e_calendar_item_set_selection_if_emission (calitem, - start_date, end_date, - TRUE); -} - -/* This tries to ensure that the given time range is visible. If the range - given is longer than we can show, only the start of it will be visible. - Note that this will not update the selection. That should be done somewhere - else. It returns TRUE if the visible range has been changed. */ -static gboolean -e_calendar_item_ensure_days_visible (ECalendarItem *calitem, - gint start_year, - gint start_month, - gint start_day, - gint end_year, - gint end_month, - gint end_day, - gboolean emission) -{ - gint current_end_year, current_end_month; - gint months_shown, months; - gint first_day_offset, days_in_month, days_in_prev_month; - gboolean need_update = FALSE; - - months_shown = calitem->rows * calitem->cols; - months = (end_year - start_year) * 12 + end_month - start_month; - - /* Calculate the range of months currently displayed. */ - current_end_year = calitem->year; - current_end_month = calitem->month + months_shown - 1; - e_calendar_item_normalize_date (calitem, ¤t_end_year, - ¤t_end_month); - - /* Try to ensure that the end month is shown. */ - if ((end_year == current_end_year + 1 && current_end_month == 11 && end_month == 0) || - (end_year == current_end_year && end_month == current_end_month + 1)) { - /* See if the end of the selection will fit in the - leftover days of the month after the last one shown. */ - calitem->month += (months_shown - 1); - e_calendar_item_normalize_date (calitem, &calitem->year, - &calitem->month); - - e_calendar_item_get_month_info (calitem, 0, 0, - &first_day_offset, - &days_in_month, - &days_in_prev_month); - - if (end_day >= E_CALENDAR_ROWS_PER_MONTH * E_CALENDAR_COLS_PER_MONTH - - first_day_offset - days_in_month) { - need_update = TRUE; - - calitem->year = end_year; - calitem->month = end_month - months_shown + 1; - } else { - calitem->month -= (months_shown - 1); - } - - e_calendar_item_normalize_date (calitem, &calitem->year, - &calitem->month); - } - else if (end_year > current_end_year || - (end_year == current_end_year && end_month > current_end_month)) { - /* The selection will definitely not fit in the leftover days - * of the month after the last one shown. */ - need_update = TRUE; - - calitem->year = end_year; - calitem->month = end_month - months_shown + 1; - - e_calendar_item_normalize_date (calitem, &calitem->year, - &calitem->month); - } - - /* Now try to ensure that the start month is shown. We do this after - the end month so that the start month will always be shown. */ - if (start_year < calitem->year - || (start_year == calitem->year - && start_month < calitem->month)) { - need_update = TRUE; - - /* First we see if the start of the selection will fit in the - leftover days of the month before the first one shown. */ - calitem->year = start_year; - calitem->month = start_month + 1; - e_calendar_item_normalize_date (calitem, &calitem->year, - &calitem->month); - - e_calendar_item_get_month_info (calitem, 0, 0, - &first_day_offset, - &days_in_month, - &days_in_prev_month); - - if (start_day <= days_in_prev_month - first_day_offset) { - calitem->year = start_year; - calitem->month = start_month; - } - } - - if (need_update && emission) - e_calendar_item_date_range_changed (calitem); - - return need_update; -} - - -static void -e_calendar_item_show_popup_menu (ECalendarItem *calitem, - GdkEventButton *event, - gint month_offset) -{ - GtkWidget *menu, *submenu, *menuitem, *label; - gint year, month; - gchar buffer[64]; - struct tm tmp_tm; - - menu = gtk_menu_new (); - - for (year = calitem->year - 2; year <= calitem->year + 2; year++) { - g_snprintf (buffer, 64, "%i", year); - menuitem = gtk_menu_item_new_with_label (buffer); - gtk_widget_show (menuitem); - gtk_container_add (GTK_CONTAINER (menu), menuitem); - - submenu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu); - - g_object_set_data(G_OBJECT(submenu), "year", - GINT_TO_POINTER (year)); - g_object_set_data(G_OBJECT(submenu), "month_offset", - GINT_TO_POINTER (month_offset)); - - for (month = 0; month < 12; month++) { - memset (&tmp_tm, 0, sizeof (tmp_tm)); - tmp_tm.tm_year = year - 1900; - tmp_tm.tm_mon = month; - tmp_tm.tm_mday = 1; - tmp_tm.tm_isdst = -1; - mktime (&tmp_tm); - e_utf8_strftime (buffer, sizeof (buffer), "%B", &tmp_tm); - - menuitem = gtk_menu_item_new (); - gtk_widget_show (menuitem); - gtk_container_add (GTK_CONTAINER (submenu), menuitem); - - label = gtk_label_new (buffer); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_container_add (GTK_CONTAINER (menuitem), label); - - g_object_set_data(G_OBJECT(menuitem), "month", - GINT_TO_POINTER (month)); - - g_signal_connect((menuitem), "activate", - G_CALLBACK (e_calendar_item_on_menu_item_activate), calitem); - } - } - - /* Run the menu modal so we can destroy it after. */ - g_signal_connect((menu), "deactivate", - G_CALLBACK (gtk_main_quit), NULL); - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, - e_calendar_item_position_menu, calitem, - event->button, event->time); - gtk_grab_add (menu); - gtk_main (); - gtk_grab_remove (menu); - gtk_widget_destroy (menu); -} - - -static void -e_calendar_item_on_menu_item_activate (GtkWidget *menuitem, - ECalendarItem *calitem) -{ - gint year, month_offset, month; - - year = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(menuitem->parent), "year")); - month_offset = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(menuitem->parent), "month_offset")); - month = GPOINTER_TO_INT (g_object_get_data(G_OBJECT(menuitem), "month")); - - month -= month_offset; - e_calendar_item_normalize_date (calitem, &year, &month); - e_calendar_item_set_first_month (calitem, year, month); -} - - -static void -e_calendar_item_position_menu (GtkMenu *menu, - gint *x, - gint *y, - gboolean *push_in, - gpointer user_data) -{ - GtkRequisition requisition; - gint screen_width, screen_height; - - gtk_widget_get_child_requisition (GTK_WIDGET (menu), &requisition); - - *x -= 2; - *y -= requisition.height / 2; - - screen_width = gdk_screen_width (); - screen_height = gdk_screen_height (); - - *x = CLAMP (*x, 0, screen_width - requisition.width); - *y = CLAMP (*y, 0, screen_height - requisition.height); -} - - -/* Sets the function to call to get the colors to use for a particular day. */ -void -e_calendar_item_set_style_callback (ECalendarItem *calitem, - ECalendarItemStyleCallback cb, - gpointer data, - GtkDestroyNotify destroy) -{ - g_return_if_fail (E_IS_CALENDAR_ITEM (calitem)); - - if (calitem->style_callback_data && calitem->style_callback_destroy) - (*calitem->style_callback_destroy) (calitem->style_callback_data); - - calitem->style_callback = cb; - calitem->style_callback_data = data; - calitem->style_callback_destroy = destroy; -} - - -static void -e_calendar_item_date_range_changed (ECalendarItem *calitem) -{ - g_free (calitem->styles); - calitem->styles = NULL; - calitem->date_range_changed = TRUE; - e_calendar_item_queue_signal_emission (calitem); -} - - -static void -e_calendar_item_queue_signal_emission (ECalendarItem *calitem) -{ - if (calitem->signal_emission_idle_id == 0) { - calitem->signal_emission_idle_id = g_idle_add_full (G_PRIORITY_HIGH, e_calendar_item_signal_emission_idle_cb, calitem, NULL); - } -} - - -static gboolean -e_calendar_item_signal_emission_idle_cb (gpointer data) -{ - ECalendarItem *calitem; - - g_return_val_if_fail (E_IS_CALENDAR_ITEM (data), FALSE); - - GDK_THREADS_ENTER (); - - calitem = E_CALENDAR_ITEM (data); - - calitem->signal_emission_idle_id = 0; - - /* We ref the calitem & check in case it gets destroyed, since we - were getting a free memory write here. */ - g_object_ref((calitem)); - - if (calitem->date_range_changed) { - calitem->date_range_changed = FALSE; - gtk_signal_emit (GTK_OBJECT (calitem), - e_calendar_item_signals[DATE_RANGE_CHANGED]); - } - - if (calitem->selection_changed) { - calitem->selection_changed = FALSE; - gtk_signal_emit (GTK_OBJECT (calitem), - e_calendar_item_signals[SELECTION_CHANGED]); - } - - g_object_unref((calitem)); - - GDK_THREADS_LEAVE (); - return FALSE; -} - - -/* Sets a callback to use to get the current time. This is useful if the - application needs to use its own timezone data rather than rely on the - Unix timezone. */ -void -e_calendar_item_set_get_time_callback (ECalendarItem *calitem, - ECalendarItemGetTimeCallback cb, - gpointer data, - GtkDestroyNotify destroy) -{ - g_return_if_fail (E_IS_CALENDAR_ITEM (calitem)); - - if (calitem->time_callback_data && calitem->time_callback_destroy) - (*calitem->time_callback_destroy) (calitem->time_callback_data); - - calitem->time_callback = cb; - calitem->time_callback_data = data; - calitem->time_callback_destroy = destroy; -} diff --git a/widgets/misc/e-calendar-item.h b/widgets/misc/e-calendar-item.h deleted file mode 100644 index d67d71d5cc..0000000000 --- a/widgets/misc/e-calendar-item.h +++ /dev/null @@ -1,379 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ -#ifndef _E_CALENDAR_ITEM_H_ -#define _E_CALENDAR_ITEM_H_ - -#include <libgnomecanvas/gnome-canvas.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * ECalendarItem - canvas item displaying a calendar. - */ - -#define E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME 1 -#define E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME 1 - -/* The number of rows & columns of days in each month. */ -#define E_CALENDAR_ROWS_PER_MONTH 6 -#define E_CALENDAR_COLS_PER_MONTH 7 - -/* Used to mark days as bold in e_calendar_item_mark_day(). */ -#define E_CALENDAR_ITEM_MARK_BOLD 1 - -/* - * These are the padding sizes between various pieces of the calendar. - */ - -/* The minimum padding around the numbers in each cell/day. */ -#define E_CALENDAR_ITEM_MIN_CELL_XPAD 4 -#define E_CALENDAR_ITEM_MIN_CELL_YPAD 0 - -/* Vertical padding. */ -#define E_CALENDAR_ITEM_YPAD_ABOVE_DAY_LETTERS 1 -#define E_CALENDAR_ITEM_YPAD_BELOW_DAY_LETTERS 0 -#define E_CALENDAR_ITEM_YPAD_ABOVE_CELLS 1 -#define E_CALENDAR_ITEM_YPAD_BELOW_CELLS 2 - -/* Horizontal padding in the heading bars. */ -#define E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME_WITH_BUTTON 16 -#define E_CALENDAR_ITEM_XPAD_BEFORE_MONTH_NAME 3 -#define E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME 3 -#define E_CALENDAR_ITEM_XPAD_AFTER_MONTH_NAME_WITH_BUTTON 16 - -/* Horizontal padding in the month displays. */ -#define E_CALENDAR_ITEM_XPAD_BEFORE_WEEK_NUMBERS 4 -#define E_CALENDAR_ITEM_XPAD_AFTER_WEEK_NUMBERS 2 -#define E_CALENDAR_ITEM_XPAD_BEFORE_CELLS 1 -#define E_CALENDAR_ITEM_XPAD_AFTER_CELLS 4 - - -/* These index our colors array. */ -typedef enum -{ - E_CALENDAR_ITEM_COLOR_TODAY_BOX, - E_CALENDAR_ITEM_COLOR_SELECTION_FG, - E_CALENDAR_ITEM_COLOR_SELECTION_BG_FOCUSED, - E_CALENDAR_ITEM_COLOR_SELECTION_BG, - E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG, - - E_CALENDAR_ITEM_COLOR_LAST -} ECalendarItemColors; - -typedef struct _ECalendarItem ECalendarItem; -typedef struct _ECalendarItemClass ECalendarItemClass; - -/* The type of the callback function optionally used to get the colors to - use for each day. */ -typedef void (*ECalendarItemStyleCallback) (ECalendarItem *calitem, - gint year, - gint month, - gint day, - gint day_style, - gboolean today, - gboolean prev_or_next_month, - gboolean selected, - gboolean has_focus, - gboolean drop_target, - GdkColor **bg_color, - GdkColor **fg_color, - GdkColor **box_color, - gboolean *bold, - gpointer data); - -/* The type of the callback function optionally used to get the current time. - */ -typedef struct tm (*ECalendarItemGetTimeCallback) (ECalendarItem *calitem, - gpointer data); - - -#define E_CALENDAR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - e_calendar_item_get_type (), ECalendarItem)) -#define E_CALENDAR_ITEM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),\ - e_calendar_item_get_type ())) -#define E_IS_CALENDAR_ITEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \ - e_calendar_item_get_type ())) - -struct _ECalendarItem -{ - GnomeCanvasItem canvas_item; - - /* The year & month of the first calendar being displayed. */ - gint year; - gint month; /* 0 to 11 */ - - /* Points to an array of styles, one char for each day. We use 32 - chars for each month, with n + 2 months, where n is the number of - complete months shown (since we show some days before the first - month and after the last month grayes out). - A value of 0 is the default, and 1 is bold. */ - guint8 *styles; - - /* - * Options. - */ - - /* The minimum & maximum number of rows & columns of months. - If the maximum values are -1 then there is no maximum. - The minimum valies default to 1. The maximum values to -1. */ - gint min_rows; - gint min_cols; - gint max_rows; - gint max_cols; - - /* The actual number of rows & columns of months. */ - gint rows; - gint cols; - - /* Whether we show week nubers. */ - gboolean show_week_numbers; - - /* The first day of the week, 0 (Monday) to 6 (Sunday). */ - gint week_start_day; - - /* Whether the cells expand to fill extra space. */ - gboolean expand; - - /* The maximum number of days that can be selected. Defaults to 1. */ - gint max_days_selected; - - /* The number of days selected before we switch to selecting whole - weeks, or -1 if we never switch. Defaults to -1. */ - gint days_to_start_week_selection; - - /* Whether the selection is moved when we move back/forward one month. - Used for things like the EDateEdit which only want the selection to - be changed when the user explicitly selects a day. */ - gboolean move_selection_when_moving; - - /* Whether the selection day is preserved when we move back/forward - one month. Used for the work week and week view. */ - gboolean preserve_day_when_moving; - - /* Whether to display the pop-up, TRUE by default */ - gboolean display_popup; - - /* - * Internal stuff. - */ - - /* Bounds of item. */ - gdouble x1, y1, x2, y2; - - /* The minimum size of each month, based on the fonts used. */ - gint min_month_width; - gint min_month_height; - - /* The actual size of each month, after dividing extra space. */ - gint month_width; - gint month_height; - - /* The offset to the left edge of the first calendar. */ - gint x_offset; - - /* The padding around each calendar month. */ - gint month_lpad, month_rpad; - gint month_tpad, month_bpad; - - /* The size of each cell. */ - gint cell_width; - gint cell_height; - - /* The current selection. The month offsets are from 0, which is the - top-left calendar month view. Note that -1 is used for the last days - from the previous month. The days are real month days. */ - gboolean selecting; - GDate *selecting_axis; - gboolean selection_dragging_end; - gboolean selection_from_full_week; - gboolean selection_set; - gint selection_start_month_offset; - gint selection_start_day; - gint selection_end_month_offset; - gint selection_end_day; - gint selection_real_start_month_offset; - gint selection_real_start_day; - - /* The first character of each day of the week, e.g. 'MTWTFSS'. */ - gchar *days; - - /* Widths of the day characters. */ - gint day_widths[7]; - - /* Widths of the digits, '0' .. '9'. */ - gint digit_widths[10]; - gint max_digit_width; - gint week_number_digit_widths[10]; - gint max_week_number_digit_width; - - /* Fonts for drawing text. If font isn't set it uses the font from the - canvas widget. If week_number_font isn't set it uses font. */ - PangoFontDescription *font_desc; - PangoFontDescription *week_number_font_desc; - - ECalendarItemStyleCallback style_callback; - gpointer style_callback_data; - GtkDestroyNotify style_callback_destroy; - - ECalendarItemGetTimeCallback time_callback; - gpointer time_callback_data; - GtkDestroyNotify time_callback_destroy; - - /* Colors for drawing. */ - GdkColor colors[E_CALENDAR_ITEM_COLOR_LAST]; - - /* Our idle handler for emitting signals. */ - gint signal_emission_idle_id; - - /* A flag to indicate that the selection or date range has changed. - When set the idle function will emit the signal and reset it to - FALSE. This is so we don't emit it several times when args are set - etc. */ - gboolean selection_changed; - gboolean date_range_changed; -}; - -struct _ECalendarItemClass -{ - GnomeCanvasItemClass parent_class; - - void (* date_range_changed) (ECalendarItem *calitem); - void (* selection_changed) (ECalendarItem *calitem); - void (* selection_preview_changed) (ECalendarItem *calitem); -}; - - -GtkType e_calendar_item_get_type (void); - -/* FIXME: months are 0-11 throughout, but 1-12 may be better. */ - -void e_calendar_item_get_first_month (ECalendarItem *calitem, - gint *year, - gint *month); -void e_calendar_item_set_first_month (ECalendarItem *calitem, - gint year, - gint month); - -/* Get the maximum number of days selectable */ -gint e_calendar_item_get_max_days_sel (ECalendarItem *calitem); - -/* Set the maximum number of days selectable */ -void e_calendar_item_set_max_days_sel (ECalendarItem *calitem, - gint days); - -/* Get the maximum number of days selectable */ -gint e_calendar_item_get_days_start_week_sel(ECalendarItem *calitem); - -/* Get the maximum number of days before whole weeks are selected */ -void e_calendar_item_set_days_start_week_sel(ECalendarItem *calitem, - gint days); - -/* Set the maximum number of days before whole weeks are selected */ -gboolean e_calendar_item_get_display_popup (ECalendarItem *calitem); - -/* Get the maximum number of days before whole weeks are selected */ -void e_calendar_item_set_display_popup (ECalendarItem *calitem, - gboolean display); - -/* Set the maximum number of days before whole weeks are selected */ -gint e_calendar_item_get_days_start_week_sel(ECalendarItem *calitem); - -/* Set the maximum number of days selectable */ -void e_calendar_item_set_days_start_week_sel(ECalendarItem *calitem, - gint days); - -/* Gets the range of dates actually shown. Months are 0 to 11. - This also includes the last days of the previous month and the first days - of the following month, which are normally shown in gray. - It returns FALSE if no dates are currently shown. */ -gboolean e_calendar_item_get_date_range (ECalendarItem *calitem, - gint *start_year, - gint *start_month, - gint *start_day, - gint *end_year, - gint *end_month, - gint *end_day); - -/* Returns the selected date range. It returns FALSE if no days are currently - selected. */ -gboolean e_calendar_item_get_selection (ECalendarItem *calitem, - GDate *start_date, - GDate *end_date); -/* Sets the selected date range, and changes the date range shown so at least - the start of the selection is shown. If start_date is NULL it clears the - selection. */ -void e_calendar_item_set_selection (ECalendarItem *calitem, - GDate *start_date, - GDate *end_date); - -/* Marks a particular day. Passing E_CALENDAR_ITEM_MARK_BOLD as the day style - will result in the day being shown as bold by default. The style callback - could support more day_styles, or the style callback could determine the - colors itself, without needing to mark days. */ -void e_calendar_item_clear_marks (ECalendarItem *calitem); -void e_calendar_item_mark_day (ECalendarItem *calitem, - gint year, - gint month, - gint day, - guint8 day_style); - -/* Mark a range of days. Any days outside the currently shown range are - ignored. */ -void e_calendar_item_mark_days (ECalendarItem *calitem, - gint start_year, - gint start_month, - gint start_day, - gint end_year, - gint end_month, - gint end_day, - guint8 day_style); - -/* Sets the function to call to get the colors to use for a particular day. */ -void e_calendar_item_set_style_callback (ECalendarItem *calitem, - ECalendarItemStyleCallback cb, - gpointer data, - GtkDestroyNotify destroy); - -/* Sets a callback to use to get the current time. This is useful if the - application needs to use its own timezone data rather than rely on the - Unix timezone. */ -void e_calendar_item_set_get_time_callback (ECalendarItem *calitem, - ECalendarItemGetTimeCallback cb, - gpointer data, - GtkDestroyNotify destroy); -void e_calendar_item_normalize_date (ECalendarItem *calitem, - gint *year, - gint *month); -gint e_calendar_item_get_week_number (ECalendarItem *calitem, - gint day, - gint month, - gint year); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CALENDAR_ITEM_H_ */ diff --git a/widgets/misc/e-calendar.c b/widgets/misc/e-calendar.c deleted file mode 100644 index 402e390df0..0000000000 --- a/widgets/misc/e-calendar.c +++ /dev/null @@ -1,661 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * Bolian Yin <bolian.yin@sun.com> - * - * Copyright 2000, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * ECalendar - displays a table of monthly calendars, allowing highlighting - * and selection of one or more days. Like GtkCalendar with more features. - * Most of the functionality is in the ECalendarItem canvas item, though - * we also add GnomeCanvasWidget buttons to go to the previous/next month and - * to got to the current day. - */ - -#include <config.h> - -#include "e-calendar.h" - -#include <glib.h> -#include <gtk/gtkarrow.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkpixmap.h> -#include <gtk/gtksignal.h> -#include <libgnomecanvas/gnome-canvas-widget.h> -#include <gal/util/e-util.h> - -#define E_CALENDAR_SMALL_FONT_PTSIZE 6 - -#define E_CALENDAR_SMALL_FONT \ - "-adobe-utopia-regular-r-normal-*-*-100-*-*-p-*-iso8859-*" -#define E_CALENDAR_SMALL_FONT_FALLBACK \ - "-adobe-helvetica-medium-r-normal-*-*-80-*-*-p-*-iso8859-*" - -/* The space between the arrow buttons and the edge of the widget. */ -#define E_CALENDAR_ARROW_BUTTON_X_PAD 2 -#define E_CALENDAR_ARROW_BUTTON_Y_PAD 0 - -/* Vertical padding. The padding above the button includes the space for the - horizontal line. */ -#define E_CALENDAR_YPAD_ABOVE_LOWER_BUTTONS 4 -#define E_CALENDAR_YPAD_BELOW_LOWER_BUTTONS 3 - -/* Horizontal padding inside & between buttons. */ -#define E_CALENDAR_IXPAD_BUTTONS 4 -#define E_CALENDAR_XPAD_BUTTONS 8 - -/* The time between steps when the prev/next buttons is pressed, in 1/1000ths - of a second, and the number of timeouts we skip before we start - automatically moving back/forward. */ -#define E_CALENDAR_AUTO_MOVE_TIMEOUT 150 -#define E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY 2 - -static void e_calendar_class_init (ECalendarClass *class); -static void e_calendar_init (ECalendar *cal); -static void e_calendar_destroy (GtkObject *object); -static void e_calendar_realize (GtkWidget *widget); -static void e_calendar_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static void e_calendar_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void e_calendar_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gint e_calendar_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time); -static void e_calendar_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time); -static gboolean e_calendar_button_has_focus (ECalendar *cal); -static gboolean e_calendar_focus (GtkWidget *widget, - GtkDirectionType direction); - -static void e_calendar_on_prev_pressed (ECalendar *cal); -static void e_calendar_on_prev_released (ECalendar *cal); -static void e_calendar_on_prev_clicked (ECalendar *cal); -static void e_calendar_on_next_pressed (ECalendar *cal); -static void e_calendar_on_next_released (ECalendar *cal); -static void e_calendar_on_next_clicked (ECalendar *cal); - -static void e_calendar_start_auto_move (ECalendar *cal, - gboolean moving_forward); -static gboolean e_calendar_auto_move_handler (gpointer data); -static void e_calendar_stop_auto_move (ECalendar *cal); - -static GnomeCanvasClass *parent_class; -static GtkLayoutClass *grandparent_class; - -E_MAKE_TYPE (e_calendar, "ECalendar", ECalendar, - e_calendar_class_init, e_calendar_init, E_CANVAS_TYPE) - - -static void -e_calendar_class_init (ECalendarClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = g_type_class_ref(E_CANVAS_TYPE); - grandparent_class = g_type_class_ref(GTK_TYPE_LAYOUT); - - object_class->destroy = e_calendar_destroy; - - widget_class->realize = e_calendar_realize; - widget_class->style_set = e_calendar_style_set; - widget_class->size_request = e_calendar_size_request; - widget_class->size_allocate = e_calendar_size_allocate; - widget_class->drag_motion = e_calendar_drag_motion; - widget_class->drag_leave = e_calendar_drag_leave; - widget_class->focus = e_calendar_focus; -} - - -static void -e_calendar_init (ECalendar *cal) -{ - GnomeCanvasGroup *canvas_group; - PangoFontDescription *small_font_desc; - GtkWidget *button, *pixmap; - - /* Create the small font. */ - - small_font_desc = - pango_font_description_copy (gtk_widget_get_style (GTK_WIDGET (cal))->font_desc); - pango_font_description_set_size (small_font_desc, - E_CALENDAR_SMALL_FONT_PTSIZE * PANGO_SCALE); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (cal)->root); - - cal->calitem = E_CALENDAR_ITEM (gnome_canvas_item_new (canvas_group, - e_calendar_item_get_type (), - "week_number_font_desc", small_font_desc, - NULL)); - - pango_font_description_free (small_font_desc); - - /* Create the arrow buttons to move to the previous/next month. */ - button = gtk_button_new (); - gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); - gtk_widget_show (button); - gtk_signal_connect_object (GTK_OBJECT (button), "pressed", - G_CALLBACK (e_calendar_on_prev_pressed), - GTK_OBJECT (cal)); - gtk_signal_connect_object (GTK_OBJECT (button), "released", - G_CALLBACK (e_calendar_on_prev_released), - GTK_OBJECT (cal)); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", - G_CALLBACK (e_calendar_on_prev_clicked), - GTK_OBJECT (cal)); - - pixmap = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE); - gtk_widget_show (pixmap); - gtk_container_add (GTK_CONTAINER (button), pixmap); - - cal->prev_item = gnome_canvas_item_new (canvas_group, - gnome_canvas_widget_get_type (), - "widget", button, - NULL); - - button = gtk_button_new (); - gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); - gtk_widget_show (button); - gtk_signal_connect_object (GTK_OBJECT (button), "pressed", - G_CALLBACK (e_calendar_on_next_pressed), - GTK_OBJECT (cal)); - gtk_signal_connect_object (GTK_OBJECT (button), "released", - G_CALLBACK (e_calendar_on_next_released), - GTK_OBJECT (cal)); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", - G_CALLBACK (e_calendar_on_next_clicked), - GTK_OBJECT (cal)); - - pixmap = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE); - gtk_widget_show (pixmap); - gtk_container_add (GTK_CONTAINER (button), pixmap); - - cal->next_item = gnome_canvas_item_new (canvas_group, - gnome_canvas_widget_get_type (), - "widget", button, - NULL); - - cal->min_rows = 1; - cal->min_cols = 1; - cal->max_rows = -1; - cal->max_cols = -1; - - cal->timeout_id = 0; -} - - -/** - * e_calendar_new: - * @Returns: a new #ECalendar. - * - * Creates a new #ECalendar. - **/ -GtkWidget * -e_calendar_new (void) -{ - GtkWidget *cal; - - cal = gtk_type_new (e_calendar_get_type ()); - - return cal; -} - - -static void -e_calendar_destroy (GtkObject *object) -{ - ECalendar *cal; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_CALENDAR (object)); - - cal = E_CALENDAR (object); - - if (cal->timeout_id != 0) { - gtk_timeout_remove (cal->timeout_id); - cal->timeout_id = 0; - } - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -e_calendar_realize (GtkWidget *widget) -{ - (*GTK_WIDGET_CLASS (parent_class)->realize) (widget); - - /* Set the background of the canvas window to the normal color, - or the arrow buttons are not displayed properly. */ - gdk_window_set_background (GTK_LAYOUT (widget)->bin_window, - &widget->style->bg[GTK_STATE_NORMAL]); -} - - -static void -e_calendar_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - if (GTK_WIDGET_CLASS (parent_class)->style_set) - (*GTK_WIDGET_CLASS (parent_class)->style_set) (widget, - previous_style); - - /* Set the background of the canvas window to the normal color, - or the arrow buttons are not displayed properly. */ - if (GTK_WIDGET_REALIZED (widget->parent)) - gdk_window_set_background (GTK_LAYOUT (widget)->bin_window, - &widget->style->bg[GTK_STATE_NORMAL]); -} - - -static void -e_calendar_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - ECalendar *cal; - GtkStyle *style; - gint col_width, row_height, width, height; - - cal = E_CALENDAR (widget); - style = GTK_WIDGET (cal)->style; - - g_object_get((cal->calitem), - "row_height", &row_height, - "column_width", &col_width, - NULL); - - height = row_height * cal->min_rows; - width = col_width * cal->min_cols; - - requisition->width = width + style->xthickness * 2; - requisition->height = height + style->ythickness * 2; -} - - -static void -e_calendar_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - ECalendar *cal; - PangoFontDescription *font_desc; - PangoContext *pango_context; - PangoFontMetrics *font_metrics; - gdouble old_x2, old_y2, new_x2, new_y2; - gdouble xthickness, ythickness, arrow_button_size; - - cal = E_CALENDAR (widget); - xthickness = widget->style->xthickness; - ythickness = widget->style->ythickness; - - (*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); - - /* Set up Pango prerequisites */ - font_desc = gtk_widget_get_style (widget)->font_desc; - pango_context = gtk_widget_get_pango_context (widget); - font_metrics = pango_context_get_metrics (pango_context, font_desc, - pango_context_get_language (pango_context)); - - /* Set the scroll region to its allocated size, if changed. */ - gnome_canvas_get_scroll_region (GNOME_CANVAS (cal), - NULL, NULL, &old_x2, &old_y2); - new_x2 = widget->allocation.width - 1; - new_y2 = widget->allocation.height - 1; - if (old_x2 != new_x2 || old_y2 != new_y2) - gnome_canvas_set_scroll_region (GNOME_CANVAS (cal), - 0, 0, new_x2, new_y2); - - /* Take off space for line & buttons if shown. */ - gnome_canvas_item_set (GNOME_CANVAS_ITEM (cal->calitem), - "x1", 0.0, - "y1", 0.0, - "x2", new_x2, - "y2", new_y2, - NULL); - - - /* Position the arrow buttons. */ - arrow_button_size = - PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) - + PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics)) - + E_CALENDAR_ITEM_YPAD_ABOVE_MONTH_NAME - + E_CALENDAR_ITEM_YPAD_BELOW_MONTH_NAME - - E_CALENDAR_ARROW_BUTTON_Y_PAD * 2; - - gnome_canvas_item_set (cal->prev_item, - "x", xthickness * 2 - + E_CALENDAR_ARROW_BUTTON_X_PAD, - "y", ythickness * 2 - + E_CALENDAR_ARROW_BUTTON_Y_PAD, - "width", arrow_button_size, - "height", arrow_button_size, - NULL); - - gnome_canvas_item_set (cal->next_item, - "x", new_x2 + 1 - xthickness * 2 - - E_CALENDAR_ARROW_BUTTON_X_PAD - - arrow_button_size, - "y", ythickness * 2 - + E_CALENDAR_ARROW_BUTTON_Y_PAD, - "width", arrow_button_size, - "height", arrow_button_size, - NULL); - - pango_font_metrics_unref (font_metrics); -} - -void -e_calendar_set_minimum_size (ECalendar *cal, - gint rows, - gint cols) -{ - g_return_if_fail (E_IS_CALENDAR (cal)); - - cal->min_rows = rows; - cal->min_cols = cols; - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (cal->calitem), - "minimum_rows", rows, - "minimum_columns", cols, - NULL); - - gtk_widget_queue_resize (GTK_WIDGET (cal)); -} - - -void -e_calendar_set_maximum_size (ECalendar *cal, - gint rows, - gint cols) -{ - g_return_if_fail (E_IS_CALENDAR (cal)); - - cal->max_rows = rows; - cal->max_cols = cols; - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (cal->calitem), - "maximum_rows", rows, - "maximum_columns", cols, - NULL); - - gtk_widget_queue_resize (GTK_WIDGET (cal)); -} - - -/* Returns the border size on each side of the month displays. */ -void -e_calendar_get_border_size (ECalendar *cal, - gint *top, - gint *bottom, - gint *left, - gint *right) -{ - GtkStyle *style; - - g_return_if_fail (E_IS_CALENDAR (cal)); - - style = GTK_WIDGET (cal)->style; - - if (style) { - *top = style->ythickness; - *bottom = style->ythickness; - *left = style->xthickness; - *right = style->xthickness; - } else { - *top = *bottom = *left = *right = 0; - } -} - - -static void -e_calendar_on_prev_pressed (ECalendar *cal) -{ - e_calendar_start_auto_move (cal, FALSE); -} - -static void -e_calendar_on_next_pressed (ECalendar *cal) -{ - e_calendar_start_auto_move (cal, TRUE); -} - -static void -e_calendar_start_auto_move (ECalendar *cal, - gboolean moving_forward) -{ - if (cal->timeout_id == 0) { - cal->timeout_id = g_timeout_add (E_CALENDAR_AUTO_MOVE_TIMEOUT, - e_calendar_auto_move_handler, - cal); - } - cal->timeout_delay = E_CALENDAR_AUTO_MOVE_TIMEOUT_DELAY; - cal->moving_forward = moving_forward; - -} - - -static gboolean -e_calendar_auto_move_handler (gpointer data) -{ - ECalendar *cal; - ECalendarItem *calitem; - gint offset; - - g_return_val_if_fail (E_IS_CALENDAR (data), FALSE); - - cal = E_CALENDAR (data); - calitem = cal->calitem; - - GDK_THREADS_ENTER (); - - if (cal->timeout_delay > 0) { - cal->timeout_delay--; - } else { - offset = cal->moving_forward ? 1 : -1; - e_calendar_item_set_first_month (calitem, calitem->year, - calitem->month + offset); - } - - GDK_THREADS_LEAVE (); - return TRUE; -} - - -static void -e_calendar_on_prev_released (ECalendar *cal) -{ - e_calendar_stop_auto_move (cal); -} - - -static void -e_calendar_on_next_released (ECalendar *cal) -{ - e_calendar_stop_auto_move (cal); -} - - -static void -e_calendar_stop_auto_move (ECalendar *cal) -{ - if (cal->timeout_id != 0) { - gtk_timeout_remove (cal->timeout_id); - cal->timeout_id = 0; - } -} - -static void -e_calendar_on_prev_clicked (ECalendar *cal) -{ - e_calendar_item_set_first_month (cal->calitem, cal->calitem->year, - cal->calitem->month - 1); -} - -static void -e_calendar_on_next_clicked (ECalendar *cal) -{ - e_calendar_item_set_first_month (cal->calitem, cal->calitem->year, - cal->calitem->month + 1); -} - - -static gint -e_calendar_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - ECalendar *cal; - - g_return_val_if_fail (E_IS_CALENDAR (widget), FALSE); - - cal = E_CALENDAR (widget); - -#if 0 - g_print ("In e_calendar_drag_motion\n"); -#endif - - return FALSE; -} - - -static void -e_calendar_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time) -{ - ECalendar *cal; - - g_return_if_fail (E_IS_CALENDAR (widget)); - - cal = E_CALENDAR (widget); - -#if 0 - g_print ("In e_calendar_drag_leave\n"); -#endif -} - -static gboolean -e_calendar_button_has_focus (ECalendar *cal) -{ - GtkWidget *prev_widget, *next_widget; - gboolean ret_val; - - g_return_val_if_fail (E_IS_CALENDAR (cal), FALSE); - - prev_widget = GNOME_CANVAS_WIDGET(cal->prev_item)->widget; - next_widget = GNOME_CANVAS_WIDGET(cal->next_item)->widget; - ret_val = GTK_WIDGET_HAS_FOCUS (prev_widget) || - GTK_WIDGET_HAS_FOCUS (next_widget); - return ret_val; -} - -static gboolean -e_calendar_focus (GtkWidget *widget, GtkDirectionType direction) -{ -#define E_CALENDAR_FOCUS_CHILDREN_NUM 3 - ECalendar *cal; - GnomeCanvas *canvas; - GnomeCanvasItem *children[E_CALENDAR_FOCUS_CHILDREN_NUM]; - gint focused_index = -1; - gint index; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (E_IS_CALENDAR (widget), FALSE); - cal = E_CALENDAR (widget); - canvas = GNOME_CANVAS (widget); - - if (!GTK_WIDGET_CAN_FOCUS (widget)) - return FALSE; - - children[0] = GNOME_CANVAS_ITEM (cal->calitem); - children[1] = cal->prev_item; - children[2] = cal->next_item; - - /* get current focused item, if e-calendar has had focus */ - if (GTK_WIDGET_HAS_FOCUS (widget) || e_calendar_button_has_focus (cal)) - for (index = 0; canvas->focused_item && index < E_CALENDAR_FOCUS_CHILDREN_NUM; ++index) { - if (children[index] == canvas->focused_item) { - focused_index = index; - break; - } - } - - if (focused_index == -1) - if (direction == GTK_DIR_TAB_FORWARD) - focused_index = 0; - else - focused_index = E_CALENDAR_FOCUS_CHILDREN_NUM - 1; - else - if (direction == GTK_DIR_TAB_FORWARD) - ++focused_index; - else - --focused_index; - - if (focused_index < 0 || - focused_index >= E_CALENDAR_FOCUS_CHILDREN_NUM) - /* move out of e-calendar */ - return FALSE; - gnome_canvas_item_grab_focus (children[focused_index]); - if (GNOME_IS_CANVAS_WIDGET (children[focused_index])) { - GtkWidget *widget; - widget = GNOME_CANVAS_WIDGET (children[focused_index])->widget; - gtk_widget_grab_focus (widget); - } - return TRUE; -} - -void -e_calendar_set_focusable (ECalendar *cal, gboolean focusable) -{ - GtkWidget *prev_widget, *next_widget; - - g_return_if_fail (E_IS_CALENDAR (cal)); - - prev_widget = GNOME_CANVAS_WIDGET(cal->prev_item)->widget; - next_widget = GNOME_CANVAS_WIDGET(cal->next_item)->widget; - - if (focusable) { - GTK_WIDGET_SET_FLAGS (cal, GTK_CAN_FOCUS); - GTK_WIDGET_SET_FLAGS (prev_widget, GTK_CAN_FOCUS); - GTK_WIDGET_SET_FLAGS (next_widget, GTK_CAN_FOCUS); - } - else { - if (GTK_WIDGET_HAS_FOCUS (cal) || e_calendar_button_has_focus (cal)) { - GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (cal)); - if (toplevel) - gtk_widget_grab_focus (toplevel); - } - GTK_WIDGET_UNSET_FLAGS (cal, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (prev_widget, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (next_widget, GTK_CAN_FOCUS); - } -} diff --git a/widgets/misc/e-calendar.h b/widgets/misc/e-calendar.h deleted file mode 100644 index 1fe6d2500c..0000000000 --- a/widgets/misc/e-calendar.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ -#ifndef _E_CALENDAR_H_ -#define _E_CALENDAR_H_ - -#include <gtk/gtkwidget.h> -#include <gal/widgets/e-canvas.h> -#include "e-calendar-item.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* - * ECalendar - displays a table of monthly calendars, allowing highlighting - * and selection of one or more days. Like GtkCalendar with more features. - * Most of the functionality is in the ECalendarItem canvas item, though - * we also add GnomeCanvasWidget buttons to go to the previous/next month and - * to got to the current day. - */ - -#define E_CALENDAR(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_calendar_get_type (), ECalendar) -#define E_CALENDAR_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_calendar_get_type (), ECalendarClass) -#define E_IS_CALENDAR(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_calendar_get_type ()) - - -typedef struct _ECalendar ECalendar; -typedef struct _ECalendarClass ECalendarClass; - -struct _ECalendar -{ - ECanvas canvas; - - ECalendarItem *calitem; - - GnomeCanvasItem *prev_item; - GnomeCanvasItem *next_item; - - gint min_rows; - gint min_cols; - - gint max_rows; - gint max_cols; - - /* These are all used when the prev/next buttons are held down. - moving_forward is TRUE if we are moving forward in time, i.e. the - next button is pressed. */ - gint timeout_id; - gint timeout_delay; - gboolean moving_forward; -}; - -struct _ECalendarClass -{ - ECanvasClass parent_class; -}; - - -GtkType e_calendar_get_type (void); -GtkWidget* e_calendar_new (void); - -void e_calendar_set_minimum_size (ECalendar *cal, - gint rows, - gint cols); -void e_calendar_set_maximum_size (ECalendar *cal, - gint rows, - gint cols); - -/* Returns the border size on each side of the month displays. */ -void e_calendar_get_border_size (ECalendar *cal, - gint *top, - gint *bottom, - gint *left, - gint *right); - -void e_calendar_set_focusable (ECalendar *cal, gboolean focusable); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CALENDAR_H_ */ diff --git a/widgets/misc/e-cell-date-edit.c b/widgets/misc/e-cell-date-edit.c deleted file mode 100644 index 737c7da14f..0000000000 --- a/widgets/misc/e-cell-date-edit.c +++ /dev/null @@ -1,977 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2001, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * ECellDateEdit - a subclass of ECellPopup used to show a date with a popup - * window to edit it. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-cell-date-edit.h" - -#include <string.h> -#include <time.h> -#include <glib.h> - -#include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> - -#include <gal/util/e-util.h> -#include <gal/e-table/e-table-item.h> -#include <gal/e-table/e-cell-text.h> - -#include <libgnomeui/gnome-messagebox.h> -#include <libgnome/gnome-i18n.h> - -#include "e-util/e-time-utils.h" -/* This depends on ECalendar which is why I didn't put it in gal. */ -#include "e-calendar.h" - -static void e_cell_date_edit_class_init (GtkObjectClass *object_class); -static void e_cell_date_edit_init (ECellDateEdit *ecde); -static void e_cell_date_edit_destroy (GtkObject *object); -static void e_cell_date_edit_get_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); -static void e_cell_date_edit_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id); - -static gint e_cell_date_edit_do_popup (ECellPopup *ecp, - GdkEvent *event, - int row, - int view_col); -static void e_cell_date_edit_set_popup_values (ECellDateEdit *ecde); -static void e_cell_date_edit_select_matching_time(ECellDateEdit *ecde, - char *time); -static void e_cell_date_edit_show_popup (ECellDateEdit *ecde, - int row, - int view_col); -static void e_cell_date_edit_get_popup_pos (ECellDateEdit *ecde, - int row, - int view_col, - gint *x, - gint *y, - gint *height, - gint *width); - -static void e_cell_date_edit_rebuild_time_list (ECellDateEdit *ecde); - -static int e_cell_date_edit_key_press (GtkWidget *popup_window, - GdkEventKey *event, - ECellDateEdit *ecde); -static int e_cell_date_edit_button_press (GtkWidget *popup_window, - GdkEventButton *event, - ECellDateEdit *ecde); -static void e_cell_date_edit_on_ok_clicked (GtkWidget *button, - ECellDateEdit *ecde); -static void e_cell_date_edit_show_time_invalid_warning (ECellDateEdit *ecde); -static void e_cell_date_edit_on_now_clicked (GtkWidget *button, - ECellDateEdit *ecde); -static void e_cell_date_edit_on_none_clicked (GtkWidget *button, - ECellDateEdit *ecde); -static void e_cell_date_edit_on_today_clicked (GtkWidget *button, - ECellDateEdit *ecde); -static void e_cell_date_edit_update_cell (ECellDateEdit *ecde, - char *text); -static void e_cell_date_edit_on_time_selected (GtkList *list, - ECellDateEdit *ecde); -static void e_cell_date_edit_hide_popup (ECellDateEdit *ecde); - - -/* Our arguments. */ -enum { - ARG_0, - ARG_SHOW_TIME, - ARG_SHOW_NOW_BUTTON, - ARG_SHOW_TODAY_BUTTON, - ARG_ALLOW_NO_DATE_SET, - ARG_USE_24_HOUR_FORMAT, - ARG_LOWER_HOUR, - ARG_UPPER_HOUR -}; - -static ECellPopupClass *parent_class; - - -E_MAKE_TYPE (e_cell_date_edit, "ECellDateEdit", ECellDateEdit, - e_cell_date_edit_class_init, e_cell_date_edit_init, - e_cell_popup_get_type()); - - -static void -e_cell_date_edit_class_init (GtkObjectClass *object_class) -{ - ECellPopupClass *ecpc = (ECellPopupClass *) object_class; - - gtk_object_add_arg_type ("ECellDateEdit::show_time", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_SHOW_TIME); - gtk_object_add_arg_type ("ECellDateEdit::show_now_button", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_SHOW_NOW_BUTTON); - gtk_object_add_arg_type ("ECellDateEdit::show_today_button", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_SHOW_TODAY_BUTTON); - gtk_object_add_arg_type ("ECellDateEdit::allow_no_date_set", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_ALLOW_NO_DATE_SET); - gtk_object_add_arg_type ("ECellDateEdit::use_24_hour_format", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, - ARG_USE_24_HOUR_FORMAT); - gtk_object_add_arg_type ("ECellDateEdit::lower_hour", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_LOWER_HOUR); - gtk_object_add_arg_type ("ECellDateEdit::upper_hour", - GTK_TYPE_INT, GTK_ARG_READWRITE, - ARG_UPPER_HOUR); - - object_class->destroy = e_cell_date_edit_destroy; - object_class->get_arg = e_cell_date_edit_get_arg; - object_class->set_arg = e_cell_date_edit_set_arg; - - ecpc->popup = e_cell_date_edit_do_popup; - - parent_class = g_type_class_ref(e_cell_popup_get_type ()); -} - - -static void -e_cell_date_edit_init (ECellDateEdit *ecde) -{ - GtkWidget *frame, *vbox, *hbox, *vbox2; - GtkWidget *scrolled_window, *list, *bbox; - GtkWidget *now_button, *today_button, *none_button, *ok_button; - - ecde->lower_hour = 0; - ecde->upper_hour = 24; - ecde->use_24_hour_format = TRUE; - ecde->need_time_list_rebuild = TRUE; - ecde->freeze_count = 0; - ecde->time_callback = NULL; - ecde->time_callback_data = NULL; - ecde->time_callback_destroy = NULL; - - /* We create one popup window for the ECell, since there will only - ever be one popup in use at a time. */ - ecde->popup_window = gtk_window_new (GTK_WINDOW_POPUP); - - gtk_window_set_policy (GTK_WINDOW (ecde->popup_window), - TRUE, TRUE, FALSE); - - frame = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (ecde->popup_window), frame); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - gtk_widget_show (frame); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - gtk_widget_show (vbox); - - hbox = gtk_hbox_new (FALSE, 4); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - ecde->calendar = e_calendar_new (); - gnome_canvas_item_set (GNOME_CANVAS_ITEM (E_CALENDAR (ecde->calendar)->calitem), - "move_selection_when_moving", FALSE, - NULL); - gtk_box_pack_start (GTK_BOX (hbox), ecde->calendar, TRUE, TRUE, 0); - gtk_widget_show (ecde->calendar); - - vbox2 = gtk_vbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0); - gtk_widget_show (vbox2); - - ecde->time_entry = gtk_entry_new (); - gtk_widget_set_size_request (ecde->time_entry, 50, -1); - gtk_box_pack_start (GTK_BOX (vbox2), ecde->time_entry, - FALSE, FALSE, 0); - gtk_widget_show (ecde->time_entry); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_box_pack_start (GTK_BOX (vbox2), scrolled_window, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_NEVER, - GTK_POLICY_ALWAYS); - gtk_widget_show (scrolled_window); - - list = gtk_list_new (); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), list); - gtk_container_set_focus_vadjustment (GTK_CONTAINER (list), - gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window))); - gtk_widget_show (list); - ecde->time_list = list; - g_signal_connect((list), "selection-changed", - G_CALLBACK (e_cell_date_edit_on_time_selected), - ecde); - - bbox = gtk_hbutton_box_new (); - gtk_container_set_border_width (GTK_CONTAINER (bbox), 4); - gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), 2); - gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (bbox), 2, 0); - gtk_button_box_set_child_size (GTK_BUTTON_BOX (bbox), 0, 0); - gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); - gtk_widget_show (bbox); - - now_button = gtk_button_new_with_label (_("Now")); - gtk_container_add (GTK_CONTAINER (bbox), now_button); - gtk_widget_show (now_button); - g_signal_connect((now_button), "clicked", - G_CALLBACK (e_cell_date_edit_on_now_clicked), - ecde); - ecde->now_button = now_button; - - today_button = gtk_button_new_with_label (_("Today")); - gtk_container_add (GTK_CONTAINER (bbox), today_button); - gtk_widget_show (today_button); - g_signal_connect((today_button), "clicked", - G_CALLBACK (e_cell_date_edit_on_today_clicked), - ecde); - ecde->today_button = today_button; - - none_button = gtk_button_new_with_label (_("None")); - gtk_container_add (GTK_CONTAINER (bbox), none_button); - gtk_widget_show (none_button); - g_signal_connect((none_button), "clicked", - G_CALLBACK (e_cell_date_edit_on_none_clicked), - ecde); - ecde->none_button = none_button; - - ok_button = gtk_button_new_with_label (_("OK")); - gtk_container_add (GTK_CONTAINER (bbox), ok_button); - gtk_widget_show (ok_button); - g_signal_connect((ok_button), "clicked", - G_CALLBACK (e_cell_date_edit_on_ok_clicked), - ecde); - - - g_signal_connect((ecde->popup_window), - "key_press_event", - G_CALLBACK (e_cell_date_edit_key_press), - ecde); - g_signal_connect((ecde->popup_window), - "button_press_event", - G_CALLBACK (e_cell_date_edit_button_press), - ecde); -} - - -/** - * e_cell_date_edit_new: - * - * Creates a new ECellDateEdit renderer. - * - * Returns: an ECellDateEdit object. - */ -ECell * -e_cell_date_edit_new (void) -{ - ECellDateEdit *ecde = gtk_type_new (e_cell_date_edit_get_type ()); - - return (ECell*) ecde; -} - - -/* - * GtkObject::destroy method - */ -static void -e_cell_date_edit_destroy (GtkObject *object) -{ - ECellDateEdit *ecde = E_CELL_DATE_EDIT (object); - - e_cell_date_edit_set_get_time_callback (ecde, NULL, NULL, NULL); - - gtk_widget_destroy (ecde->popup_window); - ecde->popup_window = NULL; - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -static void -e_cell_date_edit_get_arg (GtkObject *o, - GtkArg *arg, - guint arg_id) -{ - ECellDateEdit *ecde; - - ecde = E_CELL_DATE_EDIT (o); - - switch (arg_id) { - case ARG_SHOW_TIME: - GTK_VALUE_BOOL (*arg) = GTK_WIDGET_VISIBLE (ecde->time_entry) ? TRUE : FALSE; - break; - case ARG_SHOW_NOW_BUTTON: - GTK_VALUE_BOOL (*arg) = GTK_WIDGET_VISIBLE (ecde->now_button) ? TRUE : FALSE; - break; - case ARG_SHOW_TODAY_BUTTON: - GTK_VALUE_BOOL (*arg) = GTK_WIDGET_VISIBLE (ecde->today_button) ? TRUE : FALSE; - break; - case ARG_ALLOW_NO_DATE_SET: - GTK_VALUE_BOOL (*arg) = GTK_WIDGET_VISIBLE (ecde->none_button) ? TRUE : FALSE; - break; - case ARG_USE_24_HOUR_FORMAT: - GTK_VALUE_BOOL (*arg) = ecde->use_24_hour_format; - break; - case ARG_LOWER_HOUR: - GTK_VALUE_INT (*arg) = ecde->lower_hour; - break; - case ARG_UPPER_HOUR: - GTK_VALUE_INT (*arg) = ecde->upper_hour; - break; - default: - g_warning ("Invalid arg"); - } -} - - -static void -e_cell_date_edit_set_arg (GtkObject *o, - GtkArg *arg, - guint arg_id) -{ - ECellDateEdit *ecde; - gint ivalue; - gboolean bvalue; - - ecde = E_CELL_DATE_EDIT (o); - - switch (arg_id){ - case ARG_SHOW_TIME: - bvalue = GTK_VALUE_BOOL (*arg); - if (bvalue) { - gtk_widget_show (ecde->time_entry); - gtk_widget_show (ecde->time_list); - } else { - gtk_widget_hide (ecde->time_entry); - gtk_widget_hide (ecde->time_list); - } - break; - case ARG_SHOW_NOW_BUTTON: - bvalue = GTK_VALUE_BOOL (*arg); - if (bvalue) { - gtk_widget_show (ecde->now_button); - } else { - gtk_widget_hide (ecde->now_button); - } - break; - case ARG_SHOW_TODAY_BUTTON: - bvalue = GTK_VALUE_BOOL (*arg); - if (bvalue) { - gtk_widget_show (ecde->today_button); - } else { - gtk_widget_hide (ecde->today_button); - } - break; - case ARG_ALLOW_NO_DATE_SET: - bvalue = GTK_VALUE_BOOL (*arg); - if (bvalue) { - gtk_widget_show (ecde->none_button); - } else { - /* FIXME: What if we have no date set now. */ - gtk_widget_hide (ecde->none_button); - } - break; - case ARG_USE_24_HOUR_FORMAT: - bvalue = GTK_VALUE_BOOL (*arg); - if (ecde->use_24_hour_format != bvalue) { - ecde->use_24_hour_format = bvalue; - ecde->need_time_list_rebuild = TRUE; - } - break; - case ARG_LOWER_HOUR: - ivalue = GTK_VALUE_INT (*arg); - ivalue = CLAMP (ivalue, 0, 24); - if (ecde->lower_hour != ivalue) { - ecde->lower_hour = ivalue; - ecde->need_time_list_rebuild = TRUE; - } - break; - case ARG_UPPER_HOUR: - ivalue = GTK_VALUE_INT (*arg); - ivalue = CLAMP (ivalue, 0, 24); - if (ecde->upper_hour != ivalue) { - ecde->upper_hour = ivalue; - ecde->need_time_list_rebuild = TRUE; - } - break; - default: - g_warning ("Invalid arg"); - } - -#if 0 - if (ecde->need_time_list_rebuild && ecde->freeze_count == 0) - e_cell_date_edit_rebuild_time_list (ecde); -#endif -} - - -static gint -e_cell_date_edit_do_popup (ECellPopup *ecp, - GdkEvent *event, - int row, - int view_col) -{ - ECellDateEdit *ecde = E_CELL_DATE_EDIT (ecp); - guint32 time; - - e_cell_date_edit_show_popup (ecde, row, view_col); - e_cell_date_edit_set_popup_values (ecde); - - if (event->type == GDK_BUTTON_PRESS) { - time = event->button.time; - } else { - time = event->key.time; - } - - gtk_grab_add (ecde->popup_window); - - /* Set the focus to the first widget. */ - gtk_widget_grab_focus (ecde->time_entry); - gdk_window_focus (ecde->popup_window->window, GDK_CURRENT_TIME); - - return TRUE; -} - - -static void -e_cell_date_edit_set_popup_values (ECellDateEdit *ecde) -{ - ECellPopup *ecp = E_CELL_POPUP (ecde); - ECellText *ecell_text = E_CELL_TEXT (ecp->child); - ECellView *ecv = (ECellView*) ecp->popup_cell_view; - ETableItem *eti = E_TABLE_ITEM (ecp->popup_cell_view->cell_view.e_table_item_view); - ETableCol *ecol; - char *cell_text; - ETimeParseStatus status; - struct tm date_tm; - GDate date; - ECalendarItem *calitem; - char buffer[64]; - gboolean is_date = TRUE; - - ecol = e_table_header_get_column (eti->header, ecp->popup_view_col); - cell_text = e_cell_text_get_text (ecell_text, ecv->e_table_model, - ecol->col_idx, ecp->popup_row); - - /* Try to parse just a date first. If the value is only a date, we - use a DATE value. */ - status = e_time_parse_date (cell_text, &date_tm); - if (status == E_TIME_PARSE_INVALID) { - is_date = FALSE; - status = e_time_parse_date_and_time (cell_text, &date_tm); - } - - /* If there is no date and time set, or the date is invalid, we clear - the selections, else we select the appropriate date & time. */ - calitem = E_CALENDAR_ITEM (E_CALENDAR (ecde->calendar)->calitem); - if (status == E_TIME_PARSE_NONE || status == E_TIME_PARSE_INVALID) { - gtk_entry_set_text (GTK_ENTRY (ecde->time_entry), ""); - e_calendar_item_set_selection (calitem, NULL, NULL); - gtk_list_unselect_all (GTK_LIST (ecde->time_list)); - } else { - if (is_date) { - buffer[0] = '\0'; - } else { - e_time_format_time (&date_tm, ecde->use_24_hour_format, - FALSE, buffer, sizeof (buffer)); - } - gtk_entry_set_text (GTK_ENTRY (ecde->time_entry), buffer); - - g_date_clear (&date, 1); - g_date_set_dmy (&date, date_tm.tm_mday, date_tm.tm_mon + 1, - date_tm.tm_year + 1900); - e_calendar_item_set_selection (calitem, &date, &date); - - if (is_date) { - gtk_list_unselect_all (GTK_LIST (ecde->time_list)); - } else { - e_cell_date_edit_select_matching_time (ecde, buffer); - } - } - - e_cell_text_free_text (ecell_text, cell_text); -} - - -static void -e_cell_date_edit_select_matching_time (ECellDateEdit *ecde, - char *time) -{ - GtkList *list; - GtkWidget *listitem, *label; - GList *elem; - gboolean found = FALSE; - char *list_item_text; - - list = GTK_LIST (ecde->time_list); - elem = list->children; - while (elem) { - listitem = GTK_WIDGET (elem->data); - label = GTK_BIN (listitem)->child; - gtk_label_get (GTK_LABEL (label), &list_item_text); - - if (!strcmp (list_item_text, time)) { - found = TRUE; - gtk_list_select_child (list, listitem); - break; - } - - elem = elem->next; - } - - if (!found) - gtk_list_unselect_all (list); -} - - -static void -e_cell_date_edit_show_popup (ECellDateEdit *ecde, - int row, - int view_col) -{ - gint x, y, width, height, old_width, old_height; - - if (ecde->need_time_list_rebuild) - e_cell_date_edit_rebuild_time_list (ecde); - - /* This code is practically copied from GtkCombo. */ - old_width = ecde->popup_window->allocation.width; - old_height = ecde->popup_window->allocation.height; - - e_cell_date_edit_get_popup_pos (ecde, row, view_col, &x, &y, &height, &width); - - gtk_widget_set_uposition (ecde->popup_window, x, y); - gtk_widget_set_size_request (ecde->popup_window, width, height); - gtk_widget_realize (ecde->popup_window); - gdk_window_resize (ecde->popup_window->window, width, height); - gtk_widget_show (ecde->popup_window); - - e_cell_popup_set_shown (E_CELL_POPUP (ecde), TRUE); -} - - -/* Calculates the size and position of the popup window (like GtkCombo). */ -static void -e_cell_date_edit_get_popup_pos (ECellDateEdit *ecde, - int row, - int view_col, - gint *x, - gint *y, - gint *height, - gint *width) -{ - ECellPopup *ecp = E_CELL_POPUP (ecde); - ETableItem *eti = E_TABLE_ITEM (ecp->popup_cell_view->cell_view.e_table_item_view); - GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (eti)->canvas); - GtkRequisition popup_requisition; - gint avail_height, screen_width, column_width, row_height; - double x1, y1, wx, wy; - - gdk_window_get_origin (canvas->window, x, y); - - x1 = e_table_header_col_diff (eti->header, 0, view_col + 1); - y1 = e_table_item_row_diff (eti, 0, row + 1); - column_width = e_table_header_col_diff (eti->header, view_col, - view_col + 1); - row_height = e_table_item_row_diff (eti, row, - row + 1); - gnome_canvas_item_i2w (GNOME_CANVAS_ITEM (eti), &x1, &y1); - - gnome_canvas_world_to_window (GNOME_CANVAS (canvas), - x1, - y1, - &wx, - &wy); - - *x += wx; - /* The ETable positions don't include the grid lines, I think, so we - add 1. */ - *y += wy + 1; - - avail_height = gdk_screen_height () - *y; - - /* We'll use the entire screen width if needed, but we save space for - the vertical scrollbar in case we need to show that. */ - screen_width = gdk_screen_width (); - - gtk_widget_size_request (ecde->popup_window, &popup_requisition); - - /* Calculate the desired width. */ - *width = popup_requisition.width; - - /* Use at least the same width as the column. */ - if (*width < column_width) - *width = column_width; - - /* Check if it fits in the available height. */ - if (popup_requisition.height > avail_height) { - /* It doesn't fit, so we see if we have the minimum space - needed. */ - if (*y - row_height > avail_height) { - /* We don't, so we show the popup above the cell - instead of below it. */ - avail_height = *y - row_height; - *y -= (popup_requisition.height + row_height); - if (*y < 0) - *y = 0; - } - } - - /* We try to line it up with the right edge of the column, but we don't - want it to go off the edges of the screen. */ - if (*x > screen_width) - *x = screen_width; - *x -= *width; - if (*x < 0) - *x = 0; - - *height = popup_requisition.height; -} - - -/* This handles key press events in the popup window. If the Escape key is - pressed we hide the popup, and do not change the cell contents. */ -static int -e_cell_date_edit_key_press (GtkWidget *popup_window, - GdkEventKey *event, - ECellDateEdit *ecde) -{ - /* If the Escape key is pressed we hide the popup. */ - if (event->keyval != GDK_Escape) - return FALSE; - - e_cell_date_edit_hide_popup (ecde); - - return TRUE; -} - - -/* This handles button press events in the popup window. If the button is - pressed outside the popup, we hide it and do not change the cell contents. -*/ -static int -e_cell_date_edit_button_press (GtkWidget *popup_window, - GdkEventButton *event, - ECellDateEdit *ecde) -{ - GtkWidget *event_widget; - - event_widget = gtk_get_event_widget ((GdkEvent*) event); - if (gtk_widget_get_toplevel (event_widget) != popup_window) { - e_cell_date_edit_hide_popup (ecde); - } - - return TRUE; -} - - -/* Clears the time list and rebuilds it using the lower_hour, upper_hour - and use_24_hour_format settings. */ -static void -e_cell_date_edit_rebuild_time_list (ECellDateEdit *ecde) -{ - GtkList *list; - GtkWidget *listitem; - char buffer[40]; - struct tm tmp_tm; - gint hour, min; - - list = GTK_LIST (ecde->time_list); - - gtk_list_clear_items (list, 0, -1); - - /* Fill the struct tm with some sane values. */ - tmp_tm.tm_year = 2000; - tmp_tm.tm_mon = 0; - tmp_tm.tm_mday = 1; - tmp_tm.tm_sec = 0; - tmp_tm.tm_isdst = 0; - - for (hour = ecde->lower_hour; hour <= ecde->upper_hour; hour++) { - - /* We don't want to display midnight at the end, since that is - really in the next day. */ - if (hour == 24) - break; - - /* We want to finish on upper_hour, with min == 0. */ - for (min = 0; - min == 0 || (min < 60 && hour != ecde->upper_hour); - min += 30) { - tmp_tm.tm_hour = hour; - tmp_tm.tm_min = min; - e_time_format_time (&tmp_tm, ecde->use_24_hour_format, - FALSE, buffer, sizeof (buffer)); - listitem = gtk_list_item_new_with_label (buffer); - gtk_widget_show (listitem); - gtk_container_add (GTK_CONTAINER (list), listitem); - } - } - - ecde->need_time_list_rebuild = FALSE; -} - - -static void -e_cell_date_edit_on_ok_clicked (GtkWidget *button, - ECellDateEdit *ecde) -{ - ECalendarItem *calitem; - GDate start_date, end_date; - gboolean day_selected; - struct tm date_tm; - char buffer[64]; - const char *text; - ETimeParseStatus status; - gboolean is_date = FALSE; - - calitem = E_CALENDAR_ITEM (E_CALENDAR (ecde->calendar)->calitem); - day_selected = e_calendar_item_get_selection (calitem, &start_date, - &end_date); - - text = gtk_entry_get_text (GTK_ENTRY (ecde->time_entry)); - status = e_time_parse_time (text, &date_tm); - if (status == E_TIME_PARSE_INVALID) { - e_cell_date_edit_show_time_invalid_warning (ecde); - return; - } else if (status == E_TIME_PARSE_NONE) { - is_date = TRUE; - } - - if (day_selected) { - date_tm.tm_year = g_date_get_year (&start_date) - 1900; - date_tm.tm_mon = g_date_get_month (&start_date) - 1; - date_tm.tm_mday = g_date_get_day (&start_date); - /* We need to call this to set the weekday. */ - mktime (&date_tm); - e_time_format_date_and_time (&date_tm, - ecde->use_24_hour_format, - !is_date, FALSE, - buffer, sizeof (buffer)); - } else { - buffer[0] = '\0'; - } - - e_cell_date_edit_update_cell (ecde, buffer); - e_cell_date_edit_hide_popup (ecde); -} - - -static void -e_cell_date_edit_show_time_invalid_warning (ECellDateEdit *ecde) -{ - GtkWidget *dialog; - struct tm date_tm; - char buffer[64], *message; - - /* Create a useful error message showing the correct format. */ - date_tm.tm_year = 100; - date_tm.tm_mon = 0; - date_tm.tm_mday = 1; - date_tm.tm_hour = 1; - date_tm.tm_min = 30; - date_tm.tm_sec = 0; - date_tm.tm_isdst = -1; - e_time_format_time (&date_tm, ecde->use_24_hour_format, FALSE, - buffer, sizeof (buffer)); - - message = g_strdup_printf (_("The time must be in the format: %s"), - buffer); - - dialog = gnome_message_box_new (message, GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - /* FIXME: Fix transient settings - I'm not sure it works with popup - windows. Maybe we need to use a normal window without decorations.*/ - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (ecde->popup_window)); - gnome_dialog_run (GNOME_DIALOG (dialog)); - - g_free (message); -} - - -static void -e_cell_date_edit_on_now_clicked (GtkWidget *button, - ECellDateEdit *ecde) -{ - struct tm tmp_tm; - time_t t; - char buffer[64]; - - if (ecde->time_callback) { - tmp_tm = (*ecde->time_callback) (ecde, ecde->time_callback_data); - } else { - t = time (NULL); - tmp_tm = *localtime (&t); - } - e_time_format_date_and_time (&tmp_tm, - ecde->use_24_hour_format, - TRUE, FALSE, - buffer, sizeof (buffer)); - - e_cell_date_edit_update_cell (ecde, buffer); - e_cell_date_edit_hide_popup (ecde); -} - - -static void -e_cell_date_edit_on_none_clicked (GtkWidget *button, - ECellDateEdit *ecde) -{ - e_cell_date_edit_update_cell (ecde, ""); - e_cell_date_edit_hide_popup (ecde); -} - - -static void -e_cell_date_edit_on_today_clicked (GtkWidget *button, - ECellDateEdit *ecde) -{ - struct tm tmp_tm; - time_t t; - char buffer[64]; - - if (ecde->time_callback) { - tmp_tm = (*ecde->time_callback) (ecde, ecde->time_callback_data); - } else { - t = time (NULL); - tmp_tm = *localtime (&t); - } - - tmp_tm.tm_hour = 0; - tmp_tm.tm_min = 0; - tmp_tm.tm_sec = 0; - e_time_format_date_and_time (&tmp_tm, - ecde->use_24_hour_format, - FALSE, FALSE, - buffer, sizeof (buffer)); - - e_cell_date_edit_update_cell (ecde, buffer); - e_cell_date_edit_hide_popup (ecde); -} - - -static void -e_cell_date_edit_update_cell (ECellDateEdit *ecde, - char *text) -{ - ECellPopup *ecp = E_CELL_POPUP (ecde); - ECellText *ecell_text = E_CELL_TEXT (ecp->child); - ECellView *ecv = (ECellView*) ecp->popup_cell_view; - ETableItem *eti = E_TABLE_ITEM (ecv->e_table_item_view); - ETableCol *ecol; - gchar *old_text; - - /* Compare the new text with the existing cell contents. */ - ecol = e_table_header_get_column (eti->header, ecp->popup_view_col); - - old_text = e_cell_text_get_text (ecell_text, ecv->e_table_model, - ecol->col_idx, ecp->popup_row); - - /* If they are different, update the cell contents. */ - if (strcmp (old_text, text)) { - e_cell_text_set_value (ecell_text, ecv->e_table_model, - ecol->col_idx, ecp->popup_row, text); - } - - e_cell_text_free_text (ecell_text, old_text); -} - - -static void -e_cell_date_edit_on_time_selected (GtkList *list, - ECellDateEdit *ecde) -{ - GtkWidget *listitem, *label; - char *list_item_text; - - if (!list->selection) - return; - - listitem = list->selection->data; - label = GTK_BIN (listitem)->child; - gtk_label_get (GTK_LABEL (label), &list_item_text); - gtk_entry_set_text (GTK_ENTRY (ecde->time_entry), list_item_text); -} - - -static void -e_cell_date_edit_hide_popup (ECellDateEdit *ecde) -{ - gtk_grab_remove (ecde->popup_window); - gtk_widget_hide (ecde->popup_window); - e_cell_popup_set_shown (E_CELL_POPUP (ecde), FALSE); -} - - -/* These freeze and thaw the rebuilding of the time list. They are useful when - setting several properties which result in rebuilds of the list, e.g. the - lower_hour, upper_hour and use_24_hour_format properties. */ -void -e_cell_date_edit_freeze (ECellDateEdit *ecde) -{ - g_return_if_fail (E_IS_CELL_DATE_EDIT (ecde)); - - ecde->freeze_count++; -} - - -void -e_cell_date_edit_thaw (ECellDateEdit *ecde) -{ - g_return_if_fail (E_IS_CELL_DATE_EDIT (ecde)); - - if (ecde->freeze_count > 0) { - ecde->freeze_count--; - - if (ecde->freeze_count == 0) - e_cell_date_edit_rebuild_time_list (ecde); - } -} - - -/* Sets a callback to use to get the current time. This is useful if the - application needs to use its own timezone data rather than rely on the - Unix timezone. */ -void -e_cell_date_edit_set_get_time_callback (ECellDateEdit *ecde, - ECellDateEditGetTimeCallback cb, - gpointer data, - GtkDestroyNotify destroy) -{ - g_return_if_fail (E_IS_CELL_DATE_EDIT (ecde)); - - if (ecde->time_callback_data && ecde->time_callback_destroy) - (*ecde->time_callback_destroy) (ecde->time_callback_data); - - ecde->time_callback = cb; - ecde->time_callback_data = data; - ecde->time_callback_destroy = destroy; -} diff --git a/widgets/misc/e-cell-date-edit.h b/widgets/misc/e-cell-date-edit.h deleted file mode 100644 index 6f1dacbb58..0000000000 --- a/widgets/misc/e-cell-date-edit.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2001, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * ECellDateEdit - a subclass of ECellPopup used to show a date with a popup - * window to edit it. - */ - -#ifndef _E_CELL_DATE_EDIT_H_ -#define _E_CELL_DATE_EDIT_H_ - -#include <time.h> -#include <gal/e-table/e-cell-popup.h> - -#define E_CELL_DATE_EDIT_TYPE (e_cell_date_edit_get_type ()) -#define E_CELL_DATE_EDIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_CELL_DATE_EDIT_TYPE, ECellDateEdit)) -#define E_CELL_DATE_EDIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_CELL_DATE_EDIT_TYPE, ECellDateEditClass)) -#define E_IS_CELL_DATE_EDIT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_DATE_EDIT_TYPE)) -#define E_IS_CELL_DATE_EDIT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_DATE_EDIT_TYPE)) - - -typedef struct _ECellDateEdit ECellDateEdit; -typedef struct _ECellDateEditClass ECellDateEditClass; - -/* The type of the callback function optionally used to get the current time. - */ -typedef struct tm (*ECellDateEditGetTimeCallback) (ECellDateEdit *ecde, - gpointer data); - -struct _ECellDateEdit { - ECellPopup parent; - - GtkWidget *popup_window; - GtkWidget *calendar; - GtkWidget *time_entry; - GtkWidget *time_list; - - GtkWidget *now_button; - GtkWidget *today_button; - GtkWidget *none_button; - - /* This is the range of hours we show in the time list. */ - gint lower_hour; - gint upper_hour; - - /* TRUE if we use 24-hour format for the time list and entry. */ - gboolean use_24_hour_format; - - /* This is TRUE if we need to rebuild the list of times. */ - gboolean need_time_list_rebuild; - - /* The freeze count for rebuilding the time list. We only rebuild when - this is 0. */ - gint freeze_count; - - ECellDateEditGetTimeCallback time_callback; - gpointer time_callback_data; - GtkDestroyNotify time_callback_destroy; -}; - -struct _ECellDateEditClass { - ECellPopupClass parent_class; -}; - - -GtkType e_cell_date_edit_get_type (void); -ECell *e_cell_date_edit_new (void); - - -/* These freeze and thaw the rebuilding of the time list. They are useful when - setting several properties which result in rebuilds of the list, e.g. the - lower_hour, upper_hour and use_24_hour_format properties. */ -void e_cell_date_edit_freeze (ECellDateEdit *ecde); -void e_cell_date_edit_thaw (ECellDateEdit *ecde); - - -/* Sets a callback to use to get the current time. This is useful if the - application needs to use its own timezone data rather than rely on the - Unix timezone. */ -void e_cell_date_edit_set_get_time_callback(ECellDateEdit *ecde, - ECellDateEditGetTimeCallback cb, - gpointer data, - GtkDestroyNotify destroy); - - -#endif /* _E_CELL_DATE_EDIT_H_ */ diff --git a/widgets/misc/e-cell-percent.c b/widgets/misc/e-cell-percent.c deleted file mode 100644 index 82ab3a72f8..0000000000 --- a/widgets/misc/e-cell-percent.c +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2001, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * ECellPercent - a subclass of ECellText used to show an integer percentage - * in an ETable. - */ - -#include <config.h> - -#include <ctype.h> - -#include <sys/time.h> -#include <unistd.h> -#include <stdio.h> -#include <gal/util/e-util.h> -#include <libgnomeui/gnome-messagebox.h> -#include <libgnome/gnome-i18n.h> - -#include "e-cell-percent.h" - -#define PARENT_TYPE e_cell_text_get_type () - -static ECellTextClass *parent_class; - - -static char * -ecp_get_text (ECellText *cell, ETableModel *model, int col, int row) -{ - int percent; - static char buffer[8]; - - percent = GPOINTER_TO_INT (e_table_model_value_at (model, col, row)); - - /* A -ve value means the property is not set. */ - if (percent < 0) { - buffer[0] = '\0'; - } else { - g_snprintf (buffer, sizeof (buffer), "%i%%", percent); - } - - return buffer; -} - -static void -ecp_free_text(ECellText *cell, char *text) -{ - /* Do Nothing. */ -} - -/* FIXME: We need to set the "transient_for" property for the dialog. */ -static void -show_percent_warning (void) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new (_("The percent value must be between 0 and 100, inclusive"), - GNOME_MESSAGE_BOX_ERROR, - GNOME_STOCK_BUTTON_OK, NULL); - gtk_widget_show (dialog); -} - -static void -ecp_set_value (ECellText *cell, ETableModel *model, int col, int row, - const char *text) -{ - int matched, percent; - gboolean empty = TRUE; - const char *p; - - if (text) { - p = text; - while (*p) { - if (!isspace ((unsigned char) *p)) { - empty = FALSE; - break; - } - p++; - } - } - - if (empty) { - percent = -1; - } else { - matched = sscanf (text, "%i", &percent); - - if (matched != 1 || percent < 0 || percent > 100) { - show_percent_warning (); - return; - } - } - - e_table_model_set_value_at (model, col, row, - GINT_TO_POINTER (percent)); -} - -static void -e_cell_percent_class_init (GtkObjectClass *object_class) -{ - ECellTextClass *ectc = (ECellTextClass *) object_class; - - parent_class = g_type_class_ref(PARENT_TYPE); - - ectc->get_text = ecp_get_text; - ectc->free_text = ecp_free_text; - ectc->set_value = ecp_set_value; -} - -static void -e_cell_percent_init (GtkObject *object) -{ -} - -/** - * e_cell_percent_new: - * @fontname: font to be used to render on the screen - * @justify: Justification of the string in the cell. - * - * Creates a new ECell renderer that can be used to render an integer - * percentage that comes from the model. The value returned from the model is - * interpreted as being an int. - * - * See ECellText for other features. - * - * Returns: an ECell object that can be used to render numbers. - */ -ECell * -e_cell_percent_new (const char *fontname, GtkJustification justify) -{ - ECellPercent *ecn = g_object_new (E_CELL_PERCENT_TYPE, NULL); - - e_cell_text_construct (E_CELL_TEXT(ecn), fontname, justify); - - return (ECell *) ecn; -} - -E_MAKE_TYPE (e_cell_percent, "ECellPercent", ECellPercent, - e_cell_percent_class_init, e_cell_percent_init, PARENT_TYPE); diff --git a/widgets/misc/e-cell-percent.h b/widgets/misc/e-cell-percent.h deleted file mode 100644 index 6207e0c878..0000000000 --- a/widgets/misc/e-cell-percent.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2001, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * ECellPercent - a subclass of ECellText used to show an integer percentage - * in an ETable. - */ - -#ifndef _E_CELL_PERCENT_H_ -#define _E_CELL_PERCENT_H_ - -#include <gal/e-table/e-cell-text.h> - -#define E_CELL_PERCENT_TYPE (e_cell_percent_get_type ()) -#define E_CELL_PERCENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_CELL_PERCENT_TYPE, ECellPercent)) -#define E_CELL_PERCENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_CELL_PERCENT_TYPE, ECellPercentClass)) -#define E_IS_CELL_NUMBER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_CELL_PERCENT_TYPE)) -#define E_IS_CELL_NUMBER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_CELL_PERCENT_TYPE)) - -typedef struct { - ECellText base; -} ECellPercent; - -typedef struct { - ECellTextClass parent_class; -} ECellPercentClass; - -GType e_cell_percent_get_type (void); -ECell *e_cell_percent_new (const char *fontname, GtkJustification justify); - -#endif /* _E_CELL_PERCENT_H_ */ diff --git a/widgets/misc/e-cell-renderer-combo.c b/widgets/misc/e-cell-renderer-combo.c deleted file mode 100644 index 8ead96c4e8..0000000000 --- a/widgets/misc/e-cell-renderer-combo.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * e-cell-renderer-combo.c - * - * Author: Mike Kestner <mkestner@ximian.com> - * - * Copyright (C) 2003 Ximian Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#include <config.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkarrow.h> -#include <gtk/gtkbutton.h> -#include <gal/util/e-util.h> - -#include "e-combo-cell-editable.h" -#include "e-cell-renderer-combo.h" - -enum { - PROP_0, - PROP_LIST -}; - -struct _ECellRendererComboPriv { - EComboCellEditable *editable; - gchar *path; - GList *list; -}; - -static GtkCellRendererTextClass *parent_class; - -static void -ecrc_editing_done (GtkCellEditable *editable, ECellRendererCombo *cell) -{ - const gchar *new_text; - - if (e_combo_cell_editable_cancelled (E_COMBO_CELL_EDITABLE (editable))) - return; - - new_text = e_combo_cell_editable_get_text (E_COMBO_CELL_EDITABLE (editable)); - - g_signal_emit_by_name (cell, "edited", cell->priv->path, new_text); - g_free (cell->priv->path); - cell->priv->path = NULL; -} - -static GtkCellEditable * -ecrc_start_editing (GtkCellRenderer *cell, GdkEvent *event, GtkWidget *widget, const gchar *path, - GdkRectangle *bg_area, GdkRectangle *cell_area, GtkCellRendererState flags) -{ - ECellRendererCombo *combo_cell = E_CELL_RENDERER_COMBO (cell); - GtkCellRendererText *text_cell = GTK_CELL_RENDERER_TEXT (cell); - EComboCellEditable *editable; - - if (!text_cell->editable) - return NULL; - - editable = E_COMBO_CELL_EDITABLE (e_combo_cell_editable_new ()); - e_combo_cell_editable_set_text (editable, text_cell->text); - e_combo_cell_editable_set_list (editable, combo_cell->priv->list); - gtk_widget_show (GTK_WIDGET (editable)); - - g_signal_connect (editable, "editing-done", G_CALLBACK (ecrc_editing_done), combo_cell); - - combo_cell->priv->editable = g_object_ref (editable); - combo_cell->priv->path = g_strdup (path); - - return GTK_CELL_EDITABLE (editable); -} - -static void -ecrc_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area, - gint *x_offset, gint *y_offset, gint *width, gint *height) -{ - GtkWidget *btn; - GtkRequisition req; - - if (GTK_CELL_RENDERER_CLASS (parent_class)->get_size) - GTK_CELL_RENDERER_CLASS (parent_class)->get_size (cell, widget, cell_area, x_offset, y_offset, width, height); - - btn = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (btn), gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE)); - gtk_widget_size_request (btn, &req); - *width += req.width; - gtk_widget_destroy (btn); -} - -static void -ecrc_get_prop (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - ECellRendererCombo *ecrc = E_CELL_RENDERER_COMBO (object); - - switch (prop_id) { - case PROP_LIST: - g_value_set_pointer (value, ecrc->priv->list); - break; - default: - break; - } -} - -static void -ecrc_set_prop (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - ECellRendererCombo *ecrc = E_CELL_RENDERER_COMBO (object); - - switch (prop_id) { - case PROP_LIST: - ecrc->priv->list = g_value_get_pointer (value); - break; - default: - break; - } -} - -static void -ecrc_finalize (GObject *obj) -{ - ECellRendererCombo *cell = (ECellRendererCombo *) obj; - - if (cell->priv->editable) - g_object_unref (cell->priv->editable); - cell->priv->editable = NULL; - - if (cell->priv->path) - g_free (cell->priv->path); - cell->priv->path = NULL; - - g_free (cell->priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -static void -ecrc_init (ECellRendererCombo *cell) -{ - cell->priv = g_new0 (ECellRendererComboPriv, 1); -} - -static void -ecrc_class_init (ECellRendererComboClass *class) -{ - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class); - GObjectClass *obj_class = G_OBJECT_CLASS (class); - - parent_class = GTK_CELL_RENDERER_TEXT_CLASS (g_type_class_peek_parent (class)); - - obj_class->get_property = ecrc_get_prop; - obj_class->set_property = ecrc_set_prop; - obj_class->finalize = ecrc_finalize; - - cell_class->start_editing = ecrc_start_editing; - cell_class->get_size = ecrc_get_size; - - g_object_class_install_property (obj_class, PROP_LIST, - g_param_spec_pointer ("list", "List", "List of items to popup.", G_PARAM_READWRITE)); -} - -E_MAKE_TYPE (e_cell_renderer_combo, "ECellRendererCombo", ECellRendererCombo, ecrc_class_init, ecrc_init, GTK_TYPE_CELL_RENDERER_TEXT) - -GtkCellRenderer * -e_cell_renderer_combo_new (void) -{ - return GTK_CELL_RENDERER (g_object_new (E_TYPE_CELL_RENDERER_COMBO, NULL)); -} - diff --git a/widgets/misc/e-cell-renderer-combo.h b/widgets/misc/e-cell-renderer-combo.h deleted file mode 100644 index bed1d34a09..0000000000 --- a/widgets/misc/e-cell-renderer-combo.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * e-cell-renderer-combo.h - * - * Author: Mike Kestner <mkestner@ximian.com> - * - * Copyright (C) 2003 Ximian Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef __E_CELL_RENDERER_COMBO_H__ -#define __E_CELL_RENDERER_COMBO_H__ - -#include <gtk/gtkcellrenderertext.h> - -G_BEGIN_DECLS - -#define E_TYPE_CELL_RENDERER_COMBO (e_cell_renderer_combo_get_type ()) -#define E_CELL_RENDERER_COMBO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_CELL_RENDERER_COMBO, ECellRendererCombo)) -#define E_CELL_RENDERER_COMBO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_CELL_RENDERER_COMBO, ECellRendererComboClass)) -#define E_IS_CELL_RENDERER_COMBO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_CELL_RENDERER_COMBO)) -#define E_IS_CELL_RENDERER_COMBO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((o), E_TYPE_CELL_RENDERER_COMBO)) -#define E_CELL_RENDERER_COMBO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_TYPE_CELL_RENDERER_COMBO, ECellRendererComboClass)) - -typedef struct _ECellRendererCombo ECellRendererCombo; -typedef struct _ECellRendererComboClass ECellRendererComboClass; -typedef struct _ECellRendererComboPriv ECellRendererComboPriv; - -struct _ECellRendererCombo -{ - GtkCellRendererText parent; - - ECellRendererComboPriv *priv; -}; - -struct _ECellRendererComboClass -{ - GtkCellRendererTextClass parent_class; -}; - -GType e_cell_renderer_combo_get_type (void); -GtkCellRenderer *e_cell_renderer_combo_new (void); - -G_END_DECLS - -#endif /* __E_CELL_RENDERER_COMBO_H__ */ diff --git a/widgets/misc/e-charset-picker.c b/widgets/misc/e-charset-picker.c deleted file mode 100644 index 79693ace1b..0000000000 --- a/widgets/misc/e-charset-picker.c +++ /dev/null @@ -1,594 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-charset-picker.h" -#include "e-util/e-dialog-utils.h" - -#include <string.h> -#include <iconv.h> - -#include <gtk/gtkhbox.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkstock.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkoptionmenu.h> -#include <gtk/gtksignal.h> - -#include <libgnome/gnome-i18n.h> - -#include <bonobo/bonobo-ui-node.h> -#include <bonobo/bonobo-ui-util.h> - -typedef enum { - E_CHARSET_UNKNOWN, - E_CHARSET_BALTIC, - E_CHARSET_CENTRAL_EUROPEAN, - E_CHARSET_CHINESE, - E_CHARSET_CYRILLIC, - E_CHARSET_GREEK, - E_CHARSET_HEBREW, - E_CHARSET_JAPANESE, - E_CHARSET_KOREAN, - E_CHARSET_TURKISH, - E_CHARSET_UNICODE, - E_CHARSET_WESTERN_EUROPEAN, - E_CHARSET_WESTERN_EUROPEAN_NEW, -} ECharsetClass; - -static const char *classnames[] = { - N_("Unknown"), - N_("Baltic"), - N_("Central European"), - N_("Chinese"), - N_("Cyrillic"), - N_("Greek"), - N_("Hebrew"), - N_("Japanese"), - N_("Korean"), - N_("Turkish"), - N_("Unicode"), - N_("Western European"), - N_("Western European, New"), -}; - -typedef struct { - char *name; - ECharsetClass class; - char *subclass; -} ECharset; - -/* This list is based on what other mailers/browsers support. There's - * not a lot of point in using, say, ISO-8859-3, if anything that can - * read that can read UTF8 too. - */ -static ECharset charsets[] = { - { "ISO-8859-13", E_CHARSET_BALTIC, NULL }, - { "ISO-8859-4", E_CHARSET_BALTIC, NULL }, - { "ISO-8859-2", E_CHARSET_CENTRAL_EUROPEAN, NULL }, - { "Big5", E_CHARSET_CHINESE, N_("Traditional") }, - { "BIG5HKSCS", E_CHARSET_CHINESE, N_("Traditional") }, - { "EUC-TW", E_CHARSET_CHINESE, N_("Traditional") }, - { "GB18030", E_CHARSET_CHINESE, N_("Simplified") }, - { "GB2312", E_CHARSET_CHINESE, N_("Simplified") }, - { "HZ", E_CHARSET_CHINESE, N_("Simplified") }, - { "ISO-2022-CN", E_CHARSET_CHINESE, N_("Simplified") }, - { "KOI8-R", E_CHARSET_CYRILLIC, NULL }, - { "Windows-1251", E_CHARSET_CYRILLIC, NULL }, - { "KOI8-U", E_CHARSET_CYRILLIC, N_("Ukrainian") }, - { "ISO-8859-5", E_CHARSET_CYRILLIC, NULL }, - { "ISO-8859-7", E_CHARSET_GREEK, NULL }, - { "ISO-8859-8", E_CHARSET_HEBREW, N_("Visual") }, - { "ISO-2022-JP", E_CHARSET_JAPANESE, NULL }, - { "EUC-JP", E_CHARSET_JAPANESE, NULL }, - { "Shift_JIS", E_CHARSET_JAPANESE, NULL }, - { "EUC-KR", E_CHARSET_KOREAN, NULL }, - { "ISO-8859-9", E_CHARSET_TURKISH, NULL }, - { "UTF-8", E_CHARSET_UNICODE, NULL }, - { "UTF-7", E_CHARSET_UNICODE, NULL }, - { "ISO-8859-1", E_CHARSET_WESTERN_EUROPEAN, NULL }, - { "ISO-8859-15", E_CHARSET_WESTERN_EUROPEAN_NEW, NULL }, -}; -static const int num_charsets = sizeof (charsets) / sizeof (charsets[0]); - -static void -select_item (GtkMenuShell *menu_shell, GtkWidget *item) -{ - gtk_menu_shell_select_item (menu_shell, item); - gtk_menu_shell_deactivate (menu_shell); -} - -static void -activate (GtkWidget *item, gpointer menu) -{ - g_object_set_data ((GObject *) menu, "activated_item", item); -} - -static GtkWidget * -add_charset (GtkWidget *menu, ECharset *charset, gboolean free_name) -{ - GtkWidget *item; - char *label; - - if (charset->subclass) { - label = g_strdup_printf ("%s, %s (%s)", - _(classnames[charset->class]), - _(charset->subclass), - charset->name); - } else if (charset->class) { - label = g_strdup_printf ("%s (%s)", - _(classnames[charset->class]), - charset->name); - } else { - label = g_strdup (charset->name); - } - - item = gtk_menu_item_new_with_label (label); - g_object_set_data_full ((GObject *) item, "charset", - charset->name, free_name ? g_free : NULL); - g_free (label); - - gtk_widget_show (item); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - g_signal_connect (item, "activate", G_CALLBACK (activate), menu); - - return item; -} - -static gboolean -add_other_charset (GtkWidget *menu, GtkWidget *other, const char *new_charset) -{ - ECharset charset = { NULL, E_CHARSET_UNKNOWN, NULL }; - GtkWidget *item; - iconv_t ic; - - ic = iconv_open ("UTF-8", new_charset); - if (ic == (iconv_t)-1) { - GtkWidget *window = gtk_widget_get_ancestor (other, GTK_TYPE_WINDOW); - e_notice (window, GTK_MESSAGE_ERROR, - _("Unknown character set: %s"), new_charset); - return FALSE; - } - iconv_close (ic); - - /* Temporarily remove the "Other..." item */ - g_object_ref (other); - gtk_container_remove (GTK_CONTAINER (menu), other); - - /* Create new menu item */ - charset.name = g_strdup (new_charset); - item = add_charset (menu, &charset, TRUE); - - /* And re-add "Other..." */ - gtk_menu_shell_append (GTK_MENU_SHELL (menu), other); - g_object_unref (other); - - g_object_set_data_full ((GObject *) menu, "other_charset", - g_strdup (new_charset), g_free); - - g_object_set_data ((GObject *) menu, "activated_item", item); - select_item (GTK_MENU_SHELL (menu), item); - - return TRUE; -} - -static void -activate_entry (GtkWidget *entry, GtkDialog *dialog) -{ - gtk_dialog_response (dialog, GTK_RESPONSE_OK); -} - -static void -activate_other (GtkWidget *item, gpointer menu) -{ - GtkWidget *window, *entry, *label, *vbox, *hbox; - char *old_charset, *new_charset; - GtkDialog *dialog; - - window = gtk_widget_get_toplevel (menu); - if (!GTK_WIDGET_TOPLEVEL (window)) - window = gtk_widget_get_ancestor (item, GTK_TYPE_WINDOW); - - old_charset = g_object_get_data(menu, "other_charset"); - - dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_("Character Encoding"), - GTK_WINDOW (window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL)); - - gtk_dialog_set_has_separator (dialog, FALSE); - gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); - gtk_box_pack_start (GTK_BOX (dialog->vbox), vbox, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - label = gtk_label_new (_("Enter the character set to use")); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - hbox = gtk_hbox_new (FALSE, 12); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); - gtk_widget_show (entry); - - if (old_charset) - gtk_entry_set_text (GTK_ENTRY (entry), old_charset); - g_signal_connect (entry, "activate", - G_CALLBACK (activate_entry), dialog); - - gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 12); - - gtk_widget_show_all (GTK_WIDGET (dialog)); - - g_object_ref (dialog); - if (gtk_dialog_run (dialog) == GTK_RESPONSE_OK) { - new_charset = (char *)gtk_entry_get_text (GTK_ENTRY (entry)); - - if (*new_charset) { - if (add_other_charset (menu, item, new_charset)) { - gtk_widget_destroy (GTK_WIDGET (dialog)); - g_object_unref (dialog); - return; - } - } - } - gtk_widget_destroy (GTK_WIDGET (dialog)); - g_object_unref (dialog); - - /* Revert to previous selection */ - select_item (GTK_MENU_SHELL (menu), g_object_get_data(G_OBJECT(menu), "activated_item")); -} - -/** - * e_charset_picker_new: - * @default_charset: the default character set, or %NULL to use the - * locale character set. - * - * This creates an option menu widget and fills it in with a selection - * of available character sets. The @default_charset (or locale character - * set if @default_charset is %NULL) will be listed first, and selected - * by default (except that iso-8859-1 will always be used instead of - * US-ASCII). Any other character sets of the same language class as - * the default will be listed next, followed by the remaining character - * sets, a separator, and an "Other..." menu item, which can be used to - * select other charsets. - * - * Return value: an option menu widget, filled in and with signals - * attached. - */ -GtkWidget * -e_charset_picker_new (const char *default_charset) -{ - GtkWidget *menu, *item; - int def, i; - const char *locale_charset; - - g_get_charset (&locale_charset); - if (!strcasecmp (locale_charset, "US-ASCII")) - locale_charset = "iso-8859-1"; - - if (!default_charset) - default_charset = locale_charset; - for (def = 0; def < num_charsets; def++) { - if (!strcasecmp (charsets[def].name, default_charset)) - break; - } - - menu = gtk_menu_new (); - for (i = 0; i < num_charsets; i++) { - item = add_charset (menu, &charsets[i], FALSE); - if (i == def) { - activate (item, menu); - select_item (GTK_MENU_SHELL (menu), item); - } - } - - /* do the Unknown/Other section */ - gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_menu_item_new ()); - - if (def == num_charsets) { - ECharset other = { NULL, E_CHARSET_UNKNOWN, NULL }; - - /* Add an entry for @default_charset */ - other.name = g_strdup (default_charset); - item = add_charset (menu, &other, TRUE); - activate (item, menu); - select_item (GTK_MENU_SHELL (menu), item); - g_object_set_data_full ((GObject *) menu, "other_charset", - g_strdup (default_charset), g_free); - def++; - } - - item = gtk_menu_item_new_with_label (_("Other...")); - g_signal_connect (item, "activate", G_CALLBACK (activate_other), menu); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - gtk_widget_show_all (menu); - - return menu; -} - -/** - * e_charset_picker_get_charset: - * @menu: a character set menu from e_charset_picker_new() - * - * Return value: the currently-selected character set in @picker, - * which must be freed with g_free(). - **/ -char * -e_charset_picker_get_charset (GtkWidget *menu) -{ - GtkWidget *item; - char *charset; - - g_return_val_if_fail (GTK_IS_MENU (menu), NULL); - - item = gtk_menu_get_active (GTK_MENU (menu)); - charset = g_object_get_data ((GObject *) item, "charset"); - - return g_strdup (charset); -} - -/** - * e_charset_picker_dialog: - * @title: title for the dialog box - * @prompt: prompt string for the dialog box - * @default_charset: as for e_charset_picker_new() - * @parent: a parent window for the dialog box, or %NULL - * - * This creates a new dialog box with the given @title and @prompt and - * a character set picker menu. It then runs the dialog and returns - * the selected character set, or %NULL if the user clicked "Cancel". - * - * Return value: the selected character set (which must be freed with - * g_free()), or %NULL. - **/ -char * -e_charset_picker_dialog (const char *title, const char *prompt, - const char *default_charset, GtkWindow *parent) -{ - GtkDialog *dialog; - GtkWidget *label, *omenu, *picker, *vbox, *hbox; - char *charset = NULL; - - dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (title, - parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL)); - - gtk_dialog_set_has_separator (dialog, FALSE); - gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 12); - gtk_box_pack_start (GTK_BOX (dialog->vbox), vbox, FALSE, FALSE, 0); - gtk_widget_show (vbox); - - label = gtk_label_new (prompt); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - hbox = gtk_hbox_new (FALSE, 12); - gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - picker = e_charset_picker_new (default_charset); - omenu = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), picker); - gtk_box_pack_start (GTK_BOX (hbox), omenu, TRUE, TRUE, 0); - gtk_widget_show (omenu); - - gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 12); - - gtk_widget_show_all (GTK_WIDGET (dialog)); - - g_object_ref (dialog); - - if (gtk_dialog_run (dialog) == GTK_RESPONSE_OK) - charset = e_charset_picker_get_charset (picker); - - gtk_widget_destroy (GTK_WIDGET (dialog)); - g_object_unref (dialog); - - return charset; -} - -/** - * e_charset_picker_bonobo_ui_populate: - * @uic: Bonobo UI Component - * @path: menu path - * @default_charset: the default character set, or %NULL to use the - * locale character set. - * @cb: Callback function - * @user_data: data to be passed to the callback. - * - * This creates a Bonobo UI menu and fills it in with a selection - * of available character sets. The @default_charset (or locale character - * set if @default_charset is %NULL) will be listed first, and selected - * by default (except that iso-8859-1 will always be used instead of - * US-ASCII). Any other character sets of the same language class as - * the default will be listed next, followed by the remaining character - * sets. - **/ -void -e_charset_picker_bonobo_ui_populate (BonoboUIComponent *uic, const char *path, - const char *default_charset, - BonoboUIListenerFn cb, gpointer user_data) -{ - char *encoded_label, *label; - const char *locale_charset; - GString *menuitems; - int def, i; - - g_get_charset (&locale_charset); - if (!strcasecmp (locale_charset, "US-ASCII")) - locale_charset = "iso-8859-1"; - - if (!default_charset) - default_charset = locale_charset; - for (def = 0; def < num_charsets; def++) { - if (!strcasecmp (charsets[def].name, default_charset)) - break; - } - - label = g_strdup (_("Character Encoding")); - encoded_label = bonobo_ui_util_encode_str (label); - menuitems = g_string_new (""); - g_string_append_printf (menuitems, "<submenu name=\"ECharsetPicker\" label=\"%s\">\n", - encoded_label); - g_free (encoded_label); - g_free (label); - - for (i = 0; i < num_charsets; i++) { - char *command, *label, *encoded_label; - char *charset_name, *u; - - /* escape _'s in the charset name so that it doesn't become an underline in a GtkLabel */ - if ((u = strchr (charsets[i].name, '_'))) { - int extra = 1; - char *s, *d; - - while ((u = strchr (u + 1, '_'))) - extra++; - - d = charset_name = g_alloca (strlen (charsets[i].name) + extra + 1); - s = charsets[i].name; - while (*s != '\0') { - if (*s == '_') - *d++ = '_'; - *d++ = *s++; - } - *d = '\0'; - } else { - charset_name = charsets[i].name; - } - - if (charsets[i].subclass) { - label = g_strdup_printf ("%s, %s (%s)", - _(classnames[charsets[i].class]), - _(charsets[i].subclass), - charset_name); - } else if (charsets[i].class) { - label = g_strdup_printf ("%s (%s)", - _(classnames[charsets[i].class]), - charset_name); - } else { - label = g_strdup (charset_name); - } - - encoded_label = bonobo_ui_util_encode_str (label); - g_free (label); - - command = g_strdup_printf ("<cmd name=\"Charset-%s\" label=\"%s\" type=\"radio\"" - " group=\"charset_picker\" state=\"%d\"/>\n", - charsets[i].name, encoded_label, i == def); - - bonobo_ui_component_set (uic, "/commands", command, NULL); - g_free (command); - - g_string_append_printf (menuitems, " <menuitem name=\"Charset-%s\" verb=\"\"/>\n", - charsets[i].name); - - g_free (encoded_label); - - label = g_strdup_printf ("Charset-%s", charsets[i].name); - bonobo_ui_component_add_listener (uic, label, cb, user_data); - g_free (label); - } - - if (def == num_charsets) { - char *command, *label, *encoded_label; - char *charset_name, *u; - - /* escape _'s in the charset name so that it doesn't become an underline in a GtkLabel */ - if ((u = strchr (default_charset, '_'))) { - int extra = 1; - char *s, *d; - - while ((u = strchr (u + 1, '_'))) - extra++; - - d = charset_name = g_alloca (strlen (default_charset) + extra + 1); - s = (char *) default_charset; - while (*s != '\0') { - if (*s == '_') - *d++ = '_'; - *d++ = *s++; - } - *d = '\0'; - } else { - charset_name = (char *) default_charset; - } - - label = g_strdup (charset_name); - encoded_label = bonobo_ui_util_encode_str (label); - g_free (label); - - command = g_strdup_printf ("<cmd name=\"Charset-%s\" label=\"%s\" type=\"radio\"" - " group=\"charset_picker\" state=\"1\"/>\n", - default_charset, encoded_label); - - bonobo_ui_component_set (uic, "/commands", command, NULL); - g_free (command); - - g_string_append (menuitems, " <separator/>\n"); - g_string_append_printf (menuitems, " <menuitem name=\"Charset-%s\" verb=\"\"/>\n", - default_charset); - - g_free (encoded_label); - - label = g_strdup_printf ("Charset-%s", default_charset); - bonobo_ui_component_add_listener (uic, label, cb, user_data); - g_free (label); - } - - g_string_append (menuitems, "</submenu>\n"); - - bonobo_ui_component_set (uic, path, menuitems->str, NULL); - g_string_free (menuitems, TRUE); -} diff --git a/widgets/misc/e-charset-picker.h b/widgets/misc/e-charset-picker.h deleted file mode 100644 index 97c945c32e..0000000000 --- a/widgets/misc/e-charset-picker.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - * - */ - -#ifndef _E_CHARSETPICKER_H_ -#define _E_CHARSETPICKER_H_ - -#include <gtk/gtkwindow.h> -#include <bonobo/bonobo-ui-component.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -GtkWidget *e_charset_picker_new (const char *default_charset); -char *e_charset_picker_get_charset (GtkWidget *picker); - -char *e_charset_picker_dialog (const char *title, const char *prompt, - const char *default_charset, - GtkWindow *parent); - -/* bonobo equivalents */ -void e_charset_picker_bonobo_ui_populate (BonoboUIComponent *uic, const char *path, - const char *default_charset, - BonoboUIListenerFn cb, gpointer user_data); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CHARSETPICKER_H_ */ diff --git a/widgets/misc/e-clipped-label.c b/widgets/misc/e-clipped-label.c deleted file mode 100644 index b02561c0b7..0000000000 --- a/widgets/misc/e-clipped-label.c +++ /dev/null @@ -1,417 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 1999, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * This is similar to GtkLabel but clips itself and displays '...' if it - * can't fit inside its allocated area. The intended use is for inside buttons - * that are a fixed size. The GtkLabel would normally display only the middle - * part of the text, which doesn't look very good. This only supports one line - * of text (so no wrapping/justification), without underlined characters. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-clipped-label.h" - -#include <math.h> -#include <string.h> - -#include <glib.h> -#include <gdk/gdki18n.h> -#include <libgnome/gnome-i18n.h> - - -static void e_clipped_label_class_init (EClippedLabelClass *class); -static void e_clipped_label_init (EClippedLabel *label); -static void e_clipped_label_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void e_clipped_label_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gint e_clipped_label_expose (GtkWidget *widget, - GdkEventExpose *event); -static void e_clipped_label_recalc_chars_displayed (EClippedLabel *label); -static void e_clipped_label_finalize (GObject *object); - -static void build_layout (EClippedLabel *label, const char *text); - -static GtkMiscClass *parent_class; - -/* This is the string to draw when the label is clipped, e.g. '...'. */ -static gchar *e_clipped_label_ellipsis; - -/* Flags used in chars_displayed field. Must be negative. */ -#define E_CLIPPED_LABEL_NEED_RECALC -1 -#define E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL -2 - - -GtkType -e_clipped_label_get_type (void) -{ - static GtkType e_clipped_label_type = 0; - - if (!e_clipped_label_type){ - GtkTypeInfo e_clipped_label_info = { - "EClippedLabel", - sizeof (EClippedLabel), - sizeof (EClippedLabelClass), - (GtkClassInitFunc) e_clipped_label_class_init, - (GtkObjectInitFunc) e_clipped_label_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - parent_class = g_type_class_ref(GTK_TYPE_MISC); - e_clipped_label_type = gtk_type_unique (GTK_TYPE_MISC, - &e_clipped_label_info); - } - - return e_clipped_label_type; -} - - -static void -e_clipped_label_class_init (EClippedLabelClass *class) -{ - GObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - /* Method override */ - widget_class->size_request = e_clipped_label_size_request; - widget_class->size_allocate = e_clipped_label_size_allocate; - widget_class->expose_event = e_clipped_label_expose; - - object_class->finalize = e_clipped_label_finalize; - - e_clipped_label_ellipsis = _("..."); -} - - -static void -e_clipped_label_init (EClippedLabel *label) -{ - GTK_WIDGET_SET_FLAGS (label, GTK_NO_WINDOW); - - label->label = NULL; - label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC; -} - - -/** - * e_clipped_label_new: - * - * @text: The label text. - * @Returns: A new #EClippedLabel. - * - * Creates a new #EClippedLabel with the given text. - **/ -GtkWidget * -e_clipped_label_new (const gchar *text, - PangoWeight font_weight, - gfloat font_size) -{ - GtkWidget *label; - EClippedLabel *clipped; - - label = GTK_WIDGET (gtk_type_new (e_clipped_label_get_type ())); - - clipped = E_CLIPPED_LABEL (label); - - clipped->font_size = font_size; - clipped->font_weight = font_weight; - clipped->layout = NULL; - - build_layout (clipped, e_clipped_label_ellipsis); - pango_layout_get_pixel_size (clipped->layout, &clipped->ellipsis_width, NULL); - - if (text && *text) - e_clipped_label_set_text (clipped, text); - - return label; -} - -static void -build_layout (EClippedLabel *label, const char *text) -{ - if (!label->layout) { - GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (label)); - PangoFontDescription *desc = pango_font_description_copy (style->font_desc); - - label->layout = gtk_widget_create_pango_layout (GTK_WIDGET (label), text); - - pango_font_description_set_size (desc, pango_font_description_get_size (desc) * label->font_size); - - pango_font_description_set_weight (desc, label->font_weight); - pango_layout_set_font_description (label->layout, desc); - pango_font_description_free (desc); - } - - pango_layout_set_text (label->layout, text, -1); -} - -static void -e_clipped_label_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - EClippedLabel *label; - int height; - int width; - - g_return_if_fail (E_IS_CLIPPED_LABEL (widget)); - g_return_if_fail (requisition != NULL); - - label = E_CLIPPED_LABEL (widget); - - pango_layout_get_pixel_size (label->layout, &width, &height); - - requisition->width = 0; - requisition->height = height + 2 * GTK_MISC (widget)->ypad; -} - - -static void -e_clipped_label_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - EClippedLabel *label; - - label = E_CLIPPED_LABEL (widget); - - widget->allocation = *allocation; - - /* Flag that we need to recalculate how many characters to display. */ - label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC; -} - - -static gint -e_clipped_label_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - EClippedLabel *label; - GtkMisc *misc; - gint x; - PangoRectangle rect; - - g_return_val_if_fail (E_IS_CLIPPED_LABEL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - label = E_CLIPPED_LABEL (widget); - misc = GTK_MISC (widget); - - /* If the label isn't visible or has no text, just return. */ - if (!GTK_WIDGET_VISIBLE (widget) || !GTK_WIDGET_MAPPED (widget) - || !label->label || (*label->label == '\0')) - return TRUE; - - /* Recalculate the number of characters displayed, if necessary. */ - if (label->chars_displayed == E_CLIPPED_LABEL_NEED_RECALC) - e_clipped_label_recalc_chars_displayed (label); - - /* - * GC Clipping - */ - gdk_gc_set_clip_rectangle (widget->style->white_gc, - &event->area); - gdk_gc_set_clip_rectangle (widget->style->fg_gc[widget->state], - &event->area); - - pango_layout_get_pixel_extents (label->layout, &rect, NULL); - - if (label->chars_displayed == E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL) { - x = floor (widget->allocation.x + (gint)misc->xpad - + (((gint)widget->allocation.width - - (gint)label->label_width - 2 * (gint)misc->xpad) - * misc->xalign) + 0.5); - - gdk_draw_layout (widget->window, widget->style->fg_gc[widget->state], - x, label->label_y, label->layout); - } else { - int layout_width; - - x = widget->allocation.x + (gint)misc->xpad; - - /* trim the layout to the number of characters we're displaying */ - pango_layout_set_text (label->layout, label->label, label->chars_displayed); - - /* draw it */ - gdk_draw_layout (widget->window, widget->style->fg_gc[widget->state], - x, label->label_y, label->layout); - - pango_layout_get_pixel_size (label->layout, &layout_width, NULL); - - /* offset the X position for the ellipsis */ - x = widget->allocation.x + (gint)misc->xpad - + label->ellipsis_x; - - /* then draw the ellipsis */ - pango_layout_set_text (label->layout, e_clipped_label_ellipsis, strlen (e_clipped_label_ellipsis)); - - gdk_draw_layout (widget->window, widget->style->fg_gc[widget->state], - x, label->label_y, label->layout); - - /* then reset the layout to our original label text */ - pango_layout_set_text (label->layout, label->label, -1); - } - - gdk_gc_set_clip_mask (widget->style->white_gc, NULL); - gdk_gc_set_clip_mask (widget->style->fg_gc[widget->state], NULL); - - return TRUE; -} - - -static void -e_clipped_label_finalize (GObject *object) -{ - EClippedLabel *label; - - g_return_if_fail (E_IS_CLIPPED_LABEL (object)); - - label = E_CLIPPED_LABEL(object); - - g_free (label->label); - - g_object_unref (label->layout); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/** - * e_clipped_label_get_text: - * - * @label: An #EClippedLabel. - * @Return: The label text. - * - * Returns the label text, or NULL. - **/ -gchar* -e_clipped_label_get_text (EClippedLabel *label) -{ - g_return_val_if_fail (E_IS_CLIPPED_LABEL (label), NULL); - - return label->label; -} - - -/** - * e_clipped_label_set_text: - * - * @label: An #EClippedLabel. - * @text: The new label text. - * - * Sets the label text. - **/ -void -e_clipped_label_set_text (EClippedLabel *label, - const gchar *text) -{ - g_return_if_fail (E_IS_CLIPPED_LABEL (label)); - - if (label->label != text || !label->label || !text - || strcmp (label->label, text)) { - g_free (label->label); - label->label = NULL; - - if (text) - label->label = g_strdup (text); - - build_layout (label, text); - - /* Reset the number of characters displayed, so it is - recalculated when needed. */ - label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC; - - /* We don't queue a resize, since the label should not affect - the widget size, but we queue a draw. */ - gtk_widget_queue_draw (GTK_WIDGET (label)); - } -} - - -static void -e_clipped_label_recalc_chars_displayed (EClippedLabel *label) -{ - gint max_width, width; - GSList *lines; - PangoLayoutLine *line; - int index; - PangoRectangle rect; - GtkWidget *widget = GTK_WIDGET (label); - GtkMisc *misc = GTK_MISC (label); - - max_width = GTK_WIDGET (label)->allocation.width - - 2 * GTK_MISC (label)->xpad; - - if (!label->label) { - label->chars_displayed = 0; - return; - } - - /* See if the entire label fits in the allocated width. */ - pango_layout_set_text (label->layout, label->label, -1); - - pango_layout_get_pixel_extents (label->layout, &rect, NULL); - - label->label_y = floor (widget->allocation.y + (gint)misc->ypad - + (((gint)widget->allocation.height - 2 * (gint)misc->ypad - + (gint)PANGO_ASCENT (rect) - PANGO_DESCENT(rect)) - * misc->yalign) + 0.5); - - pango_layout_get_pixel_size (label->layout, &label->label_width, NULL); - if (label->label_width <= max_width) { - label->chars_displayed = E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL; - return; - } - - label->chars_displayed = 0; - label->ellipsis_x = 0; - - if (max_width <= 0) - return; - - max_width -= label->ellipsis_width; - - lines = pango_layout_get_lines (label->layout); - line = lines->data; - - if (!pango_layout_line_x_to_index (line, - max_width * PANGO_SCALE, - &index, - NULL)) { - return; - } - - label->chars_displayed = index; - - pango_layout_set_text (label->layout, label->label, label->chars_displayed); - pango_layout_get_pixel_size (label->layout, &width, NULL); - - label->ellipsis_x = width; -} diff --git a/widgets/misc/e-clipped-label.h b/widgets/misc/e-clipped-label.h deleted file mode 100644 index b0165b3e7d..0000000000 --- a/widgets/misc/e-clipped-label.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 1999, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * This is similar to GtkLabel but clips itself and displays '...' if it - * can't fit inside its allocated area. The intended use is for inside buttons - * that are a fixed size. The GtkLabel would normally display only the middle - * part of the text, which doesn't look very good. This only supports one line - * of text (so no wrapping/justification), without underlined characters. - */ -#ifndef _E_CLIPPED_LABEL_H_ -#define _E_CLIPPED_LABEL_H_ - -#include <gtk/gtkmisc.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define E_CLIPPED_LABEL(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_clipped_label_get_type (), EClippedLabel) -#define E_CLIPPED_LABEL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_clipped_label_get_type (), EClippedLabelClass) -#define E_IS_CLIPPED_LABEL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_clipped_label_get_type ()) - - -typedef struct _EClippedLabel EClippedLabel; -typedef struct _EClippedLabelClass EClippedLabelClass; - -struct _EClippedLabel -{ - GtkMisc misc; - - gchar *label; - - /* Font size multiplication factor; 1.0 means "default GTK font - size" */ - gfloat font_size; - PangoWeight font_weight; - - /* Our PangoLayout */ - PangoLayout *layout; - - /* This is the width of the entire label string, in pixels. */ - gint label_width; - - /* This is the label's y coord. we store it here so it won't - change as the label's baseline changes (for example if we - ellide the 'y' from 'Summary' the baseline drops) */ - gint label_y; - - /* This is the number of characters we can fit in, or - E_CLIPPED_LABEL_NEED_RECALC if it needs to be recalculated, or - E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL to show the entire label. */ - gint chars_displayed; - - /* This is the x position to display the ellipsis string, e.g. '...', - relative to the start of the label. */ - gint ellipsis_x; - - /* This is the width of the ellipsis, in pixels */ - gint ellipsis_width; -}; - -struct _EClippedLabelClass -{ - GtkMiscClass parent_class; -}; - - -GtkType e_clipped_label_get_type (void); -GtkWidget *e_clipped_label_new (const gchar *text, - PangoWeight font_weight, - gfloat font_size); - -gchar *e_clipped_label_get_text (EClippedLabel *label); -void e_clipped_label_set_text (EClippedLabel *label, - const gchar *text); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CLIPPED_LABEL_H_ */ diff --git a/widgets/misc/e-combo-button.c b/widgets/misc/e-combo-button.c deleted file mode 100644 index e336e88906..0000000000 --- a/widgets/misc/e-combo-button.c +++ /dev/null @@ -1,536 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-combo-button.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-combo-button.h" -#include <e-util/e-icon-factory.h> - -#include <gtk/gtkarrow.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkimage.h> -#include <gtk/gtksignal.h> - -#include <gal/util/e-util.h> - - -struct _EComboButtonPrivate { - GdkPixbuf *icon; - - GtkWidget *icon_image; - GtkWidget *label; - GtkWidget *arrow_image; - GtkWidget *hbox; - - GtkMenu *menu; - - gboolean menu_popped_up; -}; - - -#define SPACING 2 - - -#define PARENT_TYPE gtk_button_get_type () -static GtkButtonClass *parent_class = NULL; - -enum { - ACTIVATE_DEFAULT, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - - -/* Utility functions. */ - -static GtkWidget * -create_empty_image_widget (void) -{ - GtkWidget *image_widget; - GdkPixbuf *pixbuf; - - pixbuf = e_icon_factory_get_icon (NULL, E_ICON_SIZE_MENU); - - image_widget = gtk_image_new_from_pixbuf (pixbuf); - - g_object_unref (pixbuf); - - return image_widget; -} - -static void -set_icon (EComboButton *combo_button, - GdkPixbuf *pixbuf) -{ - EComboButtonPrivate *priv; - - priv = combo_button->priv; - - if (priv->icon != NULL) - g_object_unref (priv->icon); - - if (pixbuf == NULL) { - priv->icon = NULL; - gtk_widget_hide (priv->icon_image); - return; - } - - priv->icon = g_object_ref (pixbuf); - - gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon_image), priv->icon); - - gtk_widget_show (priv->icon_image); -} - - -/* Paint the borders. */ - -static void -paint (EComboButton *combo_button, - GdkRectangle *area) -{ - EComboButtonPrivate *priv = combo_button->priv; - GtkWidget *widget = GTK_WIDGET (combo_button); - GtkShadowType shadow_type; - gboolean interior_focus; - int separator_x; - int focus_width, focus_pad; - int x, y, width, height; - int border_width; - - shadow_type = GTK_BUTTON (widget)->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT; - - border_width = GTK_CONTAINER (widget)->border_width; - - x = widget->allocation.x + border_width; - y = widget->allocation.y + border_width; - width = widget->allocation.width - border_width * 2; - height = widget->allocation.height - border_width * 2; - - separator_x = (priv->label->allocation.width - + priv->label->allocation.x - + priv->arrow_image->allocation.x) / 2; - - gtk_widget_style_get (GTK_WIDGET (widget), - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "interior-focus", &interior_focus, - NULL); - - if (GTK_WIDGET_HAS_DEFAULT (widget) - && GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL) - gtk_paint_box (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - area, widget, "buttondefault", - x, y, width, height); - - if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget)) { - x += focus_width + focus_pad; - y += focus_width + focus_pad; - width -= 2 * (focus_width + focus_pad); - height -= 2 * (focus_width + focus_pad); - } - - if ((GTK_BUTTON (widget)->relief != GTK_RELIEF_NONE) || - ((GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL) && - (GTK_WIDGET_STATE(widget) != GTK_STATE_ACTIVE || GTK_BUTTON (widget)->depressed) && - (GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE))) { - gtk_paint_box (widget->style, widget->window, - GTK_WIDGET_STATE (widget), shadow_type, - area, widget, "button", - x, y, separator_x, height); - gtk_paint_box (widget->style, widget->window, - GTK_WIDGET_STATE (widget), shadow_type, - area, widget, "button", - separator_x, y, width - separator_x, height); - } - - if (GTK_WIDGET_HAS_FOCUS (widget)) { - if (interior_focus) { - x += widget->style->xthickness + focus_pad; - y += widget->style->ythickness + focus_pad; - width -= 2 * (widget->style->xthickness + focus_pad); - height -= 2 * (widget->style->xthickness + focus_pad); - } else { - x -= focus_width + focus_pad; - y -= focus_width + focus_pad; - width += 2 * (focus_width + focus_pad); - height += 2 * (focus_width + focus_pad); - } - - gtk_paint_focus (widget->style, widget->window, - GTK_WIDGET_STATE (widget), - area, widget, "button", - x, y, width, height); - } -} - - -/* Callbacks for the associated menu. */ - -static void -menu_detacher (GtkWidget *widget, - GtkMenu *menu) -{ - EComboButton *combo_button; - EComboButtonPrivate *priv; - - combo_button = E_COMBO_BUTTON (widget); - priv = combo_button->priv; - - gtk_signal_disconnect_by_data (GTK_OBJECT (menu), combo_button); - priv->menu = NULL; -} - -static void -menu_deactivate_callback (GtkMenuShell *menu_shell, - void *data) -{ - EComboButton *combo_button; - EComboButtonPrivate *priv; - - combo_button = E_COMBO_BUTTON (data); - priv = combo_button->priv; - - priv->menu_popped_up = FALSE; - - GTK_BUTTON (combo_button)->button_down = FALSE; - GTK_BUTTON (combo_button)->in_button = FALSE; - gtk_button_leave (GTK_BUTTON (combo_button)); - gtk_button_clicked (GTK_BUTTON (combo_button)); -} - -static void -menu_position_func (GtkMenu *menu, - gint *x_return, - gint *y_return, - gboolean *push_in, - void *data) -{ - EComboButton *combo_button; - GtkAllocation *allocation; - - combo_button = E_COMBO_BUTTON (data); - allocation = & (GTK_WIDGET (combo_button)->allocation); - - gdk_window_get_origin (GTK_WIDGET (combo_button)->window, x_return, y_return); - - *y_return += allocation->height; -} - - -/* GtkObject methods. */ - -static void -impl_destroy (GtkObject *object) -{ - EComboButton *combo_button; - EComboButtonPrivate *priv; - - combo_button = E_COMBO_BUTTON (object); - priv = combo_button->priv; - - if (priv) { - if (priv->arrow_image != NULL) { - gtk_widget_destroy (priv->arrow_image); - priv->arrow_image = NULL; - } - - if (priv->icon != NULL) { - g_object_unref (priv->icon); - priv->icon = NULL; - } - - g_free (priv); - combo_button->priv = NULL; - } - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -/* GtkWidget methods. */ - -static int -impl_button_press_event (GtkWidget *widget, - GdkEventButton *event) -{ - EComboButton *combo_button; - EComboButtonPrivate *priv; - - combo_button = E_COMBO_BUTTON (widget); - priv = combo_button->priv; - - if (event->type == GDK_BUTTON_PRESS && - (event->button == 1 || event->button == 3)) { - GTK_BUTTON (widget)->button_down = TRUE; - - if (event->button == 3 || - event->x >= priv->arrow_image->allocation.x) { - /* User clicked on the right side: pop up the menu. */ - gtk_button_pressed (GTK_BUTTON (widget)); - - priv->menu_popped_up = TRUE; - gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, - menu_position_func, combo_button, - event->button, event->time); - } else { - /* User clicked on the left side: just behave like a - normal button (i.e. not a toggle). */ - gtk_button_pressed (GTK_BUTTON (widget)); - } - } - - return TRUE; -} - -static int -impl_leave_notify_event (GtkWidget *widget, - GdkEventCrossing *event) -{ - EComboButton *combo_button; - EComboButtonPrivate *priv; - - combo_button = E_COMBO_BUTTON (widget); - priv = combo_button->priv; - - /* This is to override the standard behavior of deactivating the button - when the pointer gets out of the widget, in the case in which we - have just popped up the menu. Otherwise, the button would look as - inactive when the menu is popped up. */ - if (! priv->menu_popped_up) - return (* GTK_WIDGET_CLASS (parent_class)->leave_notify_event) (widget, event); - - return FALSE; -} - -static int -impl_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - GtkBin *bin; - GdkEventExpose child_event; - - if (! GTK_WIDGET_DRAWABLE (widget)) - return FALSE; - - bin = GTK_BIN (widget); - - paint (E_COMBO_BUTTON (widget), &event->area); - - child_event = *event; - if (bin->child && GTK_WIDGET_NO_WINDOW (bin->child) && - gtk_widget_intersect (bin->child, &event->area, &child_event.area)) - gtk_container_propagate_expose (GTK_CONTAINER (widget), bin->child, &child_event); - - return FALSE; -} - - -/* GtkButton methods. */ - -static void -impl_released (GtkButton *button) -{ - EComboButton *combo_button; - EComboButtonPrivate *priv; - - combo_button = E_COMBO_BUTTON (button); - priv = combo_button->priv; - - /* Massive cut & paste from GtkButton here... The only change in - behavior here is that we want to emit ::activate_default when not - the menu hasn't been popped up. */ - - if (button->button_down) { - int new_state; - - button->button_down = FALSE; - - if (button->in_button) { - gtk_button_clicked (button); - - if (! priv->menu_popped_up) - gtk_signal_emit (GTK_OBJECT (button), signals[ACTIVATE_DEFAULT]); - } - - new_state = (button->in_button ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL); - - if (GTK_WIDGET_STATE (button) != new_state) { - gtk_widget_set_state (GTK_WIDGET (button), new_state); - - /* We _draw () instead of queue_draw so that if the - operation blocks, the label doesn't vanish. */ - gtk_widget_draw (GTK_WIDGET (button), NULL); - } - } -} - - -static void -class_init (GtkObjectClass *object_class) -{ - GtkWidgetClass *widget_class; - GtkButtonClass *button_class; - - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class->destroy = impl_destroy; - - widget_class = GTK_WIDGET_CLASS (object_class); - widget_class->button_press_event = impl_button_press_event; - widget_class->leave_notify_event = impl_leave_notify_event; - widget_class->expose_event = impl_expose_event; - - button_class = GTK_BUTTON_CLASS (object_class); - button_class->released = impl_released; - - signals[ACTIVATE_DEFAULT] = gtk_signal_new ("activate_default", - GTK_RUN_FIRST, - GTK_CLASS_TYPE (object_class), - G_STRUCT_OFFSET (EComboButtonClass, activate_default), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); -} - -static void -init (EComboButton *combo_button) -{ - EComboButtonPrivate *priv; - - priv = g_new (EComboButtonPrivate, 1); - combo_button->priv = priv; - - priv->hbox = gtk_hbox_new (FALSE, SPACING); - gtk_container_add (GTK_CONTAINER (combo_button), priv->hbox); - gtk_widget_show (priv->hbox); - - priv->icon_image = create_empty_image_widget (); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->icon_image, TRUE, TRUE, 0); - gtk_widget_show (priv->icon_image); - - priv->label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->label, TRUE, TRUE, - 2 * GTK_WIDGET (combo_button)->style->xthickness); - gtk_widget_show (priv->label); - - priv->arrow_image = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_box_pack_start (GTK_BOX (priv->hbox), priv->arrow_image, TRUE, TRUE, - GTK_WIDGET (combo_button)->style->xthickness); - gtk_widget_show (priv->arrow_image); - - priv->icon = NULL; - priv->menu = NULL; - priv->menu_popped_up = FALSE; -} - - -void -e_combo_button_construct (EComboButton *combo_button) -{ - EComboButtonPrivate *priv; - - g_return_if_fail (combo_button != NULL); - g_return_if_fail (E_IS_COMBO_BUTTON (combo_button)); - - priv = combo_button->priv; - g_return_if_fail (priv->menu == NULL); - - GTK_WIDGET_UNSET_FLAGS (combo_button, GTK_CAN_FOCUS); - - gtk_button_set_relief (GTK_BUTTON (combo_button), GTK_RELIEF_NONE); -} - -GtkWidget * -e_combo_button_new (void) -{ - EComboButton *new; - - new = gtk_type_new (e_combo_button_get_type ()); - e_combo_button_construct (new); - - return GTK_WIDGET (new); -} - - -void -e_combo_button_set_icon (EComboButton *combo_button, - GdkPixbuf *pixbuf) -{ - g_return_if_fail (combo_button != NULL); - g_return_if_fail (E_IS_COMBO_BUTTON (combo_button)); - - set_icon (combo_button, pixbuf); -} - -void -e_combo_button_set_label (EComboButton *combo_button, - const char *label) -{ - EComboButtonPrivate *priv; - - g_return_if_fail (combo_button != NULL); - g_return_if_fail (E_IS_COMBO_BUTTON (combo_button)); - g_return_if_fail (label != NULL); - - priv = combo_button->priv; - - if (label == NULL) - label = ""; - - gtk_label_parse_uline (GTK_LABEL (priv->label), label); -} - -void -e_combo_button_set_menu (EComboButton *combo_button, - GtkMenu *menu) -{ - EComboButtonPrivate *priv; - - g_return_if_fail (combo_button != NULL); - g_return_if_fail (E_IS_COMBO_BUTTON (combo_button)); - g_return_if_fail (menu != NULL); - g_return_if_fail (GTK_IS_MENU (menu)); - - priv = combo_button->priv; - - if (priv->menu != NULL) - gtk_menu_detach (priv->menu); - - priv->menu = menu; - if (menu == NULL) - return; - - gtk_menu_attach_to_widget (menu, GTK_WIDGET (combo_button), menu_detacher); - - g_signal_connect((menu), "deactivate", - G_CALLBACK (menu_deactivate_callback), - combo_button); -} - - -E_MAKE_TYPE (e_combo_button, "EComboButton", EComboButton, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-combo-button.h b/widgets/misc/e-combo-button.h deleted file mode 100644 index fa4dcc65a2..0000000000 --- a/widgets/misc/e-combo-button.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-combo-button.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_COMBO_BUTTON_H_ -#define _E_COMBO_BUTTON_H_ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkbutton.h> -#include <gtk/gtkmenu.h> - -#include <gdk-pixbuf/gdk-pixbuf.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_COMBO_BUTTON (e_combo_button_get_type ()) -#define E_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_COMBO_BUTTON, EComboButton)) -#define E_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_COMBO_BUTTON, EComboButtonClass)) -#define E_IS_COMBO_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_COMBO_BUTTON)) -#define E_IS_COMBO_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_COMBO_BUTTON)) - - -typedef struct _EComboButton EComboButton; -typedef struct _EComboButtonPrivate EComboButtonPrivate; -typedef struct _EComboButtonClass EComboButtonClass; - -struct _EComboButton { - GtkButton parent; - - EComboButtonPrivate *priv; -}; - -struct _EComboButtonClass { - GtkButtonClass parent_class; - - /* Signals. */ - void (* activate_default) (EComboButton *combo_button); -}; - - -GtkType e_combo_button_get_type (void); -void e_combo_button_construct (EComboButton *combo_button); -GtkWidget *e_combo_button_new (void); - -void e_combo_button_set_icon (EComboButton *combo_button, - GdkPixbuf *pixbuf); -void e_combo_button_set_label (EComboButton *combo_button, - const char *label); -void e_combo_button_set_menu (EComboButton *combo_button, - GtkMenu *menu); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_COMBO_BUTTON_H_ */ diff --git a/widgets/misc/e-combo-cell-editable.c b/widgets/misc/e-combo-cell-editable.c deleted file mode 100644 index f8de7c9ebc..0000000000 --- a/widgets/misc/e-combo-cell-editable.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - * e-combo-cell-editable.c - * - * Author: Mike Kestner <mkestner@ximian.com> - * - * Copyright (C) 2003 Ximian Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#include <config.h> -#include <gdk/gdkkeysyms.h> -#include <gtk/gtkarrow.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkcelleditable.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtkmain.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtkwindow.h> - -#include "e-combo-cell-editable.h" - -struct _EComboCellEditablePriv { - GtkEntry *entry; - GtkWidget *popup; - GtkTreeView *tree_view; - gboolean cancelled; - GList *list; -}; - -#define GRAB_MASK (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK) - -static GtkEventBoxClass *parent_class; - -static void -kill_popup (EComboCellEditable *ecce) -{ - gtk_grab_remove (GTK_WIDGET (ecce->priv->tree_view)); - gtk_widget_destroy (ecce->priv->popup); - - gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (ecce)); - gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (ecce)); -} - -static gboolean -popup_key_press_cb (GtkWidget *widget, GdkEventKey *event, EComboCellEditable *ecce) -{ - switch (event->keyval) { - case GDK_Escape: - ecce->priv->cancelled = TRUE; - kill_popup (ecce); - break; - - case GDK_Return: - case GDK_KP_Enter: - ecce->priv->cancelled = FALSE; - kill_popup (ecce); - break; - - default: - return FALSE; - } - - return TRUE; -} - -static gboolean -popup_button_press_cb (GtkWidget *widget, GdkEventButton *event, EComboCellEditable *ecce) -{ - GtkAllocation alloc; - gdouble rel_x, rel_y; - gint win_x, win_y; - - if (event->button != 1) - return FALSE; - - gdk_window_get_root_origin (widget->window, &win_x, &win_y); - alloc = ecce->priv->popup->allocation; - - rel_x = event->x_root - win_x - alloc.x; - rel_y = event->y_root - win_y - alloc.y; - - if (rel_x > 0 && rel_x < alloc.width && rel_y > 0 && rel_y < alloc.height) - return FALSE; - - ecce->priv->cancelled = TRUE; - kill_popup (ecce); - - return FALSE; -} - -static gboolean -tree_button_release_cb (GtkWidget *widget, GdkEventButton *event, EComboCellEditable *ecce) -{ - kill_popup (ecce); - return TRUE; -} - -static void -selection_changed_cb (GtkTreeSelection *selection, EComboCellEditable *ecce) -{ - GtkTreeModel *model; - GtkTreeIter iter; - gchar *text; - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - gtk_tree_model_get (model, &iter, 0, &text, -1); - e_combo_cell_editable_set_text (ecce, text); - g_free (text); -} - -static void -build_popup (EComboCellEditable *ecce) -{ - GtkWidget *frame; - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - GList *l; - - ecce->priv->popup = gtk_window_new (GTK_WINDOW_POPUP); - - g_signal_connect (ecce->priv->popup, "button-press-event", G_CALLBACK (popup_button_press_cb), ecce); - g_signal_connect (ecce->priv->popup, "key-press-event", G_CALLBACK (popup_key_press_cb), ecce); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - gtk_widget_show (frame); - gtk_container_add (GTK_CONTAINER (ecce->priv->popup), frame); - - ecce->priv->tree_view = GTK_TREE_VIEW (gtk_tree_view_new ()); - model = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING)); - - for (l = ecce->priv->list; l; l = l->next) { - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, l->data, -1); - } - - gtk_tree_view_set_model (ecce->priv->tree_view, model); - g_object_unref (model); - gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (ecce->priv->tree_view)); - - gtk_tree_view_set_headers_visible (ecce->priv->tree_view, FALSE); - - gtk_tree_view_insert_column_with_attributes (ecce->priv->tree_view, 0, NULL, - gtk_cell_renderer_text_new (), - "text", 0, - NULL); - - g_signal_connect (ecce->priv->tree_view, "button-release-event", G_CALLBACK (tree_button_release_cb), ecce); - - selection = gtk_tree_view_get_selection (ecce->priv->tree_view); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); - g_signal_connect (selection, "changed", G_CALLBACK (selection_changed_cb), ecce); - - gtk_widget_show (GTK_WIDGET (ecce->priv->tree_view)); -} - -static gint -lookup_row (GList *list, const gchar *text) -{ - GList *l; - gint result = 0; - - for (l = list; l; l = l->next, result++) - if (!g_utf8_collate (text, (char *) l->data)) - break; - - return result; -} - -static void -set_cursor (GtkTreeView *tree_view, gint index) -{ - GtkTreePath *path = gtk_tree_path_new (); - gtk_tree_path_append_index (path, index); - - gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE); - - gtk_tree_path_free (path); -} - -static void -grab_popup (GdkWindow *popup) -{ - gdk_pointer_grab (popup, TRUE, GRAB_MASK, NULL, NULL, gtk_get_current_event_time ()); - gdk_keyboard_grab (popup, TRUE, gtk_get_current_event_time ()); -} - -static void -position_popup (EComboCellEditable *ecce, gint x, gint y, gint offset) -{ - GtkRequisition req; - - gtk_widget_realize (ecce->priv->popup); - gtk_widget_size_request (ecce->priv->popup, &req); - - if (req.height > gdk_screen_height () - y) { - y -= (offset + req.height); - if (y < 0) - y = 0; - } - - gtk_window_move (GTK_WINDOW (ecce->priv->popup), x, y); - gtk_widget_show (ecce->priv->popup); -} - -static void -show_popup (EComboCellEditable *ecce, gint x, gint y, gint offset) -{ - gint row; - - if (!ecce->priv->list) - return; - - build_popup (ecce); - row = lookup_row (ecce->priv->list, e_combo_cell_editable_get_text (ecce)); - set_cursor (ecce->priv->tree_view, row); - - position_popup (ecce, x, y, offset); - - gtk_grab_add (GTK_WIDGET (ecce->priv->popup)); - gtk_widget_grab_focus (GTK_WIDGET (ecce->priv->tree_view)); - grab_popup (GTK_WIDGET (ecce->priv->popup)->window); -} - -static void -button_clicked_cb (GtkButton *btn, EComboCellEditable *ecce) -{ - GtkAllocation alloc; - gint x, y; - - if (ecce->priv->popup) { - kill_popup (ecce); - return; - } - - gtk_editable_select_region (GTK_EDITABLE (ecce->priv->entry), 0, 0); - - gdk_window_get_origin (GTK_WIDGET (ecce)->window, &x, &y); - - alloc = GTK_WIDGET (ecce)->allocation; - - show_popup (ecce, x, y + alloc.height, alloc.height); -} - -static void -entry_activated_cb (GtkEntry *entry, EComboCellEditable *widget) -{ - gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget)); - gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget)); -} - -static gboolean -entry_key_press_event_cb (GtkEntry *entry, GdkEventKey *key_event, EComboCellEditable *ecce) -{ - if (key_event->keyval == GDK_Escape) { - ecce->priv->cancelled = TRUE; - gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (ecce)); - gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (ecce)); - return TRUE; - } - - return FALSE; -} - -static void -ecce_start_editing (GtkCellEditable *cell_editable, GdkEvent *event) -{ - EComboCellEditable *ecce = E_COMBO_CELL_EDITABLE (cell_editable); - - gtk_editable_select_region (GTK_EDITABLE (ecce->priv->entry), 0, -1); -} - -static void -ecce_cell_editable_init (GtkCellEditableIface *iface) -{ - iface->start_editing = ecce_start_editing; -} - -static void -ecce_finalize (GObject *obj) -{ - EComboCellEditable *ecce = (EComboCellEditable *) obj; - - g_free (ecce->priv); - - if (G_OBJECT_CLASS (parent_class)->finalize) - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -static void -ecce_init (EComboCellEditable *ecce) -{ - GtkWidget *entry, *btn, *box; - - box = gtk_hbox_new (FALSE, 0); - gtk_widget_show (box); - gtk_container_add (GTK_CONTAINER (ecce), box); - - ecce->priv = g_new0 (EComboCellEditablePriv, 1); - - entry = gtk_entry_new (); - ecce->priv->entry = GTK_ENTRY (entry); - gtk_entry_set_has_frame (ecce->priv->entry, FALSE); - gtk_entry_set_editable (ecce->priv->entry, FALSE); - g_signal_connect (entry, "activate", G_CALLBACK (entry_activated_cb), ecce); - g_signal_connect (entry, "key_press_event", G_CALLBACK (entry_key_press_event_cb), ecce); - gtk_widget_show (entry); - gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 0); - - btn = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (btn), gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT)); - g_signal_connect (btn, "clicked", (GCallback) button_clicked_cb, ecce); - gtk_widget_show_all (btn); - gtk_box_pack_start (GTK_BOX (box), btn, FALSE, TRUE, 0); -} - -static void -ecce_class_init (GObjectClass *klass) -{ - klass->finalize = ecce_finalize; - - parent_class = GTK_EVENT_BOX_CLASS (g_type_class_peek_parent (klass)); -} - -GType -e_combo_cell_editable_get_type (void) -{ - static GType ecce_type = 0; - - if (!ecce_type) { - static const GTypeInfo ecce_info = { - sizeof (EComboCellEditableClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ecce_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EComboCellEditable), - 0, /* n_preallocs */ - (GInstanceInitFunc) ecce_init, - }; - - static const GInterfaceInfo cell_editable_info = { - (GInterfaceInitFunc) ecce_cell_editable_init, - NULL, - NULL - }; - - ecce_type = g_type_register_static (GTK_TYPE_EVENT_BOX, "EComboCellEditable", &ecce_info, 0); - - g_type_add_interface_static (ecce_type, GTK_TYPE_CELL_EDITABLE, &cell_editable_info); - } - - return ecce_type; -} - -GtkCellEditable * -e_combo_cell_editable_new () -{ - return GTK_CELL_EDITABLE (g_object_new (E_TYPE_COMBO_CELL_EDITABLE, NULL)); -} - -const GList * -e_combo_cell_editable_get_list (EComboCellEditable *ecce) -{ - g_return_val_if_fail (E_COMBO_CELL_EDITABLE (ecce), NULL); - - return ecce->priv->list; -} - -void -e_combo_cell_editable_set_list (EComboCellEditable *ecce, GList *list) -{ - g_return_if_fail (E_IS_COMBO_CELL_EDITABLE (ecce)); - - ecce->priv->list = list; -} - -const gchar * -e_combo_cell_editable_get_text (EComboCellEditable *ecce) -{ - g_return_val_if_fail (E_COMBO_CELL_EDITABLE (ecce), NULL); - - return gtk_entry_get_text (ecce->priv->entry); -} - -void -e_combo_cell_editable_set_text (EComboCellEditable *ecce, const gchar *text) -{ - g_return_if_fail (E_IS_COMBO_CELL_EDITABLE (ecce)); - - gtk_entry_set_text (ecce->priv->entry, text ? text : ""); -} - -gboolean -e_combo_cell_editable_cancelled (EComboCellEditable *ecce) -{ - g_return_val_if_fail (E_IS_COMBO_CELL_EDITABLE (ecce), FALSE); - - return ecce->priv->cancelled; -} - diff --git a/widgets/misc/e-combo-cell-editable.h b/widgets/misc/e-combo-cell-editable.h deleted file mode 100644 index aa9100d829..0000000000 --- a/widgets/misc/e-combo-cell-editable.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * e-combo-cell-editable.h - * - * Author: Mike Kestner <mkestner@ximian.com> - * - * Copyright (C) 2003 Ximian Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef __E_COMBO_CELL_EDITABLE_H__ -#define __E_COMBO_CELL_EDITABLE_H__ - -#include <gtk/gtkeventbox.h> - -G_BEGIN_DECLS - -#define E_TYPE_COMBO_CELL_EDITABLE (e_combo_cell_editable_get_type ()) -#define E_COMBO_CELL_EDITABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_COMBO_CELL_EDITABLE, EComboCellEditable)) -#define E_COMBO_CELL_EDITABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_COMBO_CELL_EDITABLE, EComboCellEditableClass)) -#define E_IS_COMBO_CELL_EDITABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_COMBO_CELL_EDITABLE)) -#define E_IS_COMBO_CELL_EDITABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((o), E_TYPE_COMBO_CELL_EDITABLE)) -#define E_COMBO_CELL_EDITABLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_TYPE_COMBO_CELL_EDITABLE, EComboCellEditableClass)) - -typedef struct _EComboCellEditable EComboCellEditable; -typedef struct _EComboCellEditableClass EComboCellEditableClass; -typedef struct _EComboCellEditablePriv EComboCellEditablePriv; - -struct _EComboCellEditable -{ - GtkEventBox parent; - - EComboCellEditablePriv *priv; -}; - -struct _EComboCellEditableClass -{ - GtkEventBoxClass parent_class; -}; - -GType e_combo_cell_editable_get_type (void); - -GtkCellEditable *e_combo_cell_editable_new (void); - -const GList *e_combo_cell_editable_get_list (EComboCellEditable *editable); -void e_combo_cell_editable_set_list (EComboCellEditable *editable, GList *list); - -const gchar *e_combo_cell_editable_get_text (EComboCellEditable *editable); -void e_combo_cell_editable_set_text (EComboCellEditable *editable, const gchar *text); - -gboolean e_combo_cell_editable_cancelled (EComboCellEditable *editable); - -G_END_DECLS - -#endif /* __E_COMBO_CELL_EDITABLE_H__ */ diff --git a/widgets/misc/e-config-page.c b/widgets/misc/e-config-page.c deleted file mode 100644 index 3140850185..0000000000 --- a/widgets/misc/e-config-page.c +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-config-page.c - * - * Copyright (C) 2002 Ximian, 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-config-page.h" - -#include <gal/util/e-util.h> - -#define PARENT_TYPE gtk_event_box_get_type () -static GtkEventBoxClass *parent_class = NULL; - -/* GObject methods. */ - -static void -class_init (EConfigPageClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - - parent_class = g_type_class_ref(PARENT_TYPE); -} - -static void -init (EConfigPage *page, EConfigPageClass *klass) -{ - ; -} - -GtkWidget * -e_config_page_new (void) -{ - return gtk_type_new (e_config_page_get_type ()); -} - -E_MAKE_TYPE (e_config_page, "EConfigPage", EConfigPage, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-config-page.h b/widgets/misc/e-config-page.h deleted file mode 100644 index f4efcf5671..0000000000 --- a/widgets/misc/e-config-page.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-config-page.h - * - * Copyright (C) 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_CONFIG_PAGE_H_ -#define _E_CONFIG_PAGE_H_ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gnome.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_CONFIG_PAGE (e_config_page_get_type ()) -#define E_CONFIG_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CONFIG_PAGE, EConfigPage)) -#define E_CONFIG_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CONFIG_PAGE, EConfigPageClass)) -#define E_IS_CONFIG_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONFIG_PAGE)) -#define E_IS_CONFIG_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CONFIG_PAGE)) - - -typedef struct _EConfigPage EConfigPage; -typedef struct _EConfigPagePrivate EConfigPagePrivate; -typedef struct _EConfigPageClass EConfigPageClass; - -struct _EConfigPage { - GtkEventBox parent; - - EConfigPagePrivate *priv; -}; - -struct _EConfigPageClass { - GtkEventBoxClass parent_class; - -}; - - -GtkType e_config_page_get_type (void); -GtkWidget *e_config_page_new (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CONFIG_PAGE_H_ */ diff --git a/widgets/misc/e-dateedit.c b/widgets/misc/e-dateedit.c deleted file mode 100644 index 3044ae0ddd..0000000000 --- a/widgets/misc/e-dateedit.c +++ /dev/null @@ -1,1944 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * - * Based on the GnomeDateEdit, part of the Gnome Library. - * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * EDateEdit - a widget based on GnomeDateEdit to provide a date & optional - * time field with popups for entering a date. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-dateedit.h" -#include "e-util-marshal.h" - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <gdk/gdkkeysyms.h> -#include <gtk/gtkarrow.h> -#include <gtk/gtkbbox.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkcombo.h> -#include <gtk/gtkdrawingarea.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtklist.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkvbox.h> -#include <libgnome/gnome-i18n.h> -#include <gal/util/e-util.h> -#include "e-util/e-time-utils.h" -#include "e-calendar.h" - - - -struct _EDateEditPrivate { - GtkWidget *date_entry; - GtkWidget *date_button; - - GtkWidget *space; - - GtkWidget *time_combo; - - GtkWidget *cal_popup; - GtkWidget *calendar; - GtkWidget *now_button; - GtkWidget *today_button; - GtkWidget *none_button; /* This will only be visible if a - 'None' date/time is permitted. */ - - gboolean show_date; - gboolean show_time; - gboolean use_24_hour_format; - - /* This is TRUE if we want to make the time field insensitive rather - than hide it when set_show_time() is called. */ - gboolean make_time_insensitive; - - /* This is the range of hours we show in the time popup. */ - gint lower_hour; - gint upper_hour; - - /* This indicates whether the last date committed was invalid. - (A date is committed by hitting Return, moving the keyboard focus, - or selecting a date in the popup). Note that this only indicates - that the date couldn't be parsed. A date set to 'None' is valid - here, though e_date_edit_date_is_valid() will return FALSE if an - empty date isn't actually permitted. */ - gboolean date_is_valid; - - /* This is the last valid date which was set. If the date was set to - 'None' or empty, date_set_to_none will be TRUE and the other fields - are undefined, so don't use them. */ - gboolean date_set_to_none; - gint year; - gint month; - gint day; - - /* This indicates whether the last time committed was invalid. - (A time is committed by hitting Return, moving the keyboard focus, - or selecting a time in the popup). Note that this only indicates - that the time couldn't be parsed. An empty/None time is valid - here, though e_date_edit_time_is_valid() will return FALSE if an - empty time isn't actually permitted. */ - gboolean time_is_valid; - - /* This is the last valid time which was set. If the time was set to - 'None' or empty, time_set_to_none will be TRUE and the other fields - are undefined, so don't use them. */ - gboolean time_set_to_none; - gint hour; - gint minute; - - EDateEditGetTimeCallback time_callback; - gpointer time_callback_data; - GtkDestroyNotify time_callback_destroy; -}; - -enum { - CHANGED, - LAST_SIGNAL -}; - - -static gint date_edit_signals [LAST_SIGNAL] = { 0 }; - - -static void e_date_edit_class_init (EDateEditClass *class); -static void e_date_edit_init (EDateEdit *dedit); -static void create_children (EDateEdit *dedit); -static void e_date_edit_dispose (GObject *object); -static gboolean e_date_edit_mnemonic_activate (GtkWidget *widget, - gboolean group_cycling); -static void e_date_edit_grab_focus (GtkWidget *widget); - -static gint on_date_entry_key_press (GtkWidget *widget, - GdkEventKey *event, - EDateEdit *dedit); -static void on_date_button_clicked (GtkWidget *widget, - EDateEdit *dedit); -static void e_date_edit_show_date_popup (EDateEdit *dedit); -static void position_date_popup (EDateEdit *dedit); -static void on_date_popup_none_button_clicked (GtkWidget *button, - EDateEdit *dedit); -static void on_date_popup_today_button_clicked (GtkWidget *button, - EDateEdit *dedit); -static void on_date_popup_now_button_clicked (GtkWidget *button, - EDateEdit *dedit); -static gint on_date_popup_delete_event (GtkWidget *widget, - EDateEdit *dedit); -static gint on_date_popup_key_press (GtkWidget *widget, - GdkEventKey *event, - EDateEdit *dedit); -static gint on_date_popup_button_press (GtkWidget *widget, - GdkEventButton *event, - gpointer data); -static void on_date_popup_date_selected (ECalendarItem *calitem, - EDateEdit *dedit); -static void hide_date_popup (EDateEdit *dedit); -static void rebuild_time_popup (EDateEdit *dedit); -static gboolean field_set_to_none (const char *text); -static gboolean e_date_edit_parse_date (EDateEdit *dedit, - const char *date_text, - struct tm *date_tm); -static gboolean e_date_edit_parse_time (EDateEdit *dedit, - const gchar *time_text, - struct tm *time_tm); -static void on_date_edit_time_selected (GtkList *list, - EDateEdit *dedit); -static gint on_time_entry_key_press (GtkWidget *widget, - GdkEventKey *event, - EDateEdit *dedit); -static gint on_date_entry_focus_out (GtkEntry *entry, - GdkEventFocus *event, - EDateEdit *dedit); -static gint on_time_entry_focus_out (GtkEntry *entry, - GdkEventFocus *event, - EDateEdit *dedit); -static void e_date_edit_update_date_entry (EDateEdit *dedit); -static void e_date_edit_update_time_entry (EDateEdit *dedit); -static void e_date_edit_update_time_combo_state (EDateEdit *dedit); -static void e_date_edit_check_date_changed (EDateEdit *dedit); -static void e_date_edit_check_time_changed (EDateEdit *dedit); -static gboolean e_date_edit_set_date_internal (EDateEdit *dedit, - gboolean valid, - gboolean none, - gint year, - gint month, - gint day); -static gboolean e_date_edit_set_time_internal (EDateEdit *dedit, - gboolean valid, - gboolean none, - gint hour, - gint minute); - - -static GtkHBoxClass *parent_class; - -/** - * e_date_edit_get_type: - * - * Returns the GtkType for the EDateEdit widget - */ -GType -e_date_edit_get_type (void) -{ - static GType date_edit_type = 0; - - if (!date_edit_type){ - static const GTypeInfo date_edit_info = { - sizeof (EDateEditClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_date_edit_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EDateEdit), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_date_edit_init, - }; - - date_edit_type = g_type_register_static (GTK_TYPE_HBOX, "EDateEdit", &date_edit_info, 0); - } - - return date_edit_type; -} - - -static void -e_date_edit_class_init (EDateEditClass *class) -{ - GObjectClass *object_class = (GObjectClass *) class; - GtkWidgetClass *widget_class = (GtkWidgetClass *) class; - - parent_class = g_type_class_ref (GTK_TYPE_HBOX); - - date_edit_signals [CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EDateEditClass, changed), - NULL, NULL, - e_util_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - object_class->dispose = e_date_edit_dispose; - - widget_class->mnemonic_activate = e_date_edit_mnemonic_activate; - widget_class->grab_focus = e_date_edit_grab_focus; - - class->changed = NULL; -} - - -static void -e_date_edit_init (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - - dedit->priv = priv = g_new0 (EDateEditPrivate, 1); - - priv->show_date = TRUE; - priv->show_time = TRUE; - priv->use_24_hour_format = TRUE; - - priv->make_time_insensitive = FALSE; - - priv->lower_hour = 0; - priv->upper_hour = 24; - - priv->date_is_valid = TRUE; - priv->date_set_to_none = TRUE; - priv->time_is_valid = TRUE; - priv->time_set_to_none = TRUE; - priv->time_callback = NULL; - priv->time_callback_data = NULL; - priv->time_callback_destroy = NULL; - - create_children (dedit); - - /* Set it to the current time. */ - e_date_edit_set_time (dedit, 0); -} - - -/** - * e_date_edit_new: - * - * Description: Creates a new #EDateEdit widget which can be used - * to provide an easy to use way for entering dates and times. - * - * Returns: a new #EDateEdit widget. - */ -GtkWidget * -e_date_edit_new (void) -{ - EDateEdit *dedit; - - dedit = g_object_new (E_TYPE_DATE_EDIT, NULL); - - return GTK_WIDGET (dedit); -} - - -static void -create_children (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - ECalendar *calendar; - GtkWidget *frame, *arrow; - GtkWidget *vbox, *bbox; - - priv = dedit->priv; - - priv->date_entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (dedit), priv->date_entry, FALSE, TRUE, 0); - - g_signal_connect (priv->date_entry, "key_press_event", - G_CALLBACK (on_date_entry_key_press), - dedit); - g_signal_connect_after (priv->date_entry, - "focus_out_event", - G_CALLBACK (on_date_entry_focus_out), - dedit); - - priv->date_button = gtk_button_new (); - g_signal_connect (priv->date_button, "clicked", - G_CALLBACK (on_date_button_clicked), dedit); - gtk_box_pack_start (GTK_BOX (dedit), priv->date_button, - FALSE, FALSE, 0); - - arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_container_add (GTK_CONTAINER (priv->date_button), arrow); - gtk_widget_show (arrow); - - if (priv->show_date) { - gtk_widget_show (priv->date_entry); - gtk_widget_show (priv->date_button); - } - - /* This is just to create a space between the date & time parts. */ - priv->space = gtk_drawing_area_new (); - gtk_box_pack_start (GTK_BOX (dedit), priv->space, FALSE, FALSE, 2); - - - priv->time_combo = gtk_combo_new (); - gtk_box_pack_start (GTK_BOX (dedit), priv->time_combo, FALSE, TRUE, 0); - rebuild_time_popup (dedit); - - g_signal_connect (GTK_COMBO (priv->time_combo)->entry, - "key_press_event", - G_CALLBACK (on_time_entry_key_press), - dedit); - g_signal_connect_after (GTK_COMBO (priv->time_combo)->entry, - "focus_out_event", - G_CALLBACK (on_time_entry_focus_out), - dedit); - g_signal_connect_after (GTK_COMBO (priv->time_combo)->list, - "selection_changed", - G_CALLBACK (on_date_edit_time_selected), - dedit); - - if (priv->show_time || priv->make_time_insensitive) - gtk_widget_show (priv->time_combo); - - if (!priv->show_time && priv->make_time_insensitive) - gtk_widget_set_sensitive (priv->time_combo, FALSE); - - if (priv->show_date - && (priv->show_time || priv->make_time_insensitive)) - gtk_widget_show (priv->space); - - priv->cal_popup = gtk_window_new (GTK_WINDOW_POPUP); - gtk_widget_set_events (priv->cal_popup, - gtk_widget_get_events (priv->cal_popup) - | GDK_KEY_PRESS_MASK); - g_signal_connect (priv->cal_popup, "delete_event", - G_CALLBACK (on_date_popup_delete_event), - dedit); - g_signal_connect (priv->cal_popup, "key_press_event", - G_CALLBACK (on_date_popup_key_press), - dedit); - g_signal_connect (priv->cal_popup, "button_press_event", - G_CALLBACK (on_date_popup_button_press), - dedit); - gtk_window_set_policy (GTK_WINDOW (priv->cal_popup), - FALSE, FALSE, TRUE); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (priv->cal_popup), frame); - gtk_widget_show (frame); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), vbox); - gtk_widget_show (vbox); - - priv->calendar = e_calendar_new (); - calendar = E_CALENDAR (priv->calendar); - gnome_canvas_item_set (GNOME_CANVAS_ITEM (calendar->calitem), - "maximum_days_selected", 1, - "move_selection_when_moving", FALSE, - NULL); - - g_signal_connect (calendar->calitem, - "selection_changed", - G_CALLBACK (on_date_popup_date_selected), dedit); - - gtk_box_pack_start (GTK_BOX (vbox), priv->calendar, FALSE, FALSE, 0); - gtk_widget_show (priv->calendar); - - bbox = gtk_hbutton_box_new (); - gtk_container_set_border_width (GTK_CONTAINER (bbox), 4); - gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), 2); - gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (bbox), 2, 0); - gtk_button_box_set_child_size (GTK_BUTTON_BOX (bbox), 0, 0); - gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); - gtk_widget_show (bbox); - - priv->now_button = gtk_button_new_with_label (_("Now")); - gtk_container_add (GTK_CONTAINER (bbox), priv->now_button); - gtk_widget_show (priv->now_button); - g_signal_connect (priv->now_button, "clicked", - G_CALLBACK (on_date_popup_now_button_clicked), dedit); - - priv->today_button = gtk_button_new_with_label (_("Today")); - gtk_container_add (GTK_CONTAINER (bbox), priv->today_button); - gtk_widget_show (priv->today_button); - g_signal_connect (priv->today_button, "clicked", - G_CALLBACK (on_date_popup_today_button_clicked), dedit); - - /* Note that we don't show this here, since by default a 'None' date - is not permitted. */ - priv->none_button = gtk_button_new_with_label (_("None")); - gtk_container_add (GTK_CONTAINER (bbox), priv->none_button); - g_signal_connect (priv->none_button, "clicked", - G_CALLBACK (on_date_popup_none_button_clicked), dedit); -} - - -static void -e_date_edit_dispose (GObject *object) -{ - EDateEdit *dedit; - - g_return_if_fail (E_IS_DATE_EDIT (object)); - - dedit = E_DATE_EDIT (object); - - if (dedit->priv) { - e_date_edit_set_get_time_callback (dedit, NULL, NULL, NULL); - - gtk_widget_destroy (dedit->priv->cal_popup); - dedit->priv->cal_popup = NULL; - - g_free (dedit->priv); - dedit->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - - -/* GtkWidget::mnemonic_activate() handler for the EDateEdit */ -static gboolean -e_date_edit_mnemonic_activate (GtkWidget *widget, gboolean group_cycling) -{ - e_date_edit_grab_focus (widget); - return TRUE; -} - -/* Grab_focus handler for the EDateEdit. If the date field is being shown, we - grab the focus to that, otherwise we grab it to the time field. */ -static void -e_date_edit_grab_focus (GtkWidget *widget) -{ - EDateEdit *dedit; - - g_return_if_fail (E_IS_DATE_EDIT (widget)); - - dedit = E_DATE_EDIT (widget); - - if (dedit->priv->show_date) - gtk_widget_grab_focus (dedit->priv->date_entry); - else - gtk_widget_grab_focus (GTK_COMBO (dedit->priv->time_combo)->entry); -} - - -/** - * e_date_edit_set_editable: - * @dedit: an #EDateEdit widget. - * @editable: whether or not the widget should accept edits. - * - * Allows the programmer to disallow editing (and the popping up of - * the calendar widget), while still allowing the user to select the - * date from the GtkEntry. - */ -void -e_date_edit_set_editable (EDateEdit *dedit, gboolean editable) -{ - EDateEditPrivate *priv; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - gtk_entry_set_editable (GTK_ENTRY (priv->date_entry), editable); - gtk_widget_set_sensitive (priv->date_button, editable); -} - - -/** - * e_date_edit_get_time: - * @dedit: an #EDateEdit widget. - * @the_time: returns the last valid time entered. - * @Returns: the last valid time entered, or -1 if the time is not set. - * - * Returns the last valid time entered. If empty times are valid, by calling - * e_date_edit_set_allow_no_date_set(), then it may return -1. - * - * Note that the last time entered may actually have been invalid. You can - * check this with e_date_edit_time_is_valid(). - */ -time_t -e_date_edit_get_time (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - struct tm tmp_tm = { 0 }; - - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), -1); - - priv = dedit->priv; - - /* Try to parse any new value now. */ - e_date_edit_check_date_changed (dedit); - e_date_edit_check_time_changed (dedit); - - if (priv->date_set_to_none) - return -1; - - tmp_tm.tm_year = priv->year; - tmp_tm.tm_mon = priv->month; - tmp_tm.tm_mday = priv->day; - - if (!priv->show_time || priv->time_set_to_none) { - tmp_tm.tm_hour = 0; - tmp_tm.tm_min = 0; - } else { - tmp_tm.tm_hour = priv->hour; - tmp_tm.tm_min = priv->minute; - } - tmp_tm.tm_sec = 0; - tmp_tm.tm_isdst = -1; - - return mktime (&tmp_tm); -} - - -/** - * e_date_edit_set_time: - * @dedit: the EDateEdit widget - * @the_time: The time and date that should be set on the widget - * - * Description: Changes the displayed date and time in the EDateEdit - * widget to be the one represented by @the_time. If @the_time is 0 - * then current time is used. If it is -1, then the date is set to None. - * - * Note that the time is converted to local time using the Unix timezone, - * so if you are using your own timezones then you should use - * e_date_edit_set_date() and e_date_edit_set_time_of_day() instead. - */ -void -e_date_edit_set_time (EDateEdit *dedit, - time_t the_time) -{ - EDateEditPrivate *priv; - struct tm tmp_tm; - gboolean date_changed = FALSE, time_changed = FALSE; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - if (the_time == -1) { - date_changed = e_date_edit_set_date_internal (dedit, TRUE, - TRUE, 0, 0, 0); - time_changed = e_date_edit_set_time_internal (dedit, TRUE, - TRUE, 0, 0); - } else { - if (the_time == 0) { - if (priv->time_callback) { - tmp_tm = (*priv->time_callback) (dedit, priv->time_callback_data); - } else { - the_time = time (NULL); - tmp_tm = *localtime (&the_time); - } - } else { - tmp_tm = *localtime (&the_time); - } - - date_changed = e_date_edit_set_date_internal (dedit, TRUE, - FALSE, - tmp_tm.tm_year, - tmp_tm.tm_mon, - tmp_tm.tm_mday); - time_changed = e_date_edit_set_time_internal (dedit, TRUE, - FALSE, - tmp_tm.tm_hour, - tmp_tm.tm_min); - } - - e_date_edit_update_date_entry (dedit); - e_date_edit_update_time_entry (dedit); - e_date_edit_update_time_combo_state (dedit); - - /* Emit the signals if the date and/or time has actually changed. */ - if (date_changed || time_changed) - g_signal_emit (dedit, - date_edit_signals [CHANGED], 0); -} - - -/** - * e_date_edit_get_date: - * @dedit: an #EDateEdit widget. - * @year: returns the year set. - * @month: returns the month set (1 - 12). - * @day: returns the day set (1 - 31). - * @Returns: TRUE if a time was set, or FALSE if the field is empty or 'None'. - * - * Returns the last valid date entered into the date field. - */ -gboolean -e_date_edit_get_date (EDateEdit *dedit, - gint *year, - gint *month, - gint *day) -{ - EDateEditPrivate *priv; - - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE); - - priv = dedit->priv; - - /* Try to parse any new value now. */ - e_date_edit_check_date_changed (dedit); - - *year = priv->year + 1900; - *month = priv->month + 1; - *day = priv->day; - - if (priv->date_set_to_none - && e_date_edit_get_allow_no_date_set (dedit)) - return FALSE; - - return TRUE; -} - - -/** - * e_date_edit_set_date: - * @dedit: an #EDateEdit widget. - * @year: the year to set. - * @month: the month to set (1 - 12). - * @day: the day to set (1 - 31). - * - * Sets the date in the date field. - */ -void -e_date_edit_set_date (EDateEdit *dedit, - gint year, - gint month, - gint day) -{ - EDateEditPrivate *priv; - gboolean date_changed = FALSE; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - date_changed = e_date_edit_set_date_internal (dedit, TRUE, FALSE, - year - 1900, month - 1, - day); - - e_date_edit_update_date_entry (dedit); - e_date_edit_update_time_combo_state (dedit); - - /* Emit the signals if the date has actually changed. */ - if (date_changed) - g_signal_emit (dedit, - date_edit_signals [CHANGED], 0); -} - - -/** - * e_date_edit_get_time_of_day: - * @dedit: an #EDateEdit widget. - * @hour: returns the hour set, or 0 if the time isn't set. - * @minute: returns the minute set, or 0 if the time isn't set. - * @Returns: TRUE if a time was set, or FALSE if the field is empty or 'None'. - * - * Returns the last valid time entered into the time field. - */ -gboolean -e_date_edit_get_time_of_day (EDateEdit *dedit, - gint *hour, - gint *minute) -{ - EDateEditPrivate *priv; - - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE); - - priv = dedit->priv; - - /* Try to parse any new value now. */ - e_date_edit_check_time_changed (dedit); - - if (priv->time_set_to_none) { - *hour = 0; - *minute = 0; - return FALSE; - } else { - *hour = priv->hour; - *minute = priv->minute; - return TRUE; - } -} - - -/** - * e_date_edit_set_time_of_day: - * @dedit: an #EDateEdit widget. - * @hour: the hour to set, or -1 to set the time to None (i.e. empty). - * @minute: the minute to set. - * - * Description: Sets the time in the time field. - */ -void -e_date_edit_set_time_of_day (EDateEdit *dedit, - gint hour, - gint minute) -{ - EDateEditPrivate *priv; - gboolean time_changed = FALSE; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - if (hour == -1) { - gboolean allow_no_date_set = e_date_edit_get_allow_no_date_set (dedit); - g_return_if_fail (allow_no_date_set); - if (!priv->time_set_to_none) { - priv->time_set_to_none = TRUE; - time_changed = TRUE; - } - } else if (priv->time_set_to_none - || priv->hour != hour - || priv->minute != minute) { - priv->time_set_to_none = FALSE; - priv->hour = hour; - priv->minute = minute; - time_changed = TRUE; - } - - e_date_edit_update_time_entry (dedit); - - if (time_changed) - g_signal_emit (dedit, - date_edit_signals [CHANGED], 0); -} - -void -e_date_edit_set_date_and_time_of_day (EDateEdit *dedit, - gint year, - gint month, - gint day, - gint hour, - gint minute) -{ - EDateEditPrivate *priv; - gboolean date_changed, time_changed; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - date_changed = e_date_edit_set_date_internal (dedit, TRUE, FALSE, - year - 1900, month - 1, day); - time_changed = e_date_edit_set_time_internal (dedit, TRUE, FALSE, - hour, minute); - - e_date_edit_update_date_entry (dedit); - e_date_edit_update_time_entry (dedit); - e_date_edit_update_time_combo_state (dedit); - - if (date_changed || time_changed) - g_signal_emit (dedit, - date_edit_signals [CHANGED], 0); -} - -/** - * e_date_edit_get_show_date: - * @dedit: an #EDateEdit widget. - * @Returns: Whether the date field is shown. - * - * Description: Returns TRUE if the date field is currently shown. - */ -gboolean -e_date_edit_get_show_date (EDateEdit *dedit) -{ - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), TRUE); - - return dedit->priv->show_date; -} - - -/** - * e_date_edit_set_show_date: - * @dedit: an #EDateEdit widget. - * @show_date: TRUE if the date field should be shown. - * - * Description: Specifies whether the date field should be shown. The date - * field would be hidden if only a time needed to be entered. - */ -void -e_date_edit_set_show_date (EDateEdit *dedit, - gboolean show_date) -{ - EDateEditPrivate *priv; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - if (priv->show_date == show_date) - return; - - priv->show_date = show_date; - - if (show_date) { - gtk_widget_show (priv->date_entry); - gtk_widget_show (priv->date_button); - } else { - gtk_widget_hide (priv->date_entry); - gtk_widget_hide (priv->date_button); - } - - e_date_edit_update_time_combo_state (dedit); - - if (priv->show_date - && (priv->show_time || priv->make_time_insensitive)) - gtk_widget_show (priv->space); - else - gtk_widget_hide (priv->space); -} - - -/** - * e_date_edit_get_show_time: - * @dedit: an #EDateEdit widget - * @Returns: Whether the time field is shown. - * - * Description: Returns TRUE if the time field is currently shown. - */ -gboolean -e_date_edit_get_show_time (EDateEdit *dedit) -{ - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), TRUE); - - return dedit->priv->show_time; -} - - -/** - * e_date_edit_set_show_time: - * @dedit: an #EDateEdit widget - * @show_time: TRUE if the time field should be shown. - * - * Description: Specifies whether the time field should be shown. The time - * field would be hidden if only a date needed to be entered. - */ -void -e_date_edit_set_show_time (EDateEdit *dedit, - gboolean show_time) -{ - EDateEditPrivate *priv; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - if (priv->show_time == show_time) - return; - - priv->show_time = show_time; - - e_date_edit_update_time_combo_state (dedit); -} - - -/** - * e_date_edit_get_make_time_insensitive: - * @dedit: an #EDateEdit widget - * @Returns: Whether the time field is be made insensitive instead of hiding - * it. - * - * Description: Returns TRUE if the time field is made insensitive instead of - * hiding it. - */ -gboolean -e_date_edit_get_make_time_insensitive (EDateEdit *dedit) -{ - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), TRUE); - - return dedit->priv->make_time_insensitive; -} - - -/** - * e_date_edit_set_make_time_insensitive: - * @dedit: an #EDateEdit widget - * @make_insensitive: TRUE if the time field should be made insensitive instead - * of hiding it. - * - * Description: Specifies whether the time field should be made insensitive - * rather than hiding it. Note that this doesn't make it insensitive - you - * need to call e_date_edit_set_show_time() with FALSE as show_time to do that. - * - * This is useful if you want to disable the time field, but don't want it to - * disappear as that may affect the layout of the widgets. - */ -void -e_date_edit_set_make_time_insensitive (EDateEdit *dedit, - gboolean make_insensitive) -{ - EDateEditPrivate *priv; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - if (priv->make_time_insensitive == make_insensitive) - return; - - priv->make_time_insensitive = make_insensitive; - - e_date_edit_update_time_combo_state (dedit); -} - - -/** - * e_date_edit_get_week_start_day: - * @dedit: an #EDateEdit widget - * @Returns: the week start day, from 0 (Sunday) to 6 (Saturday). - * - * Description: Returns the week start day currently used in the calendar - * popup. - */ -gint -e_date_edit_get_week_start_day (EDateEdit *dedit) -{ - gint week_start_day; - - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), 1); - - g_object_get (E_CALENDAR (dedit->priv->calendar)->calitem, - "week_start_day", &week_start_day, - NULL); - - return week_start_day; -} - - -/** - * e_date_edit_set_week_start_day: - * @dedit: an #EDateEdit widget - * @week_start_day: the week start day, from 0 (Sunday) to 6 (Saturday). - * - * Description: Sets the week start day to use in the calendar popup. - */ -void -e_date_edit_set_week_start_day (EDateEdit *dedit, - gint week_start_day) -{ - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (E_CALENDAR (dedit->priv->calendar)->calitem), - "week_start_day", week_start_day, - NULL); -} - - -/* Whether we show week numbers in the date popup. */ -gboolean -e_date_edit_get_show_week_numbers (EDateEdit *dedit) -{ - gboolean show_week_numbers; - - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE); - - g_object_get (E_CALENDAR (dedit->priv->calendar)->calitem, - "show_week_numbers", &show_week_numbers, - NULL); - - return show_week_numbers; -} - - -void -e_date_edit_set_show_week_numbers (EDateEdit *dedit, - gboolean show_week_numbers) -{ - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - gnome_canvas_item_set (GNOME_CANVAS_ITEM (E_CALENDAR (dedit->priv->calendar)->calitem), - "show_week_numbers", show_week_numbers, - NULL); -} - - -/* Whether we use 24 hour format in the time field & popup. */ -gboolean -e_date_edit_get_use_24_hour_format (EDateEdit *dedit) -{ - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), TRUE); - - return dedit->priv->use_24_hour_format; -} - - -void -e_date_edit_set_use_24_hour_format (EDateEdit *dedit, - gboolean use_24_hour_format) -{ - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - if (dedit->priv->use_24_hour_format == use_24_hour_format) - return; - - dedit->priv->use_24_hour_format = use_24_hour_format; - - rebuild_time_popup (dedit); - - e_date_edit_update_time_entry (dedit); -} - - -/* Whether we allow the date to be set to 'None'. e_date_edit_get_time() will - return (time_t) -1 in this case. */ -gboolean -e_date_edit_get_allow_no_date_set (EDateEdit *dedit) -{ - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE); - - return GTK_WIDGET_VISIBLE (dedit->priv->none_button); -} - - -void -e_date_edit_set_allow_no_date_set (EDateEdit *dedit, - gboolean allow_no_date_set) -{ - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - if (allow_no_date_set) { - gtk_widget_show (dedit->priv->none_button); - } else { - gtk_widget_hide (dedit->priv->none_button); - - /* If the date is showing, we make sure it isn't 'None' (we - don't really mind if the time is empty), else if just the - time is showing we make sure it isn't 'None'. */ - if (dedit->priv->show_date) { - if (dedit->priv->date_set_to_none) - e_date_edit_set_time (dedit, 0); - } else { - if (dedit->priv->time_set_to_none) - e_date_edit_set_time (dedit, 0); - } - } -} - - -/* The range of time to show in the time combo popup. */ -void -e_date_edit_get_time_popup_range (EDateEdit *dedit, - gint *lower_hour, - gint *upper_hour) -{ - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - *lower_hour = dedit->priv->lower_hour; - *upper_hour = dedit->priv->upper_hour; -} - - -void -e_date_edit_set_time_popup_range (EDateEdit *dedit, - gint lower_hour, - gint upper_hour) -{ - EDateEditPrivate *priv; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - if (priv->lower_hour == lower_hour - && priv->upper_hour == upper_hour) - return; - - priv->lower_hour = lower_hour; - priv->upper_hour = upper_hour; - - rebuild_time_popup (dedit); - - /* Setting the combo list items seems to mess up the time entry, so - we set it again. We have to reset it to its last valid time. */ - priv->time_is_valid = TRUE; - e_date_edit_update_time_entry (dedit); -} - - -/* The arrow button beside the date field has been clicked, so we show the - popup with the ECalendar in. */ -static void -on_date_button_clicked (GtkWidget *widget, - EDateEdit *dedit) -{ - e_date_edit_show_date_popup (dedit); -} - - -static void -e_date_edit_show_date_popup (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - ECalendar *calendar; - struct tm mtm; - const gchar *date_text; - GDate selected_day; - gboolean clear_selection = FALSE; - - priv = dedit->priv; - calendar = E_CALENDAR (priv->calendar); - - date_text = gtk_entry_get_text (GTK_ENTRY (priv->date_entry)); - if (field_set_to_none (date_text) - || !e_date_edit_parse_date (dedit, date_text, &mtm)) - clear_selection = TRUE; - - if (clear_selection) { - e_calendar_item_set_selection (calendar->calitem, NULL, NULL); - } else { - g_date_clear (&selected_day, 1); - g_date_set_dmy (&selected_day, mtm.tm_mday, mtm.tm_mon + 1, - mtm.tm_year + 1900); - e_calendar_item_set_selection (calendar->calitem, - &selected_day, NULL); - } - - /* FIXME: Hack. Change ECalendarItem so it doesn't queue signal - emissions. */ - calendar->calitem->selection_changed = FALSE; - - position_date_popup (dedit); - gtk_widget_show (priv->cal_popup); - gtk_widget_grab_focus (priv->cal_popup); - gtk_grab_add (priv->cal_popup); - gdk_pointer_grab (priv->cal_popup->window, TRUE, - (GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK), - NULL, NULL, GDK_CURRENT_TIME); - gdk_window_focus (priv->cal_popup->window, GDK_CURRENT_TIME); -} - - -/* This positions the date popup below and to the left of the arrow button, - just before it is shown. */ -static void -position_date_popup (EDateEdit *dedit) -{ - gint x, y; - gint win_x, win_y; - gint bwidth, bheight; - GtkRequisition cal_req, button_req; - gint screen_width, screen_height; - - gtk_widget_size_request (dedit->priv->cal_popup, &cal_req); - - gtk_widget_size_request (dedit->priv->date_button, &button_req); - bwidth = button_req.width; - gtk_widget_size_request (gtk_widget_get_parent (dedit->priv->date_button), &button_req); - bheight = button_req.height; - - gtk_widget_translate_coordinates (dedit->priv->date_button, - gtk_widget_get_toplevel (dedit->priv->date_button), - bwidth - cal_req.width, bheight, - &x, &y); - - gdk_window_get_origin (gtk_widget_get_toplevel (dedit->priv->date_button)->window, - &win_x, &win_y); - - x += win_x; - y += win_y; - - screen_width = gdk_screen_width (); - screen_height = gdk_screen_height (); - - x = CLAMP (x, 0, MAX (0, screen_width - cal_req.width)); - y = CLAMP (y, 0, MAX (0, screen_height - cal_req.height)); - - gtk_widget_set_uposition (dedit->priv->cal_popup, x, y); -} - - -/* A date has been selected in the date popup, so we set the date field - and hide the popup. */ -static void -on_date_popup_date_selected (ECalendarItem *calitem, - EDateEdit *dedit) -{ - EDateEditPrivate *priv; - GDate start_date, end_date; - - priv = dedit->priv; - - hide_date_popup (dedit); - - if (!e_calendar_item_get_selection (calitem, &start_date, &end_date)) - return; - - e_date_edit_set_date (dedit, g_date_get_year (&start_date), - g_date_get_month (&start_date), - g_date_get_day (&start_date)); -} - - -static void -on_date_popup_now_button_clicked (GtkWidget *button, - EDateEdit *dedit) -{ - hide_date_popup (dedit); - e_date_edit_set_time (dedit, 0); -} - - -static void -on_date_popup_today_button_clicked (GtkWidget *button, - EDateEdit *dedit) -{ - EDateEditPrivate *priv; - struct tm tmp_tm; - time_t t; - - priv = dedit->priv; - - hide_date_popup (dedit); - - if (priv->time_callback) { - tmp_tm = (*priv->time_callback) (dedit, priv->time_callback_data); - } else { - t = time (NULL); - tmp_tm = *localtime (&t); - } - - e_date_edit_set_date (dedit, tmp_tm.tm_year + 1900, - tmp_tm.tm_mon + 1, tmp_tm.tm_mday); -} - - -static void -on_date_popup_none_button_clicked (GtkWidget *button, - EDateEdit *dedit) -{ - hide_date_popup (dedit); - e_date_edit_set_time (dedit, -1); -} - - -/* A key has been pressed while the date popup is showing. If it is the Escape - key we hide the popup. */ -static gint -on_date_popup_key_press (GtkWidget *widget, - GdkEventKey *event, - EDateEdit *dedit) -{ - if (event->keyval != GDK_Escape) - return FALSE; - - g_signal_stop_emission_by_name (widget, "key_press_event"); - hide_date_popup (dedit); - - return TRUE; -} - - -/* A mouse button has been pressed while the date popup is showing. - Any button press events used to select days etc. in the popup will have - have been handled elsewhere, so here we just hide the popup. - (This function is yanked from gtkcombo.c) */ -static gint -on_date_popup_button_press (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - EDateEdit *dedit; - GtkWidget *child; - - dedit = data; - - child = gtk_get_event_widget ((GdkEvent *) event); - - /* We don't ask for button press events on the grab widget, so - * if an event is reported directly to the grab widget, it must - * be on a window outside the application (and thus we remove - * the popup window). Otherwise, we check if the widget is a child - * of the grab widget, and only remove the popup window if it - * is not. - */ - if (child != widget) { - while (child) { - if (child == widget) - return FALSE; - child = child->parent; - } - } - - hide_date_popup (dedit); - - return TRUE; -} - - -/* A delete event has been received for the date popup, so we hide it and - return TRUE so it doesn't get destroyed. */ -static gint -on_date_popup_delete_event (GtkWidget *widget, - EDateEdit *dedit) -{ - hide_date_popup (dedit); - return TRUE; -} - - -/* Hides the date popup, removing any grabs. */ -static void -hide_date_popup (EDateEdit *dedit) -{ - gtk_widget_hide (dedit->priv->cal_popup); - gtk_grab_remove (dedit->priv->cal_popup); - gdk_pointer_ungrab (GDK_CURRENT_TIME); -} - - -/* Clears the time popup and rebuilds it using the lower_hour, upper_hour - and use_24_hour_format settings. */ -static void -rebuild_time_popup (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - GtkList *list; - GtkWidget *listitem, *label; - char buffer[40], *format; - struct tm tmp_tm; - gint hour, min; - - priv = dedit->priv; - - list = GTK_LIST (GTK_COMBO (priv->time_combo)->list); - - gtk_list_clear_items (list, 0, -1); - - /* Fill the struct tm with some sane values. */ - tmp_tm.tm_year = 2000; - tmp_tm.tm_mon = 0; - tmp_tm.tm_mday = 1; - tmp_tm.tm_sec = 0; - tmp_tm.tm_isdst = 0; - - for (hour = priv->lower_hour; hour <= priv->upper_hour; hour++) { - - /* We don't want to display midnight at the end, since that is - really in the next day. */ - if (hour == 24) - break; - - /* We want to finish on upper_hour, with min == 0. */ - for (min = 0; - min == 0 || (min < 60 && hour != priv->upper_hour); - min += 30) { - tmp_tm.tm_hour = hour; - tmp_tm.tm_min = min; - - if (priv->use_24_hour_format) - /* This is a strftime() format. %H = hour (0-23), %M = minute. */ - format = _("%H:%M"); - else - /* This is a strftime() format. %I = hour (1-12), %M = minute, %p = am/pm string. */ - format = _("%I:%M %p"); - - e_utf8_strftime (buffer, sizeof (buffer), format, &tmp_tm); - - /* For 12-hour am/pm format, we want space padding, not zero padding. This - * can be done with strftime's %l, but it's a potentially unportable extension. */ - if (!priv->use_24_hour_format && buffer [0] == '0') - buffer [0] = ' '; - - /* We need to make sure labels are right-aligned, since we want digits to line up, - * and with a nonproportional font, the width of a space != width of a digit. - * Technically, only 12-hour format needs this, but we do it always, for consistency. */ - listitem = gtk_list_item_new (); - label = gtk_label_new (buffer); - gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); - gtk_container_add (GTK_CONTAINER (listitem), label); - - gtk_widget_show_all (listitem); - gtk_container_add (GTK_CONTAINER (list), listitem); - } - } -} - - -static gboolean -e_date_edit_parse_date (EDateEdit *dedit, - const gchar *date_text, - struct tm *date_tm) -{ - if (e_time_parse_date (date_text, date_tm) != E_TIME_PARSE_OK) - return FALSE; - - return TRUE; -} - - -static gboolean -e_date_edit_parse_time (EDateEdit *dedit, - const gchar *time_text, - struct tm *time_tm) -{ - if (field_set_to_none (time_text)) { - time_tm->tm_hour = 0; - time_tm->tm_min = 0; - return TRUE; - } - - if (e_time_parse_time (time_text, time_tm) != E_TIME_PARSE_OK) - return FALSE; - - return TRUE; -} - - -/* Returns TRUE if the string is empty or is "None" in the current locale. - It ignores whitespace. */ -static gboolean -field_set_to_none (const char *text) -{ - const char *pos; - const char *none_string; - - pos = text; - while (isspace (*pos)) - pos++; - - none_string = _("None"); - - if (*pos == '\0' || !strncmp (pos, none_string, strlen (none_string))) - return TRUE; - return FALSE; -} - - -static void -on_date_edit_time_selected (GtkList *list, - EDateEdit *dedit) -{ - GtkWidget *toplevel; - - /* We only want to emit signals when an item is selected explicitly, - not when it is selected by the silly combo update thing. */ - if (!list->selection) - return; - - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (list)); - if (!GTK_WIDGET_MAPPED (toplevel)) - return; - - e_date_edit_check_time_changed (dedit); -} - - -static gint -on_date_entry_key_press (GtkWidget *widget, - GdkEventKey *event, - EDateEdit *dedit) -{ - if (event->state & GDK_MOD1_MASK - && (event->keyval == GDK_Up || event->keyval == GDK_Down - || event->keyval == GDK_Return)) { - g_signal_stop_emission_by_name (widget, - "key_press_event"); - e_date_edit_show_date_popup (dedit); - return TRUE; - } - - /* If the user hits the return key emit a "date_changed" signal if - needed. But let the signal carry on. */ - if (event->keyval == GDK_Return) { - e_date_edit_check_date_changed (dedit); - return FALSE; - } - - return FALSE; -} - - -static gint -on_time_entry_key_press (GtkWidget *widget, - GdkEventKey *event, - EDateEdit *dedit) -{ - /* I'd like to use Alt+Up/Down for popping up the list, like Win32, - but the combo steals any Up/Down keys, so we use Alt+Return. */ -#if 0 - if (event->state & GDK_MOD1_MASK - && (event->keyval == GDK_Up || event->keyval == GDK_Down)) { -#else - if (event->state & GDK_MOD1_MASK && event->keyval == GDK_Return) { -#endif - g_signal_stop_emission_by_name (widget, - "key_press_event"); - g_signal_emit_by_name (GTK_COMBO (dedit->priv->time_combo)->entry, "activate", 0); - return TRUE; - } - - /* Stop the return key from emitting the activate signal, and check - if we need to emit a "time_changed" signal. */ - if (event->keyval == GDK_Return) { - g_signal_stop_emission_by_name (widget, - "key_press_event"); - e_date_edit_check_time_changed (dedit); - return TRUE; - } - - return FALSE; -} - - -static gint -on_date_entry_focus_out (GtkEntry *entry, - GdkEventFocus *event, - EDateEdit *dedit) -{ - e_date_edit_check_date_changed (dedit); - return FALSE; -} - - -static gint -on_time_entry_focus_out (GtkEntry *entry, - GdkEventFocus *event, - EDateEdit *dedit) -{ - e_date_edit_check_time_changed (dedit); - return FALSE; -} - - -/* This sets the text in the date entry according to the current settings. */ -static void -e_date_edit_update_date_entry (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - char buffer[40]; - struct tm tmp_tm = { 0 }; - - priv = dedit->priv; - - if (priv->date_set_to_none || !priv->date_is_valid) { - gtk_entry_set_text (GTK_ENTRY (priv->date_entry), _("None")); - } else { - tmp_tm.tm_year = priv->year; - tmp_tm.tm_mon = priv->month; - tmp_tm.tm_mday = priv->day; - tmp_tm.tm_isdst = -1; - - /* This is a strftime() format for a short date. %m = month, - %d = day of month, %Y = year (all digits). */ - e_utf8_strftime (buffer, sizeof (buffer), _("%m/%d/%Y"), &tmp_tm); - gtk_entry_set_text (GTK_ENTRY (priv->date_entry), buffer); - } -} - - -/* This sets the text in the time entry according to the current settings. */ -static void -e_date_edit_update_time_entry (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - char buffer[40], *format; - struct tm tmp_tm = { 0 }; - - priv = dedit->priv; - - if (priv->time_set_to_none || !priv->time_is_valid) { - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->time_combo)->entry), ""); - } else { - /* Set these to reasonable values just in case. */ - tmp_tm.tm_year = 2000; - tmp_tm.tm_mon = 0; - tmp_tm.tm_mday = 1; - - tmp_tm.tm_hour = priv->hour; - tmp_tm.tm_min = priv->minute; - - tmp_tm.tm_sec = 0; - tmp_tm.tm_isdst = -1; - - if (priv->use_24_hour_format) - /* This is a strftime() format. %H = hour (0-23), %M = minute. */ - format = _("%H:%M"); - else - /* This is a strftime() format. %I = hour (1-12), %M = minute, %p = am/pm string. */ - format = _("%I:%M %p"); - - e_utf8_strftime (buffer, sizeof (buffer), format, &tmp_tm); - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->time_combo)->entry), - buffer); - } -} - - -static void -e_date_edit_update_time_combo_state (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - gboolean show = TRUE, show_now_button = TRUE; - gboolean clear_entry = FALSE, sensitive = TRUE; - const gchar *text; - - priv = dedit->priv; - - /* If the date entry is currently shown, and it is set to None, - clear the time entry and disable the time combo. */ - if (priv->show_date && priv->date_set_to_none) { - clear_entry = TRUE; - sensitive = FALSE; - } - - if (!priv->show_time) { - if (priv->make_time_insensitive) { - clear_entry = TRUE; - sensitive = FALSE; - } else { - show = FALSE; - } - - show_now_button = FALSE; - } - - if (clear_entry) { - /* Only clear it if it isn't empty already. */ - text = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (priv->time_combo)->entry)); - if (text[0]) - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (priv->time_combo)->entry), ""); - } - - gtk_widget_set_sensitive (priv->time_combo, sensitive); - - if (show) - gtk_widget_show (priv->time_combo); - else - gtk_widget_hide (priv->time_combo); - - if (show_now_button) - gtk_widget_show (priv->now_button); - else - gtk_widget_hide (priv->now_button); - - if (priv->show_date - && (priv->show_time || priv->make_time_insensitive)) - gtk_widget_show (priv->space); - else - gtk_widget_hide (priv->space); -} - - -/* Parses the date, and if it is different from the current settings it - updates the settings and emits a "date_changed" signal. */ -static void -e_date_edit_check_date_changed (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - const gchar *date_text; - struct tm tmp_tm; - gboolean none = FALSE, valid = TRUE, date_changed = FALSE; - - priv = dedit->priv; - - tmp_tm.tm_year = 0; - tmp_tm.tm_mon = 0; - tmp_tm.tm_mday = 0; - - date_text = gtk_entry_get_text (GTK_ENTRY (priv->date_entry)); - if (field_set_to_none (date_text)) { - none = TRUE; - } else if (!e_date_edit_parse_date (dedit, date_text, &tmp_tm)) { - valid = FALSE; - tmp_tm.tm_year = 0; - tmp_tm.tm_mon = 0; - tmp_tm.tm_mday = 0; - } - - - date_changed = e_date_edit_set_date_internal (dedit, valid, none, - tmp_tm.tm_year, - tmp_tm.tm_mon, - tmp_tm.tm_mday); - - if (date_changed) - g_signal_emit (dedit, - date_edit_signals [CHANGED], 0); -} - - -/* Parses the time, and if it is different from the current settings it - updates the settings and emits a "time_changed" signal. */ -static void -e_date_edit_check_time_changed (EDateEdit *dedit) -{ - EDateEditPrivate *priv; - const gchar *time_text; - struct tm tmp_tm; - gboolean none = FALSE, valid = TRUE, time_changed; - - priv = dedit->priv; - - tmp_tm.tm_hour = 0; - tmp_tm.tm_min = 0; - - time_text = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (priv->time_combo)->entry)); - if (field_set_to_none (time_text)) - none = TRUE; - else if (!e_date_edit_parse_time (dedit, time_text, &tmp_tm)) - valid = FALSE; - - time_changed = e_date_edit_set_time_internal (dedit, valid, none, - tmp_tm.tm_hour, - tmp_tm.tm_min); - - if (time_changed) - g_signal_emit (dedit, - date_edit_signals [CHANGED], 0); -} - - -/** - * e_date_edit_date_is_valid: - * @dedit: an #EDateEdit widget. - * @Returns: TRUE if the last date entered was valid. - * - * Returns TRUE if the last date entered was valid. - * - * Note that if this returns FALSE, you can still use e_date_edit_get_time() - * or e_date_edit_get_date() to get the last time or date entered which was - * valid. - */ -gboolean -e_date_edit_date_is_valid (EDateEdit *dedit) -{ - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE); - - if (!dedit->priv->date_is_valid) - return FALSE; - - /* If the date is empty/None and that isn't permitted, return FALSE. */ - if (dedit->priv->date_set_to_none - && !e_date_edit_get_allow_no_date_set (dedit)) - return FALSE; - - return TRUE; -} - - -/** - * e_date_edit_time_is_valid: - * @dedit: an #EDateEdit widget. - * @Returns: TRUE if the last time entered was valid. - * - * Returns TRUE if the last time entered was valid. - * - * Note that if this returns FALSE, you can still use e_date_edit_get_time() - * or e_date_edit_get_time_of_day() to get the last time or time of the day - * entered which was valid. - */ -gboolean -e_date_edit_time_is_valid (EDateEdit *dedit) -{ - g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE); - - if (!dedit->priv->time_is_valid) - return FALSE; - - /* If the time is empty and that isn't permitted, return FALSE. - Note that we don't mind an empty time if the date field is shown - - in that case we just assume 0:00. */ - if (dedit->priv->time_set_to_none && !dedit->priv->show_date - && !e_date_edit_get_allow_no_date_set (dedit)) - return FALSE; - - return TRUE; -} - - -static gboolean -e_date_edit_set_date_internal (EDateEdit *dedit, - gboolean valid, - gboolean none, - gint year, - gint month, - gint day) -{ - EDateEditPrivate *priv; - gboolean date_changed = FALSE; - - priv = dedit->priv; - - if (!valid) { - /* Date is invalid. */ - if (priv->date_is_valid) { - priv->date_is_valid = FALSE; - date_changed = TRUE; - } - } else if (none) { - /* Date has been set to 'None'. */ - if (!priv->date_is_valid - || !priv->date_set_to_none) { - priv->date_is_valid = TRUE; - priv->date_set_to_none = TRUE; - date_changed = TRUE; - } - } else { - /* Date has been set to a specific date. */ - if (!priv->date_is_valid - || priv->date_set_to_none - || priv->year != year - || priv->month != month - || priv->day != day) { - priv->date_is_valid = TRUE; - priv->date_set_to_none = FALSE; - priv->year = year; - priv->month = month; - priv->day = day; - date_changed = TRUE; - } - } - - return date_changed; -} - - -static gboolean -e_date_edit_set_time_internal (EDateEdit *dedit, - gboolean valid, - gboolean none, - gint hour, - gint minute) -{ - EDateEditPrivate *priv; - gboolean time_changed = FALSE; - - priv = dedit->priv; - - if (!valid) { - /* Time is invalid. */ - if (priv->time_is_valid) { - priv->time_is_valid = FALSE; - time_changed = TRUE; - } - } else if (none) { - /* Time has been set to empty/'None'. */ - if (!priv->time_is_valid - || !priv->time_set_to_none) { - priv->time_is_valid = TRUE; - priv->time_set_to_none = TRUE; - time_changed = TRUE; - } - } else { - /* Time has been set to a specific time. */ - if (!priv->time_is_valid - || priv->time_set_to_none - || priv->hour != hour - || priv->minute != minute) { - priv->time_is_valid = TRUE; - priv->time_set_to_none = FALSE; - priv->hour = hour; - priv->minute = minute; - time_changed = TRUE; - } - } - - return time_changed; -} - - -/* Sets a callback to use to get the current time. This is useful if the - application needs to use its own timezone data rather than rely on the - Unix timezone. */ -void -e_date_edit_set_get_time_callback (EDateEdit *dedit, - EDateEditGetTimeCallback cb, - gpointer data, - GtkDestroyNotify destroy) -{ - EDateEditPrivate *priv; - - g_return_if_fail (E_IS_DATE_EDIT (dedit)); - - priv = dedit->priv; - - if (priv->time_callback_data && priv->time_callback_destroy) - (*priv->time_callback_destroy) (priv->time_callback_data); - - priv->time_callback = cb; - priv->time_callback_data = data; - priv->time_callback_destroy = destroy; - -} - diff --git a/widgets/misc/e-dateedit.h b/widgets/misc/e-dateedit.h deleted file mode 100644 index 1fa14b95c8..0000000000 --- a/widgets/misc/e-dateedit.h +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * - * Based on the GnomeDateEdit, part of the Gnome Library. - * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * EDateEdit - a widget based on GnomeDateEdit to provide a date & optional - * time field with popups for entering a date. - * - * It emits a "changed" signal when the date and/or time has changed. - * You can check if the last date or time entered was invalid by - * calling e_date_edit_date_is_valid() and e_date_edit_time_is_valid(). - * - * Note that when the user types in a date or time, it will only emit the - * signals when the user presses the return key or switches the keyboard - * focus to another widget, or you call one of the _get_time/date functions. - */ - -#ifndef __E_DATE_EDIT_H_ -#define __E_DATE_EDIT_H_ - -#include <time.h> -#include <glib.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkwidget.h> - -#define E_TYPE_DATE_EDIT (e_date_edit_get_type ()) -#define E_DATE_EDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_DATE_EDIT, EDateEdit)) -#define E_DATE_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_DATE_EDIT, EDateEditClass)) -#define E_IS_DATE_EDIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_DATE_EDIT)) -#define E_IS_DATE_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_DATE_EDIT)) - -typedef struct _EDateEdit EDateEdit; -typedef struct _EDateEditPrivate EDateEditPrivate; -typedef struct _EDateEditClass EDateEditClass; - -/* The type of the callback function optionally used to get the current time. - */ -typedef struct tm (*EDateEditGetTimeCallback) (EDateEdit *dedit, - gpointer data); - -struct _EDateEdit { - GtkHBox hbox; - - /*< private >*/ - EDateEditPrivate *priv; -}; - -struct _EDateEditClass { - GtkHBoxClass parent_class; - - void (* changed) (EDateEdit *dedit); -}; - -GType e_date_edit_get_type (void); -GtkWidget* e_date_edit_new (void); - -/* Analogous to gtk_entry_set_editable. disable editing, while still - allowing selection. */ -void e_date_edit_set_editable (EDateEdit *dedit, gboolean editable); - -/* Returns TRUE if the last date and time set were valid. The date and time - are only set when the user hits Return or switches keyboard focus, or - selects a date or time from the popup. */ -gboolean e_date_edit_date_is_valid (EDateEdit *dedit); -gboolean e_date_edit_time_is_valid (EDateEdit *dedit); - -/* Returns the last valid date & time set, or -1 if the date & time was set to - 'None' and this is permitted via e_date_edit_set_allow_no_date_set. */ -time_t e_date_edit_get_time (EDateEdit *dedit); -void e_date_edit_set_time (EDateEdit *dedit, - time_t the_time); - -/* This returns the last valid date set, without the time. It returns TRUE - if a date is set, or FALSE if the date is set to 'None' and this is - permitted via e_date_edit_set_allow_no_date_set. (Month is 1 - 12). */ -gboolean e_date_edit_get_date (EDateEdit *dedit, - gint *year, - gint *month, - gint *day); -void e_date_edit_set_date (EDateEdit *dedit, - gint year, - gint month, - gint day); - -/* This returns the last valid time set, without the date. It returns TRUE - if a time is set, or FALSE if the time is set to 'None' and this is - permitted via e_date_edit_set_allow_no_date_set. */ -gboolean e_date_edit_get_time_of_day (EDateEdit *dedit, - gint *hour, - gint *minute); -/* Set the time. Pass -1 as hour to set to empty. */ -void e_date_edit_set_time_of_day (EDateEdit *dedit, - gint hour, - gint minute); - -void e_date_edit_set_date_and_time_of_day (EDateEdit *dedit, - gint year, - gint month, - gint day, - gint hour, - gint minute); - -/* Whether we show the date field. */ -gboolean e_date_edit_get_show_date (EDateEdit *dedit); -void e_date_edit_set_show_date (EDateEdit *dedit, - gboolean show_date); - -/* Whether we show the time field. */ -gboolean e_date_edit_get_show_time (EDateEdit *dedit); -void e_date_edit_set_show_time (EDateEdit *dedit, - gboolean show_time); - -/* The week start day, used in the date popup. 0 (Mon) to 6 (Sun). */ -gint e_date_edit_get_week_start_day (EDateEdit *dedit); -void e_date_edit_set_week_start_day (EDateEdit *dedit, - gint week_start_day); - -/* Whether we show week numbers in the date popup. */ -gboolean e_date_edit_get_show_week_numbers (EDateEdit *dedit); -void e_date_edit_set_show_week_numbers (EDateEdit *dedit, - gboolean show_week_numbers); - -/* Whether we use 24 hour format in the time field & popup. */ -gboolean e_date_edit_get_use_24_hour_format (EDateEdit *dedit); -void e_date_edit_set_use_24_hour_format (EDateEdit *dedit, - gboolean use_24_hour_format); - -/* Whether we allow the date to be set to 'None'. e_date_edit_get_time() will - return (time_t) -1 in this case. */ -gboolean e_date_edit_get_allow_no_date_set (EDateEdit *dedit); -void e_date_edit_set_allow_no_date_set (EDateEdit *dedit, - gboolean allow_no_date_set); - -/* The range of time to show in the time combo popup. */ -void e_date_edit_get_time_popup_range (EDateEdit *dedit, - gint *lower_hour, - gint *upper_hour); -void e_date_edit_set_time_popup_range (EDateEdit *dedit, - gint lower_hour, - gint upper_hour); - -/* Whether the time field is made insensitive rather than hiding it. */ -gboolean e_date_edit_get_make_time_insensitive(EDateEdit *dedit); -void e_date_edit_set_make_time_insensitive(EDateEdit *dedit, - gboolean make_insensitive); - - -/* Sets a callback to use to get the current time. This is useful if the - application needs to use its own timezone data rather than rely on the - Unix timezone. */ -void e_date_edit_set_get_time_callback (EDateEdit *dedit, - EDateEditGetTimeCallback cb, - gpointer data, - GtkDestroyNotify destroy); - -#endif diff --git a/widgets/misc/e-dropdown-button.c b/widgets/misc/e-dropdown-button.c deleted file mode 100644 index 4a0327e7be..0000000000 --- a/widgets/misc/e-dropdown-button.c +++ /dev/null @@ -1,249 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-dropdown-menu.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - * Damon Chaplin <damon@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-dropdown-button.h" - - -#include <stdio.h> -#include <gtk/gtkarrow.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkwidget.h> -#include <libgnomeui/gnome-popup-menu.h> -#include <gal/util/e-util.h> - - -struct _EDropdownButtonPrivate { - GtkAccelGroup *accel_group; - GtkWidget *menu; -}; - -#define PARENT_TYPE gtk_toggle_button_get_type () -static GtkToggleButtonClass *parent_class = NULL; - - -/* Callback to position the pop-up menu. */ - -static void -menu_position_cb (GtkMenu *menu, - int *x, - int *y, - gboolean *push_in, - void *data) -{ - EDropdownButton *dropdown_button; - EDropdownButtonPrivate *priv; - GtkRequisition menu_requisition; - int max_x, max_y; - - dropdown_button = E_DROPDOWN_BUTTON (data); - priv = dropdown_button->priv; - - /* Calculate our preferred position. */ - gdk_window_get_origin (GTK_WIDGET (dropdown_button)->window, x, y); - *y += GTK_WIDGET (dropdown_button)->allocation.height; - - /* Now make sure we are on the screen. */ - gtk_widget_size_request (GTK_WIDGET (priv->menu), &menu_requisition); - max_x = MAX (0, gdk_screen_width () - menu_requisition.width); - max_y = MAX (0, gdk_screen_height () - menu_requisition.height); - - *x = CLAMP (*x, 0, max_x); - *y = CLAMP (*y, 0, max_y); -} - -/* Callback for the "deactivate" signal on the pop-up menu. This is used so - that we unset the state of the toggle button when the pop-up menu - disappears. */ - -static int -menu_deactivate_cb (GtkMenuShell *menu_shell, - void *data) -{ - EDropdownButton *dropdown_button; - - dropdown_button = E_DROPDOWN_BUTTON (data); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dropdown_button), FALSE); - return TRUE; -} - - -/* GtkObject methods. */ - -static void -impl_destroy (GtkObject *object) -{ - EDropdownButton *dropdown_button; - EDropdownButtonPrivate *priv; - - dropdown_button = E_DROPDOWN_BUTTON (object); - priv = dropdown_button->priv; - - gtk_accel_group_unref (priv->accel_group); - gtk_widget_destroy (priv->menu); - - g_free (priv); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -/* GtkWidget methods. */ - -static void -impl_toggled (GtkToggleButton *toggle_button) -{ - EDropdownButton *dropdown_button; - EDropdownButtonPrivate *priv; - - if (parent_class->toggled) - parent_class->toggled (toggle_button); - - dropdown_button = E_DROPDOWN_BUTTON (toggle_button); - priv = dropdown_button->priv; - - if (toggle_button->active) { - gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, - menu_position_cb, dropdown_button, - 1, GDK_CURRENT_TIME); - } else { - gtk_menu_popdown (GTK_MENU (priv->menu)); - } -} - - -static void -class_init (EDropdownButtonClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkToggleButtonClass *toggle_class; - - object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - toggle_class = GTK_TOGGLE_BUTTON_CLASS (klass); - - object_class->destroy = impl_destroy; - toggle_class->toggled = impl_toggled; - - parent_class = g_type_class_ref(PARENT_TYPE); -} - - -static void -init (EDropdownButton *dropdown_button) -{ - EDropdownButtonPrivate *priv; - - priv = g_new (EDropdownButtonPrivate, 1); - priv->accel_group = gtk_accel_group_new (); - priv->menu = NULL; - - dropdown_button->priv = priv; -} - - -/** - * e_dropdown_button_construct: - * @dropdown_button: A pointer to an %EDropdownButton object - * @label_text: Text to display in the button - * @menu: The menu to pop up when the button is pressed - * - * Construct the @dropdown_button with the specified @label_text and the - * associated @menu. - **/ -void -e_dropdown_button_construct (EDropdownButton *dropdown_button, - const char *label_text, - GtkMenu *menu) -{ - EDropdownButtonPrivate *priv; - GtkWidget *hbox; - GtkWidget *arrow; - GtkWidget *label; - unsigned int accel_key; - - g_return_if_fail (dropdown_button != NULL); - g_return_if_fail (E_IS_DROPDOWN_BUTTON (dropdown_button)); - g_return_if_fail (label_text != NULL); - g_return_if_fail (menu != NULL); - g_return_if_fail (GTK_IS_MENU (menu)); - - priv = dropdown_button->priv; - - hbox = gtk_hbox_new (FALSE, 2); - gtk_container_add (GTK_CONTAINER (dropdown_button), hbox); - gtk_widget_show (hbox); - - label = gtk_label_new (""); - accel_key = gtk_label_parse_uline (GTK_LABEL (label), label_text); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - gtk_widget_show (label); - gtk_widget_add_accelerator (GTK_WIDGET (dropdown_button), "clicked", - priv->accel_group, accel_key, GDK_MOD1_MASK, 0); - - arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 2); - gtk_widget_show (arrow); - - priv->menu = GTK_WIDGET (menu); - - gtk_signal_connect_while_alive (GTK_OBJECT (priv->menu), "deactivate", - G_CALLBACK (menu_deactivate_cb), - dropdown_button, GTK_OBJECT (dropdown_button)); -} - -/** - * e_dropdown_button_new: - * @label_text: Text to display in the button - * @menu: The menu to pop up when the button is pressed - * - * Create a new dropdown button. When the button is clicked, the specified - * @menu will be popped up. - * - * Return value: A pointer to the newly created %EDropdownButton. - **/ -GtkWidget * -e_dropdown_button_new (const char *label_text, - GtkMenu *menu) -{ - GtkWidget *widget; - - g_return_val_if_fail (label_text != NULL, NULL); - g_return_val_if_fail (menu != NULL, NULL); - g_return_val_if_fail (GTK_IS_MENU (menu), NULL); - - widget = gtk_type_new (e_dropdown_button_get_type ()); - - e_dropdown_button_construct (E_DROPDOWN_BUTTON (widget), label_text, menu); - return widget; -} - - -E_MAKE_TYPE (e_dropdown_button, "EDropdownButton", EDropdownButton, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-dropdown-button.h b/widgets/misc/e-dropdown-button.h deleted file mode 100644 index f0e6257b0f..0000000000 --- a/widgets/misc/e-dropdown-button.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-dropdown-menu.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -#ifndef _E_DROPDOWN_BUTTON_H_ -#define _E_DROPDOWN_BUTTON_H_ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtktogglebutton.h> -#include <gtk/gtkmenu.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_DROPDOWN_BUTTON (e_dropdown_button_get_type ()) -#define E_DROPDOWN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_DROPDOWN_BUTTON, EDropdownButton)) -#define E_DROPDOWN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_DROPDOWN_BUTTON, EDropdownButtonClass)) -#define E_IS_DROPDOWN_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_DROPDOWN_BUTTON)) -#define E_IS_DROPDOWN_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_DROPDOWN_BUTTON)) - - -typedef struct _EDropdownButton EDropdownButton; -typedef struct _EDropdownButtonPrivate EDropdownButtonPrivate; -typedef struct _EDropdownButtonClass EDropdownButtonClass; - -struct _EDropdownButton { - GtkToggleButton parent; - - EDropdownButtonPrivate *priv; -}; - -struct _EDropdownButtonClass { - GtkToggleButtonClass parent_class; -}; - - -GtkType e_dropdown_button_get_type (void); -void e_dropdown_button_construct (EDropdownButton *dropdown_button, - const char *label_text, - GtkMenu *menu); -GtkWidget *e_dropdown_button_new (const char *label_text, - GtkMenu *menu); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_DROPDOWN_BUTTON_H_ */ diff --git a/widgets/misc/e-error.c b/widgets/misc/e-error.c deleted file mode 100644 index 1975be9c60..0000000000 --- a/widgets/misc/e-error.c +++ /dev/null @@ -1,607 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell Inc. (www.novell.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <sys/types.h> -#include <dirent.h> - -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -#include <glib.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkimage.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-url.h> - -#include "e-error.h" - -#define d(x) x - -struct _e_error_button { - struct _e_error_button *next; - char *stock; - char *label; - int response; -}; - -struct _e_error { - guint32 flags; - char *id; - int type; - int default_response; - char *title; - char *primary; - char *secondary; - char *help_uri; - struct _e_error_button *buttons; -}; - -struct _e_error_table { - char *domain; - GHashTable *errors; -}; - -static GHashTable *error_table; -static GSList *ee_parent_list; - -/* ********************************************************************** */ - -static struct _e_error_button default_ok_button = { - NULL, "gtk-ok", NULL, GTK_RESPONSE_OK -}; - -static struct _e_error default_errors[] = { - { GTK_DIALOG_MODAL, "error", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", "{1}", NULL, &default_ok_button }, - { GTK_DIALOG_MODAL, "error-primary", 3, GTK_RESPONSE_OK, N_("Evolution Error"), "{0}", NULL, NULL, &default_ok_button }, - { GTK_DIALOG_MODAL, "warning", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", "{1}", NULL, &default_ok_button }, - { GTK_DIALOG_MODAL, "warning-primary", 1, GTK_RESPONSE_OK, N_("Evolution Warning"), "{0}", NULL, NULL, &default_ok_button }, -}; - -/* ********************************************************************** */ - -static struct { - char *name; - int id; -} response_map[] = { - { "GTK_RESPONSE_REJECT", GTK_RESPONSE_REJECT }, - { "GTK_RESPONSE_ACCEPT", GTK_RESPONSE_ACCEPT }, - { "GTK_RESPONSE_OK", GTK_RESPONSE_OK }, - { "GTK_RESPONSE_CANCEL", GTK_RESPONSE_CANCEL }, - { "GTK_RESPONSE_CLOSE", GTK_RESPONSE_CLOSE }, - { "GTK_RESPONSE_YES", GTK_RESPONSE_YES }, - { "GTK_RESPONSE_NO", GTK_RESPONSE_NO }, - { "GTK_RESPONSE_APPLY", GTK_RESPONSE_APPLY }, - { "GTK_RESPONSE_HELP", GTK_RESPONSE_HELP }, -}; - -static int -map_response(const char *name) -{ - int i; - - for (i=0;i<sizeof(response_map)/sizeof(response_map[0]);i++) - if (!strcmp(name, response_map[i].name)) - return response_map[i].id; - - return 0; -} - -static struct { - const char *name; - const char *icon; - const char *title; -} type_map[] = { - { "info", GTK_STOCK_DIALOG_INFO, N_("Evolution Information") }, - { "warning", GTK_STOCK_DIALOG_WARNING, N_("Evolution Warning") }, - { "question", GTK_STOCK_DIALOG_QUESTION, N_("Evolution Query") }, - { "error", GTK_STOCK_DIALOG_ERROR, N_("Evolution Error") }, -}; - -static int -map_type(const char *name) -{ - int i; - - if (name) { - for (i=0;i<sizeof(type_map)/sizeof(type_map[0]);i++) - if (!strcmp(name, type_map[i].name)) - return i; - } - - return 3; -} - -/* - XML format: - - <error id="error-id" type="info|warning|question|error"? response="default_response"? modal="true"? > - <title>Window Title</title>? - <primary>Primary error text.</primary>? - <secondary>Secondary error text.</secondary>? - <help uri="help uri"/> ? - <button stock="stock-button-id"? label="button label"? response="response_id"? /> * - </error> - - The tool e-error-tool is used to extract the translatable strings for - translation. - -*/ -static void -ee_load(const char *path) -{ - xmlDocPtr doc; - xmlNodePtr root, error, scan; - struct _e_error *e; - struct _e_error_button *lastbutton; - struct _e_error_table *table; - char *tmp; - - d(printf("loading error file %s\n", path)); - - doc = xmlParseFile(path); - if (doc == NULL) { - g_warning("Error file '%s' not found", path); - return; - } - - root = xmlDocGetRootElement(doc); - if (root == NULL - || strcmp(root->name, "error-list") != 0 - || (tmp = xmlGetProp(root, "domain")) == NULL) { - g_warning("Error file '%s' invalid format", path); - xmlFreeDoc(doc); - return; - } - - table = g_hash_table_lookup(error_table, tmp); - if (table == NULL) { - table = g_malloc0(sizeof(*table)); - table->domain = g_strdup(tmp); - table->errors = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_insert(error_table, table->domain, table); - } else - g_warning("Error file '%s', domain '%s' already used, merging", path, tmp); - g_free(tmp); - - for (error = root->children;error;error = error->next) { - if (!strcmp(error->name, "error")) { - tmp = xmlGetProp(error, "id"); - if (tmp == NULL) - continue; - - e = g_malloc0(sizeof(*e)); - e->id = g_strdup(tmp); - xmlFree(tmp); - lastbutton = (struct _e_error_button *)&e->buttons; - - tmp = xmlGetProp(error, "modal"); - if (tmp) { - if (!strcmp(tmp, "true")) - e->flags |= GTK_DIALOG_MODAL; - xmlFree(tmp); - } - - tmp = xmlGetProp(error, "type"); - e->type = map_type(tmp); - if (tmp) - xmlFree(tmp); - - tmp = xmlGetProp(error, "default"); - if (tmp) { - e->default_response = map_response(tmp); - xmlFree(tmp); - } - - for (scan = error->children;scan;scan=scan->next) { - if (!strcmp(scan->name, "primary")) { - if ((tmp = xmlNodeGetContent(scan))) { - e->primary = g_strdup(_(tmp)); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "secondary")) { - if ((tmp = xmlNodeGetContent(scan))) { - e->secondary = g_strdup(_(tmp)); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "title")) { - if ((tmp = xmlNodeGetContent(scan))) { - e->title = g_strdup(_(tmp)); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "help")) { - tmp = xmlGetProp(scan, "uri"); - if (tmp) { - e->help_uri = g_strdup(tmp); - xmlFree(tmp); - } - } else if (!strcmp(scan->name, "button")) { - struct _e_error_button *b; - - b = g_malloc0(sizeof(*b)); - tmp = xmlGetProp(scan, "stock"); - if (tmp) { - b->stock = g_strdup(tmp); - xmlFree(tmp); - } - tmp = xmlGetProp(scan, "label"); - if (tmp) { - b->label = g_strdup(_(tmp)); - xmlFree(tmp); - } - tmp = xmlGetProp(scan, "response"); - if (tmp) { - b->response = map_response(tmp); - xmlFree(tmp); - } - - if (b->stock == NULL && b->label == NULL) { - g_warning("Error file '%s': missing button details in error '%s'", path, e->id); - g_free(b->stock); - g_free(b->label); - g_free(b); - } else { - lastbutton->next = b; - lastbutton = b; - } - } - } - - g_hash_table_insert(table->errors, e->id, e); - } - } - - xmlFreeDoc(doc); -} - -static void -ee_load_tables(void) -{ - DIR *dir; - struct dirent *d; - const char *base = EVOLUTION_PRIVDATADIR "/errors"; - struct _e_error_table *table; - int i; - - if (error_table != NULL) - return; - - error_table = g_hash_table_new(g_str_hash, g_str_equal); - - /* setup system error types */ - table = g_malloc0(sizeof(*table)); - table->domain = "builtin"; - table->errors = g_hash_table_new(g_str_hash, g_str_equal); - for (i=0;i<sizeof(default_errors)/sizeof(default_errors[0]);i++) - g_hash_table_insert(table->errors, default_errors[i].id, &default_errors[i]); - g_hash_table_insert(error_table, table->domain, table); - - /* look for installed error tables */ - dir = opendir(base); - if (dir == NULL) - return; - - while ( (d = readdir(dir)) ) { - char *path; - - if (d->d_name[0] == '.') - continue; - - path = g_build_filename(base, d->d_name, NULL); - ee_load(path); - g_free(path); - } - - closedir(dir); -} - -/* unfortunately, gmarkup_escape doesn't expose its gstring based api :( */ -static void -ee_append_text(GString *out, const char *text) -{ - char c; - - while ( (c=*text++) ) { - if (c == '<') - g_string_append(out, "<"); - else if (c == '>') - g_string_append(out, ">"); - else if (c == '"') - g_string_append(out, """); - else if (c == '\'') - g_string_append(out, "'"); - else if (c == '&') - g_string_append(out, "&"); - else - g_string_append_c(out, c); - } -} - -static void -ee_build_label(GString *out, const char *fmt, GPtrArray *args) -{ - const char *end, *newstart; - int id; - - while (fmt - && (newstart = strchr(fmt, '{')) - && (end = strchr(newstart+1, '}'))) { - g_string_append_len(out, fmt, newstart-fmt); - id = atoi(newstart+1); - if (id < args->len) - ee_append_text(out, args->pdata[id]); - else - g_warning("Error references argument %d not supplied by caller", id); - fmt = end+1; - } - - g_string_append(out, fmt); -} - -static void -ee_response(GtkWidget *w, guint button, struct _e_error *e) -{ - GError *err = NULL; - - if (button == GTK_RESPONSE_HELP) { - g_signal_stop_emission_by_name(w, "response"); - gnome_url_show(e->help_uri, &err); - if (err) { - g_warning("Unable to run help uri: %s", err->message); - g_error_free(err); - } - } -} - -GtkWidget * -e_error_newv(GtkWindow *parent, const char *tag, const char *arg0, va_list ap) -{ - struct _e_error_table *table; - struct _e_error *e; - struct _e_error_button *b; - GtkWidget *hbox, *w; - char *tmp, *domain, *id; - GString *out; - GPtrArray *args; - GtkDialog *dialog; - - if (error_table == NULL) - ee_load_tables(); - - dialog = (GtkDialog *)gtk_dialog_new(); - gtk_dialog_set_has_separator(dialog, FALSE); - - gtk_container_set_border_width((GtkContainer *)dialog, 6); - - if (parent == NULL && ee_parent_list) - parent = (GtkWindow *)ee_parent_list->data; - if (parent) - gtk_window_set_transient_for((GtkWindow *)dialog, parent); - else - g_warning("No parent set, or default parent available for error dialog"); - - domain = alloca(strlen(tag)+1); - strcpy(domain, tag); - id = strchr(domain, ':'); - if (id) - *id++ = 0; - - if ( id == NULL - || (table = g_hash_table_lookup(error_table, domain)) == NULL - || (e = g_hash_table_lookup(table->errors, id)) == NULL) { - /* setup a dummy error */ - tmp = g_strdup_printf(_("<span weight=\"bold\">Internal error, unknown error '%s' requested</span>"), tag); - w = gtk_label_new(NULL); - gtk_label_set_selectable((GtkLabel *)w, TRUE); - gtk_label_set_line_wrap((GtkLabel *)w, TRUE); - gtk_label_set_markup((GtkLabel *)w, tmp); - gtk_widget_show(w); - gtk_box_pack_start((GtkBox *)dialog->vbox, w, TRUE, TRUE, 12); - - return (GtkWidget *)dialog; - } - - if (e->flags & GTK_DIALOG_MODAL) - gtk_window_set_modal((GtkWindow *)dialog, TRUE); - gtk_window_set_destroy_with_parent((GtkWindow *)dialog, TRUE); - - if (e->help_uri) { - w = gtk_dialog_add_button(dialog, GTK_STOCK_HELP, GTK_RESPONSE_HELP); - g_signal_connect(dialog, "response", G_CALLBACK(ee_response), e); - } - - b = e->buttons; - if (b == NULL) { - gtk_dialog_add_button(dialog, GTK_STOCK_OK, GTK_RESPONSE_OK); - } else { - for (b = e->buttons;b;b=b->next) { - if (b->stock) { - if (b->label) { - /* FIXME: So although this looks like it will work, it wont. - Need to do it the hard way ... */ - w = gtk_button_new_from_stock(b->stock); - gtk_button_set_label((GtkButton *)w, b->label); - gtk_widget_show(w); - gtk_dialog_add_action_widget(dialog, w, b->response); - } else - gtk_dialog_add_button(dialog, b->stock, b->response); - } else - gtk_dialog_add_button(dialog, b->label, b->response); - } - } - - if (e->default_response) - gtk_dialog_set_default_response(dialog, e->default_response); - - hbox = gtk_hbox_new(FALSE, 0); - gtk_container_set_border_width((GtkContainer *)hbox, 12); - - w = gtk_image_new_from_stock(type_map[e->type].icon, GTK_ICON_SIZE_DIALOG); - gtk_misc_set_alignment((GtkMisc *)w, 0.0, 0.0); - gtk_box_pack_start((GtkBox *)hbox, w, TRUE, TRUE, 12); - - args = g_ptr_array_new(); - tmp = (char *)arg0; - while (tmp) { - g_ptr_array_add(args, tmp); - tmp = va_arg(ap, char *); - } - - out = g_string_new(""); - - if (e->title) { - ee_build_label(out, _(e->title), args); - gtk_window_set_title((GtkWindow *)dialog, out->str); - g_string_truncate(out, 0); - } else - gtk_window_set_title((GtkWindow *)dialog, _(type_map[e->type].title)); - - - if (e->primary) { - g_string_append(out, "<span weight=\"bold\" size=\"larger\">"); - ee_build_label(out, _(e->primary), args); - g_string_append(out, "</span>\n\n"); - } - - if (e->secondary) - ee_build_label(out, _(e->secondary), args); - - g_ptr_array_free(args, TRUE); - - w = gtk_label_new(NULL); - gtk_label_set_selectable((GtkLabel *)w, TRUE); - gtk_label_set_line_wrap((GtkLabel *)w, TRUE); - gtk_label_set_markup((GtkLabel *)w, out->str); - g_string_free(out, TRUE); - gtk_box_pack_start((GtkBox *)hbox, w, FALSE, FALSE, 0); - gtk_widget_show_all(hbox); - - gtk_box_pack_start((GtkBox *)dialog->vbox, hbox, TRUE, TRUE, 0); - - return (GtkWidget *)dialog; -} - -/** - * e_error_new: - * @parent: - * @tag: error identifier - * @arg0: The first argument for the error formatter. The list must - * be NULL terminated. - * - * Creates a new error widget. The @tag argument is used to determine - * which error to use, it is in the format domain:error-id. The NULL - * terminated list of arguments, starting with @arg0 is used to fill - * out the error definition. - * - * Return value: A GtkDialog which can be used for showing an error - * dialog asynchronously. - **/ -struct _GtkWidget * -e_error_new(struct _GtkWindow *parent, const char *tag, const char *arg0, ...) -{ - GtkWidget *w; - va_list ap; - - va_start(ap, arg0); - w = e_error_newv(parent, tag, arg0, ap); - va_end(ap); - - return w; -} - -int -e_error_runv(GtkWindow *parent, const char *tag, const char *arg0, va_list ap) -{ - GtkWidget *w; - int res; - - w = e_error_newv(parent, tag, arg0, ap); - - res = gtk_dialog_run((GtkDialog *)w); - gtk_widget_destroy(w); - - return res; -} - -/** - * e_error_run: - * @parent: - * @tag: - * @arg0: - * - * Sets up, displays, runs and destroys a standard evolution error - * dialog based on @tag, which is in the format domain:error-id. - * - * Return value: The response id of the button pressed. - **/ -int -e_error_run(GtkWindow *parent, const char *tag, const char *arg0, ...) -{ - GtkWidget *w; - va_list ap; - int res; - - va_start(ap, arg0); - w = e_error_newv(parent, tag, arg0, ap); - va_end(ap); - - res = gtk_dialog_run((GtkDialog *)w); - gtk_widget_destroy(w); - - return res; -} - -static void -remove_parent(GtkWidget *w, GtkWidget *parent) -{ - ee_parent_list = g_slist_remove(ee_parent_list, parent); -} - -/** - * e_error_default_parent: - * @parent: - * - * Bit of a hack, set a default parent that will be used to parent any - * error boxes if none is supplied. - * - * This may be called multiple times, and the last call will be the - * main default. This function will keep track of the parents - * destruction state. - **/ -void -e_error_default_parent(struct _GtkWindow *parent) -{ - if (g_slist_find(ee_parent_list, parent) == NULL) { - ee_parent_list = g_slist_prepend(ee_parent_list, parent); - g_signal_connect(parent, "destroy", G_CALLBACK(remove_parent), parent); - } -} - diff --git a/widgets/misc/e-error.h b/widgets/misc/e-error.h deleted file mode 100644 index fe097656ab..0000000000 --- a/widgets/misc/e-error.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell Inc. (www.novell.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _E_ERROR_H -#define _E_ERROR_H - -#include <stdarg.h> - -struct _GtkWindow; - -/* - * Some standard errors, if these are altered or added to, - * update devel-docs/misc/errors.txt - * - * Several more basic ones are needed. - */ - -#define E_ERROR_WARNING "builtin:warning" -#define E_ERROR_WARNING_PRIMARY "builtin:warning-primary" -#define E_ERROR_ERROR "builtin:error" -#define E_ERROR_ERROR_PRIMARY "builtin:error-primary" - -/* takes filename, returns OK if yes */ -#define E_ERROR_ASK_FILE_EXISTS_OVERWRITE "system:ask-save-file-exists-overwrite" -/* takes filename, reason */ -#define E_ERROR_NO_SAVE_FILE "system:no-save-file" -/* takes filename, reason */ -#define E_ERROR_NO_LOAD_FILE "system:no-save-file" - -/* Note that all errors returned are standard GtkDialoge's */ -struct _GtkWidget *e_error_new(struct _GtkWindow *parent, const char *tag, const char *arg0, ...); -struct _GtkWidget *e_error_newv(struct _GtkWindow *parent, const char *tag, const char *arg0, va_list ap); - -int e_error_run(struct _GtkWindow *parent, const char *tag, const char *arg0, ...); -int e_error_runv(struct _GtkWindow *parent, const char *tag, const char *arg0, va_list ap); - -void e_error_default_parent(struct _GtkWindow *parent); - -#endif /* !_E_ERROR_H */ diff --git a/widgets/misc/e-expander.c b/widgets/misc/e-expander.c deleted file mode 100644 index 52a5a833fd..0000000000 --- a/widgets/misc/e-expander.c +++ /dev/null @@ -1,1349 +0,0 @@ -/* GTK - The GIMP Toolkit - * - * Copyright (C) 2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <mark@skynet.ie> - */ - -#include <config.h> - -#include "e-expander.h" - -#include <gtk/gtklabel.h> -#include <gtk/gtkcontainer.h> -#include <gdk/gdkkeysyms.h> - -#define DEFAULT_EXPANDER_SIZE 10 -#define DEFAULT_EXPANDER_SPACING 2 - -/* ESTUFF */ -#ifndef _ -#define _(x) (x) -#endif -#define E_EXPANDER_GET_PRIVATE(expander) ((EExpanderPrivate *)g_object_get_data (G_OBJECT (expander), "e-expander-priv")) - -enum { - PROP_0, - PROP_EXPANDED, - PROP_LABEL, - PROP_USE_UNDERLINE, - PROP_PADDING, - PROP_LABEL_WIDGET -}; - -typedef struct { - GtkWidget *label_widget; - gint spacing; - - GtkExpanderStyle expander_style; - guint animation_timeout; - - guint expanded : 1; - guint use_underline : 1; - guint button_down : 1; -} EExpanderPrivate; - -static void e_expander_class_init (EExpanderClass *klass); -static void e_expander_init (EExpander *expander); - -static void e_expander_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void e_expander_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void e_expander_destroy (GtkObject *object); - -static void e_expander_realize (GtkWidget *widget); -static void e_expander_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void e_expander_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void e_expander_map (GtkWidget *widget); -static gboolean e_expander_expose (GtkWidget *widget, - GdkEventExpose *event); -static gboolean e_expander_button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean e_expander_button_release (GtkWidget *widget, - GdkEventButton *event); -static gboolean e_expander_motion_notify (GtkWidget *widget, - GdkEventMotion *event); -static gboolean e_expander_enter_notify (GtkWidget *widget, - GdkEventCrossing *event); -static gboolean e_expander_leave_notify (GtkWidget *widget, - GdkEventCrossing *event); -static gboolean e_expander_focus (GtkWidget *widget, - GtkDirectionType direction); - -static void e_expander_add (GtkContainer *container, - GtkWidget *widget); -static void e_expander_remove (GtkContainer *container, - GtkWidget *widget); -static void e_expander_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); - -static void e_expander_activate (EExpander *expander); - -static GtkBinClass *parent_class = NULL; - -GType -e_expander_get_type (void) -{ - static GType expander_type = 0; - - if (!expander_type) - { - static const GTypeInfo expander_info = - { - sizeof (EExpanderClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_expander_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EExpander), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_expander_init, - }; - - expander_type = g_type_register_static (GTK_TYPE_BIN, - "EExpander", - &expander_info, 0); - } - - return expander_type; -} - -static void -e_expander_class_init (EExpanderClass *klass) -{ - GObjectClass *gobject_class; - GtkObjectClass *gtkobject_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class = (GObjectClass *) klass; - gtkobject_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - container_class = (GtkContainerClass *) klass; - - gobject_class->set_property = e_expander_set_property; - gobject_class->get_property = e_expander_get_property; - - gtkobject_class->destroy = e_expander_destroy; - - widget_class->realize = e_expander_realize; - widget_class->size_request = e_expander_size_request; - widget_class->size_allocate = e_expander_size_allocate; - widget_class->map = e_expander_map; - widget_class->expose_event = e_expander_expose; - widget_class->button_press_event = e_expander_button_press; - widget_class->button_release_event = e_expander_button_release; - widget_class->motion_notify_event = e_expander_motion_notify; - widget_class->enter_notify_event = e_expander_enter_notify; - widget_class->leave_notify_event = e_expander_leave_notify; - widget_class->focus = e_expander_focus; - - container_class->add = e_expander_add; - container_class->remove = e_expander_remove; - container_class->forall = e_expander_forall; - - klass->activate = e_expander_activate; - - /* ESTUFF g_type_class_add_private (klass, sizeof (EExpanderPrivate)); */ - - g_object_class_install_property (gobject_class, - PROP_EXPANDED, - g_param_spec_boolean ("expanded", - _("Expanded"), - _("Whether or not the expander is expanded"), - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, - PROP_LABEL, - g_param_spec_string ("label", - _("Label"), - _("Text of the expander's label"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, - PROP_USE_UNDERLINE, - g_param_spec_boolean ("use_underline", - _("Use underline"), - _("If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key"), - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, - PROP_PADDING, - g_param_spec_int ("spacing", - _("Spacing"), - _("Space to put between the label and the child"), - 0, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_LABEL_WIDGET, - g_param_spec_object ("label_widget", - _("Label widget"), - _("A widget to display in place of the usual expander label"), - GTK_TYPE_WIDGET, - G_PARAM_READWRITE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("expander-size", - _("Expander Size"), - _("Size of the expander arrow"), - 0, - G_MAXINT, - DEFAULT_EXPANDER_SIZE, - G_PARAM_READABLE)); - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("expander-spacing", - _("Indicator Spacing"), - _("Spacing around expander arrow"), - 0, - G_MAXINT, - DEFAULT_EXPANDER_SPACING, - G_PARAM_READABLE)); - - widget_class->activate_signal = - g_signal_new ("activate", - G_TYPE_FROM_CLASS (gobject_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EExpanderClass, activate), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -e_expander_init (EExpander *expander) -{ - EExpanderPrivate *priv; - - /* ESTUFF */ - priv = g_new0 (EExpanderPrivate, 1); - g_object_set_data_full (G_OBJECT (expander), "e-expander-priv", priv, g_free); - - /* ESTUFF priv = E_EXPANDER_GET_PRIVATE (expander); */ - - GTK_WIDGET_SET_FLAGS (expander, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (expander, GTK_NO_WINDOW); - - priv->label_widget = 0; - priv->spacing = 0; - - priv->expander_style = GTK_EXPANDER_COLLAPSED; - priv->animation_timeout = 0; - - priv->expanded = FALSE; - priv->use_underline = FALSE; - priv->button_down = FALSE; - -} - -static void -e_expander_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EExpander *expander = E_EXPANDER (object); - - switch (prop_id) - { - case PROP_EXPANDED: - e_expander_set_expanded (expander, g_value_get_boolean (value)); - break; - case PROP_LABEL: - e_expander_set_label (expander, g_value_get_string (value)); - break; - case PROP_USE_UNDERLINE: - e_expander_set_use_underline (expander, g_value_get_boolean (value)); - break; - case PROP_PADDING: - e_expander_set_spacing (expander, g_value_get_int (value)); - break; - case PROP_LABEL_WIDGET: - e_expander_set_label_widget (expander, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_expander_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EExpander *expander = E_EXPANDER (object); - EExpanderPrivate *priv; - - priv = E_EXPANDER_GET_PRIVATE (expander); - - switch (prop_id) - { - case PROP_EXPANDED: - g_value_set_boolean (value, priv->expanded); - break; - case PROP_LABEL: - g_value_set_string (value, e_expander_get_label (expander)); - break; - case PROP_USE_UNDERLINE: - g_value_set_boolean (value, priv->use_underline); - break; - case PROP_PADDING: - g_value_set_int (value, priv->spacing); - break; - case PROP_LABEL_WIDGET: - g_value_set_object (value, - priv->label_widget ? - G_OBJECT (priv->label_widget) : NULL); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_expander_destroy (GtkObject *object) -{ - EExpander *expander = E_EXPANDER (object); - EExpanderPrivate *priv; - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (priv->animation_timeout) - g_source_remove (priv->animation_timeout); - priv->animation_timeout = 0; - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -e_expander_realize (GtkWidget *widget) -{ - GdkWindowAttr attributes; - gint attributes_mask; - gint border_width; - - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - border_width = GTK_CONTAINER (widget)->border_width; - - attributes.x = widget->allocation.x + border_width; - attributes.y = widget->allocation.y + border_width; - attributes.width = widget->allocation.width - 2 * border_width; - attributes.height = widget->allocation.height - 2 * border_width; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = gtk_widget_get_events (widget) | - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_EXPOSURE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK; - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); -} - -static void -e_expander_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - EExpander *expander; - GtkBin *bin; - EExpanderPrivate *priv; - gint border_width; - gint expander_size; - gint expander_spacing; - gboolean interior_focus; - gint focus_width; - gint focus_pad; - - expander = E_EXPANDER (widget); - bin = GTK_BIN (widget); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - border_width = GTK_CONTAINER (widget)->border_width; - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - requisition->width = expander_size + 2 * expander_spacing + - 2 * focus_width + 2 * focus_pad; - requisition->height = interior_focus ? (2 * focus_width + 2 * focus_pad) : 0; - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - { - GtkRequisition label_requisition; - - gtk_widget_size_request (priv->label_widget, &label_requisition); - - requisition->width += label_requisition.width; - requisition->height += label_requisition.height; - } - - requisition->height = MAX (expander_size + 2 * expander_spacing, requisition->height); - - if (!interior_focus) - requisition->height += 2 * focus_width + 2 * focus_pad; - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (bin->child, &child_requisition); - - if (!interior_focus) - child_requisition.width += 2 * focus_width + 2 * focus_pad; - - requisition->width = MAX (requisition->width, child_requisition.width); - requisition->height += child_requisition.height + priv->spacing; - } - - requisition->width += 2 * border_width; - requisition->height += 2 * border_width + 2 * priv->spacing; -} - -static void -e_expander_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - EExpander *expander; - GtkBin *bin; - EExpanderPrivate *priv; - GtkRequisition child_requisition; - gboolean child_visible = FALSE; - gint border_width; - gint expander_size; - gint expander_spacing; - gboolean interior_focus; - gint focus_width; - gint focus_pad; - gint label_height; - - expander = E_EXPANDER (widget); - bin = GTK_BIN (widget); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - border_width = GTK_CONTAINER (widget)->border_width; - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - child_requisition.width = 0; - child_requisition.height = 0; - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - { - child_visible = TRUE; - gtk_widget_get_child_requisition (bin->child, &child_requisition); - } - - widget->allocation = *allocation; - - if (GTK_WIDGET_REALIZED (widget)) - gdk_window_move_resize (widget->window, - allocation->x + border_width, - allocation->y + border_width, - MAX (allocation->width - 2 * border_width, 0), - MAX (allocation->height - 2 * border_width, 0)); - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - { - GtkAllocation label_allocation; - GtkRequisition label_requisition; - gboolean ltr; - - gtk_widget_get_child_requisition (priv->label_widget, &label_requisition); - - ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; - - label_allocation.x = focus_width + focus_pad; - if (ltr) - label_allocation.x += expander_size + 2 * expander_spacing; - label_allocation.y = priv->spacing + focus_width + focus_pad; - - label_allocation.width = MIN (label_requisition.width, - allocation->width - 2 * border_width - - expander_size - 2 * expander_spacing - - 2 * focus_width - 2 * focus_pad); - label_allocation.width = MAX (label_allocation.width, 1); - - label_allocation.height = MIN (label_requisition.height, - allocation->height - 2 * border_width - - 2 * priv->spacing - - 2 * focus_width - 2 * focus_pad - - child_requisition.height - - (child_visible ? priv->spacing : 0)); - label_allocation.height = MAX (label_allocation.height, 1); - - gtk_widget_size_allocate (priv->label_widget, &label_allocation); - - label_height = label_allocation.height; - } - else - { - label_height = 0; - } - - if (child_visible) - { - GtkAllocation child_allocation; - gint top_height; - - top_height = MAX (2 * expander_spacing + expander_size, - label_height + - (interior_focus ? 2 * focus_width + 2 * focus_pad : 0)); - - child_allocation.x = 0; - child_allocation.y = 2 * priv->spacing + top_height; - - if (!interior_focus) - { - child_allocation.x += focus_width + focus_pad; - child_allocation.y += focus_width + focus_pad; - } - - child_allocation.width = allocation->width - 2 * border_width - - (!interior_focus ? 2 * focus_width + 2 * focus_pad : 0); - child_allocation.width = MAX (child_allocation.width, 1); - - child_allocation.height = allocation->height - top_height - - 2 * border_width - - 3 * priv->spacing - - (!interior_focus ? 2 * focus_width + 2 * focus_pad : 0); - child_allocation.height = MAX (child_allocation.height, 1); - - gtk_widget_size_allocate (bin->child, &child_allocation); - } -} - -static void -e_expander_map (GtkWidget *widget) -{ - EExpanderPrivate *priv; - - priv = E_EXPANDER_GET_PRIVATE (widget); - - if (priv->label_widget) - gtk_widget_map (priv->label_widget); - - GTK_WIDGET_CLASS (parent_class)->map (widget); -} - -static GdkRectangle -get_expander_bounds (EExpander *expander) -{ - GtkWidget *widget; - GtkBin *bin; - EExpanderPrivate *priv; - GdkRectangle bounds; - gint border_width; - gint expander_size; - gint expander_spacing; - gboolean interior_focus; - gint focus_width; - gint focus_pad; - gboolean ltr; - - widget = GTK_WIDGET (expander); - bin = GTK_BIN (expander); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - border_width = GTK_CONTAINER (expander)->border_width; - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; - - - if (ltr) - bounds.x = expander_spacing; - else - bounds.x = widget->allocation.width - 2 * border_width - - expander_spacing - expander_size; - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - { - GtkAllocation label_allocation; - - label_allocation = priv->label_widget->allocation; - - if (expander_size < label_allocation.height) - bounds.y = label_allocation.y + (label_allocation.height - expander_size) / 2; - else - bounds.y = priv->spacing + expander_spacing; - } - else - { - bounds.y = priv->spacing + expander_spacing; - } - - if (!interior_focus) - { - if (ltr) - bounds.x += focus_width + focus_pad; - else - bounds.x -= focus_width + focus_pad; - bounds.y += focus_width + focus_pad; - } - - bounds.width = bounds.height = expander_size; - - return bounds; -} - -static void -e_expander_paint (EExpander *expander) -{ - GtkWidget *widget; - EExpanderPrivate *priv; - gint x, y; - GtkStateType state; - GdkRectangle clip; - - widget = GTK_WIDGET (expander); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - clip = get_expander_bounds (expander); - - x = clip.x + clip.width / 2; - y = clip.y + clip.height / 2; - - state = widget->state; - if (state != GTK_STATE_PRELIGHT) - state = GTK_STATE_NORMAL; - - gtk_paint_expander (widget->style, - widget->window, - state, - &clip, - widget, - "expander", - x, - y, - priv->expander_style); -} - -static void -e_expander_paint_focus (EExpander *expander, - GdkRectangle *area) -{ - GtkWidget *widget; - EExpanderPrivate *priv; - gint x, y, width, height; - gboolean interior_focus; - gint focus_width; - gint focus_pad; - gint expander_size; - gint expander_spacing; - gboolean ltr; - - widget = GTK_WIDGET (expander); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - gtk_widget_style_get (widget, - "interior-focus", &interior_focus, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - "expander-size", &expander_size, - "expander-spacing", &expander_spacing, - NULL); - - ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL; - - if (interior_focus) - { - if (ltr) - x = expander_spacing * 2 + expander_size; - else - x = 0; - y = priv->spacing; - - width = height = 2 * focus_pad + 2 * focus_width; - - if (priv->label_widget && GTK_WIDGET_VISIBLE (priv->label_widget)) - { - GtkAllocation label_allocation = priv->label_widget->allocation; - - width += label_allocation.width; - height += label_allocation.height; - } - } - else - { - x = y = 0; - width = widget->allocation.width - 2 * GTK_CONTAINER (widget)->border_width; - height = widget->allocation.height - 2 * GTK_CONTAINER (widget)->border_width; - } - - gtk_paint_focus (widget->style, widget->window, GTK_WIDGET_STATE (widget), - area, widget, "expander", - x, y, width, height); -} - -static gboolean -e_expander_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - if (GTK_WIDGET_DRAWABLE (widget)) - { - EExpander *expander = E_EXPANDER (widget); - EExpanderPrivate *priv; - - priv = E_EXPANDER_GET_PRIVATE (expander); - - e_expander_paint (expander); - - if (GTK_WIDGET_HAS_FOCUS (expander)) - e_expander_paint_focus (expander, &event->area); - - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); - } - - return FALSE; -} - -static gboolean -is_in_expander_panel (EExpander *expander, - GdkWindow *window, - gint x, - gint y) -{ - GtkWidget *widget; - GtkBin *bin; - GdkRectangle area; - gint border_width; - - widget = GTK_WIDGET (expander); - bin = GTK_BIN (expander); - - border_width = GTK_CONTAINER (expander)->border_width; - - area = get_expander_bounds (expander); - - area.x = 0; - area.width = widget->allocation.width; - - if (widget->window == window) - { - if (x >= area.x && x <= (area.x + area.width) && - y >= area.y && y <= (area.y + area.height)) - return TRUE; - } - - return FALSE; -} - -static gboolean -e_expander_button_press (GtkWidget *widget, - GdkEventButton *event) -{ - EExpander *expander = E_EXPANDER (widget); - EExpanderPrivate *priv; - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (event->button == 1 && !priv->button_down) - { - if (is_in_expander_panel (expander, event->window, event->x, event->y)) - { - priv->button_down = TRUE; - return TRUE; - } - } - - return FALSE; -} - -static gboolean -e_expander_button_release (GtkWidget *widget, - GdkEventButton *event) -{ - EExpander *expander = E_EXPANDER (widget); - EExpanderPrivate *priv; - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (event->button == 1 && priv->button_down) - { - g_signal_emit_by_name (expander, "activate"); - - priv->button_down = FALSE; - return TRUE; - } - - return FALSE; -} - -static void -e_expander_maybe_prelight (EExpander *expander) -{ - GtkWidget *widget; - EExpanderPrivate *priv; - GtkStateType state = GTK_STATE_NORMAL; - - widget = GTK_WIDGET (expander); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (!priv->button_down) - { - gint x, y; - - gdk_window_get_pointer (widget->window, &x, &y, NULL); - - if (is_in_expander_panel (expander, widget->window, x, y)) - state = GTK_STATE_PRELIGHT; - } - - gtk_widget_set_state (widget, state); -} - -static gboolean -e_expander_motion_notify (GtkWidget *widget, - GdkEventMotion *event) -{ - e_expander_maybe_prelight (E_EXPANDER (widget)); - - return FALSE; -} - -static gboolean -e_expander_enter_notify (GtkWidget *widget, - GdkEventCrossing *event) -{ - e_expander_maybe_prelight (E_EXPANDER (widget)); - - return FALSE; -} - -static gboolean -e_expander_leave_notify (GtkWidget *widget, - GdkEventCrossing *event) -{ - gtk_widget_set_state (widget, GTK_STATE_NORMAL); - - return FALSE; -} - -static gboolean -focus_child_in (GtkWidget *widget, - GtkDirectionType direction) -{ - GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); - - if (!child) - return FALSE; - - return gtk_widget_child_focus (child, direction); -} - -static gboolean -e_expander_focus (GtkWidget *widget, - GtkDirectionType direction) -{ - EExpanderPrivate *priv; - GtkWidget *old_focus_child; - gboolean widget_is_focus; - gboolean label_can_focus; - - priv = E_EXPANDER_GET_PRIVATE (widget); - - widget_is_focus = gtk_widget_is_focus (widget); - old_focus_child = GTK_CONTAINER (widget)->focus_child; - label_can_focus = priv->label_widget && GTK_WIDGET_CAN_FOCUS (priv->label_widget); - - if (old_focus_child && old_focus_child == priv->label_widget) - { - switch (direction) - { - case GTK_DIR_TAB_BACKWARD: - case GTK_DIR_LEFT: - case GTK_DIR_UP: - gtk_widget_grab_focus (widget); - return TRUE; - case GTK_DIR_DOWN: - case GTK_DIR_TAB_FORWARD: - case GTK_DIR_RIGHT: - return focus_child_in (widget, direction); - } - } - else if (old_focus_child) - { - if (gtk_widget_child_focus (old_focus_child, direction)) - return TRUE; - - switch (direction) - { - case GTK_DIR_TAB_BACKWARD: - case GTK_DIR_LEFT: - case GTK_DIR_UP: - if (label_can_focus) - gtk_widget_grab_focus (priv->label_widget); - else - gtk_widget_grab_focus (widget); - return TRUE; - case GTK_DIR_DOWN: - case GTK_DIR_TAB_FORWARD: - case GTK_DIR_RIGHT: - return FALSE; - } - } - else if (widget_is_focus) - { - switch (direction) - { - case GTK_DIR_TAB_BACKWARD: - case GTK_DIR_LEFT: - case GTK_DIR_UP: - return FALSE; - case GTK_DIR_DOWN: - case GTK_DIR_TAB_FORWARD: - case GTK_DIR_RIGHT: - if (label_can_focus) - { - gtk_widget_grab_focus (priv->label_widget); - return TRUE; - } - - return focus_child_in (widget, direction); - } - } - else - { - switch (direction) - { - case GTK_DIR_DOWN: - case GTK_DIR_TAB_FORWARD: - case GTK_DIR_TAB_BACKWARD: - gtk_widget_grab_focus (widget); - return TRUE; - case GTK_DIR_UP: - case GTK_DIR_LEFT: - case GTK_DIR_RIGHT: - if (!focus_child_in (widget, direction)) - { - gtk_widget_grab_focus (widget); - } - return TRUE; - } - } - - g_assert_not_reached (); - return FALSE; -} - -static void -e_expander_add (GtkContainer *container, - GtkWidget *widget) -{ - GTK_CONTAINER_CLASS (parent_class)->add (container, widget); - - g_object_set (G_OBJECT (widget), - "visible", E_EXPANDER_GET_PRIVATE (container)->expanded, - NULL); -} - -static void -e_expander_remove (GtkContainer *container, - GtkWidget *widget) -{ - EExpander *expander = E_EXPANDER (container); - - if (E_EXPANDER_GET_PRIVATE (expander)->label_widget == widget) - e_expander_set_label_widget (expander, NULL); - else - GTK_CONTAINER_CLASS (parent_class)->remove (container, widget); -} - -static void -e_expander_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkBin *bin = GTK_BIN (container); - EExpanderPrivate *priv; - - priv = E_EXPANDER_GET_PRIVATE (container); - - if (bin->child) - (* callback) (bin->child, callback_data); - - if (priv->label_widget) - (* callback) (priv->label_widget, callback_data); -} - -static void -e_expander_activate (EExpander *expander) -{ - e_expander_set_expanded (expander, - !E_EXPANDER_GET_PRIVATE (expander)->expanded); -} - -GtkWidget * -e_expander_new (const gchar *label) -{ - return g_object_new (E_TYPE_EXPANDER, "label", label, NULL); -} - -GtkWidget * -e_expander_new_with_mnemonic (const gchar *label) -{ - return g_object_new (E_TYPE_EXPANDER, - "label", label, - "use_underline", TRUE, - NULL); -} - -static gboolean -e_expander_animation_timeout (EExpander *expander) -{ - EExpanderPrivate *priv; - GdkRectangle area; - gboolean finish = FALSE; - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (GTK_WIDGET_REALIZED (expander)) - { - area = get_expander_bounds (expander); - gdk_window_invalidate_rect (GTK_WIDGET (expander)->window, &area, TRUE); - } - - if (priv->expanded) - { - if (priv->expander_style == GTK_EXPANDER_COLLAPSED) - { - priv->expander_style = GTK_EXPANDER_SEMI_EXPANDED; - } - else - { - priv->expander_style = GTK_EXPANDER_EXPANDED; - finish = TRUE; - } - } - else - { - if (priv->expander_style == GTK_EXPANDER_EXPANDED) - { - priv->expander_style = GTK_EXPANDER_SEMI_COLLAPSED; - } - else - { - priv->expander_style = GTK_EXPANDER_COLLAPSED; - finish = TRUE; - } - } - - if (finish) - { - priv->animation_timeout = 0; - g_object_set (G_OBJECT (GTK_BIN (expander)->child), - "visible", priv->expanded, - NULL); - } - - return !finish; -} - -static void -e_expander_start_animation (EExpander *expander) -{ - EExpanderPrivate *priv; - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (priv->animation_timeout) - g_source_remove (priv->animation_timeout); - - priv->animation_timeout = - g_timeout_add (50, - (GSourceFunc) e_expander_animation_timeout, - expander); -} - -void -e_expander_set_expanded (EExpander *expander, - gboolean expanded) -{ - EExpanderPrivate *priv; - - g_return_if_fail (E_IS_EXPANDER (expander)); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - expanded = expanded != FALSE; - - if (priv->expanded != expanded) - { - priv->expanded = expanded; - - if (GTK_WIDGET_VISIBLE (expander)) - e_expander_start_animation (expander); - - else if (GTK_BIN (expander)->child) - { - priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED : - GTK_EXPANDER_COLLAPSED; - g_object_set (G_OBJECT (GTK_BIN (expander)->child), - "visible", priv->expanded, - NULL); - } - - gtk_widget_queue_resize (GTK_WIDGET (expander)); - - g_object_notify (G_OBJECT (expander), "expanded"); - } -} - -gboolean -e_expander_get_expanded (EExpander *expander) -{ - g_return_val_if_fail (E_IS_EXPANDER (expander), FALSE); - - return E_EXPANDER_GET_PRIVATE (expander)->expanded; -} - -void -e_expander_set_spacing (EExpander *expander, - gint spacing) -{ - EExpanderPrivate *priv; - - g_return_if_fail (E_IS_EXPANDER (expander)); - g_return_if_fail (spacing >= 0); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (priv->spacing != spacing) - { - priv->spacing = spacing; - - gtk_widget_queue_resize (GTK_WIDGET (expander)); - - g_object_notify (G_OBJECT (expander), "spacing"); - } -} - -gint -e_expander_get_spacing (EExpander *expander) -{ - g_return_val_if_fail (E_IS_EXPANDER (expander), 0); - - return E_EXPANDER_GET_PRIVATE (expander)->spacing; -} - -void -e_expander_set_label (EExpander *expander, - const gchar *label) -{ - g_return_if_fail (E_IS_EXPANDER (expander)); - - if (!label) - { - e_expander_set_label_widget (expander, NULL); - } - else - { - GtkWidget *child; - - child = gtk_label_new (label); - gtk_label_set_use_underline (GTK_LABEL (child), - E_EXPANDER_GET_PRIVATE (expander)->use_underline); - gtk_widget_show (child); - - e_expander_set_label_widget (expander, child); - } - - g_object_notify (G_OBJECT (expander), "label"); -} - -/** - * e_expander_get_label: - * @expander: a #EExpander - * - * If the expander's label widget is a #GtkLabel, return the - * text in the label widget. (The frame will have a #GtkLabel - * for the label widget if a non-%NULL argument was passed - * to e_expander_new().) - * - * Return value: the text in the label, or %NULL if there - * was no label widget or the lable widget was not - * a #GtkLabel. This string is owned by GTK+ and - * must not be modified or freed. - **/ -G_CONST_RETURN char * -e_expander_get_label (EExpander *expander) -{ - EExpanderPrivate *priv; - - g_return_val_if_fail (E_IS_EXPANDER (expander), NULL); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (priv->label_widget && GTK_IS_LABEL (priv->label_widget)) - return gtk_label_get_text (GTK_LABEL (priv->label_widget)); - else - return NULL; -} - -void -e_expander_set_use_underline (EExpander *expander, - gboolean use_underline) -{ - EExpanderPrivate *priv; - - g_return_if_fail (E_IS_EXPANDER (expander)); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - use_underline = use_underline != FALSE; - - if (priv->use_underline != use_underline) - { - priv->use_underline = use_underline; - - if (priv->label_widget && GTK_IS_LABEL (priv->label_widget)) - gtk_label_set_use_underline (GTK_LABEL (priv->label_widget), use_underline); - - g_object_notify (G_OBJECT (expander), "use_underline"); - } -} - -gboolean -e_expander_get_use_underline (EExpander *expander) -{ - g_return_val_if_fail (E_IS_EXPANDER (expander), FALSE); - - return E_EXPANDER_GET_PRIVATE (expander)->use_underline; -} - -/** - * e_expander_set_label_widget: - * @expander: a #EExpander - * @label_widget: the new label widget - * - * Set the label widget for the expander. This is the widget - * that will appear embedded alongside the expander arrow. - **/ -void -e_expander_set_label_widget (EExpander *expander, - GtkWidget *label_widget) -{ - EExpanderPrivate *priv; - gboolean need_resize = FALSE; - - g_return_if_fail (E_IS_EXPANDER (expander)); - g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget)); - g_return_if_fail (label_widget == NULL || label_widget->parent == NULL); - - priv = E_EXPANDER_GET_PRIVATE (expander); - - if (priv->label_widget == label_widget) - return; - - if (priv->label_widget) - { - need_resize = GTK_WIDGET_VISIBLE (priv->label_widget); - gtk_widget_unparent (priv->label_widget); - } - - priv->label_widget = label_widget; - - if (label_widget) - { - priv->label_widget = label_widget; - gtk_widget_set_parent (label_widget, GTK_WIDGET (expander)); - need_resize |= GTK_WIDGET_VISIBLE (label_widget); - } - - if (GTK_WIDGET_VISIBLE (expander) && need_resize) - gtk_widget_queue_resize (GTK_WIDGET (expander)); - - g_object_notify (G_OBJECT (expander), "label_widget"); -} - -/** - * e_expander_get_label_widget: - * @expander: a #EExpander - * - * Retrieves the label widget for the frame. See - * e_expander_set_label_widget(). - * - * Return value: the label widget, or %NULL if there is none. - **/ -GtkWidget * -e_expander_get_label_widget (EExpander *expander) -{ - g_return_val_if_fail (E_IS_EXPANDER (expander), NULL); - - return E_EXPANDER_GET_PRIVATE (expander)->label_widget; -} diff --git a/widgets/misc/e-expander.h b/widgets/misc/e-expander.h deleted file mode 100644 index fa231729a4..0000000000 --- a/widgets/misc/e-expander.h +++ /dev/null @@ -1,82 +0,0 @@ -/* GTK - The GIMP Toolkit - * - * Copyright (C) 2003 Sun Microsystems, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Mark McLoughlin <mark@skynet.ie> - */ - -#ifndef _E_EXPANDER_H_ -#define _E_EXPANDER_H_ - -#include <gtk/gtkbin.h> - -G_BEGIN_DECLS - -#define E_TYPE_EXPANDER (e_expander_get_type ()) -#define E_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_EXPANDER, EExpander)) -#define E_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_EXPANDER, EExpanderClass)) -#define E_IS_EXPANDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_EXPANDER)) -#define E_IS_EXPANDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_EXPANDER)) -#define E_EXPANDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_EXPANDER, EExpanderClass)) -/* ESTUFF #define E_EXPANDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), E_TYPE_EXPANDER, EExpanderPrivate)) */ - -typedef struct _EExpander EExpander; -typedef struct _EExpanderClass EExpanderClass; - -struct _EExpander -{ - GtkBin bin; -}; - -struct _EExpanderClass -{ - GtkBinClass parent_class; - - void (* activate) (EExpander *expander); -}; - -GType e_expander_get_type (void); - -GtkWidget *e_expander_new (const gchar *label); -GtkWidget *e_expander_new_with_mnemonic (const gchar *label); - -void e_expander_set_expanded (EExpander *expander, - gboolean expanded); -gboolean e_expander_get_expanded (EExpander *expander); - -/* Spacing between the expander/label and the child */ -void e_expander_set_spacing (EExpander *expander, - gint spacing); -gint e_expander_get_spacing (EExpander *expander); - -void e_expander_set_label (EExpander *expander, - const gchar *label); -G_CONST_RETURN gchar *e_expander_get_label (EExpander *expander); - -void e_expander_set_use_underline (EExpander *expander, - gboolean use_underline); -gboolean e_expander_get_use_underline (EExpander *expander); - -void e_expander_set_label_widget (EExpander *expander, - GtkWidget *label_widget); -GtkWidget *e_expander_get_label_widget (EExpander *expander); - -G_END_DECLS - -#endif /* _E_EXPANDER_H_ */ diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c deleted file mode 100644 index f9d4d24ab1..0000000000 --- a/widgets/misc/e-filter-bar.c +++ /dev/null @@ -1,897 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-search-bar.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Authors: - * Michael Zucchi <notzed@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include <libxml/tree.h> -#include <libxml/parser.h> - -#include <libgnome/gnome-i18n.h> - -#include "e-dropdown-button.h" -#include "e-filter-bar.h" -#include "filter/rule-editor.h" - -#define d(x) - -enum { - LAST_SIGNAL -}; - -/*static gint esb_signals [LAST_SIGNAL] = { 0, };*/ - -static ESearchBarClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_QUERY, - PROP_STATE, -}; - - -/* Callbacks. */ - -static void rule_changed (FilterRule *rule, gpointer user_data); - - -/* rule editor thingy */ -static void -rule_editor_destroyed (EFilterBar *efb, GObject *deadbeef) -{ - efb->save_dialog = NULL; - e_search_bar_set_menu_sensitive (E_SEARCH_BAR (efb), E_FILTERBAR_SAVE_ID, TRUE); - gtk_widget_set_sensitive (E_SEARCH_BAR (efb)->entry, TRUE); -} - -/* FIXME: need to update the popup menu to match any edited rules, sigh */ -static void -full_rule_editor_response (GtkWidget *dialog, int response, void *data) -{ - EFilterBar *efb = data; - - if (response == GTK_RESPONSE_OK) - rule_context_save (efb->context, efb->userrules); - - gtk_widget_destroy (dialog); -} - -static void -rule_editor_response (GtkWidget *dialog, int response, void *data) -{ - EFilterBar *efb = data; - FilterRule *rule; - - if (response == GTK_RESPONSE_OK) { - rule = g_object_get_data (G_OBJECT (dialog), "rule"); - if (rule) { - if (!filter_rule_validate (rule)) - return; - - rule_context_add_rule (efb->context, rule); - /* FIXME: check return */ - rule_context_save (efb->context, efb->userrules); - } - } - - gtk_widget_destroy (dialog); -} - -static void -rule_advanced_response (GtkWidget *dialog, int response, void *data) -{ - EFilterBar *efb = data; - FilterRule *rule; - - if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) { - rule = g_object_get_data ((GObject *) dialog, "rule"); - if (rule) { - if (!filter_rule_validate (rule)) - return; - - efb->current_query = rule; - g_object_ref (rule); - g_signal_emit_by_name (efb, "query_changed"); - - if (response == GTK_RESPONSE_APPLY) { - if (!rule_context_find_rule (efb->context, rule->name, rule->source)) - rule_context_add_rule (efb->context, rule); - /* FIXME: check return */ - rule_context_save (efb->context, efb->userrules); - } - } - } - - if (response != GTK_RESPONSE_APPLY) - gtk_widget_destroy (dialog); -} - -static void -do_advanced (ESearchBar *esb) -{ - EFilterBar *efb = (EFilterBar *)esb; - - d(printf("Advanced search!\n")); - - if (!efb->save_dialog && !efb->setquery) { - GtkWidget *dialog, *w; - FilterRule *rule; - - if (efb->current_query) - rule = filter_rule_clone (efb->current_query); - else - rule = filter_rule_new (); - - w = filter_rule_get_widget (rule, efb->context); - filter_rule_set_source (rule, FILTER_SOURCE_INCOMING); - gtk_container_set_border_width (GTK_CONTAINER (w), 12); - - /* FIXME: get the toplevel window... */ - dialog = gtk_dialog_new_with_buttons (_("Advanced Search"), NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_SAVE, GTK_RESPONSE_APPLY, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - - efb->save_dialog = dialog; - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - - gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); - gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 300); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), w, TRUE, TRUE, 0); - - g_object_ref (rule); - g_object_set_data_full ((GObject *) dialog, "rule", rule, (GDestroyNotify) g_object_unref); - - g_signal_connect (dialog, "response", G_CALLBACK (rule_advanced_response), efb); - g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb); - - e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE); - gtk_widget_set_sensitive (esb->entry, FALSE); - - gtk_widget_show (dialog); - } -} - -static void -menubar_activated (ESearchBar *esb, int id, void *data) -{ - EFilterBar *efb = (EFilterBar *)esb; - GtkWidget *dialog, *w; - - d(printf ("menubar activated!\n")); - - switch (id) { - case E_FILTERBAR_EDIT_ID: - if (!efb->save_dialog) { - efb->save_dialog = dialog = (GtkWidget *) rule_editor_new (efb->context, FILTER_SOURCE_INCOMING, _("_Searches")); - - gtk_window_set_title (GTK_WINDOW (dialog), _("Search Editor")); - g_signal_connect (dialog, "response", G_CALLBACK (full_rule_editor_response), efb); - g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb); - gtk_widget_show (dialog); - } - break; - case E_FILTERBAR_SAVE_ID: - if (efb->current_query && !efb->save_dialog) { - FilterRule *rule; - char *name, *text; - - rule = filter_rule_clone (efb->current_query); - text = e_search_bar_get_text (esb); - name = g_strdup_printf ("%s %s", rule->name, text && text[0] ? text : "''"); - filter_rule_set_name (rule, name); - g_free (text); - g_free (name); - - w = filter_rule_get_widget (rule, efb->context); - filter_rule_set_source (rule, FILTER_SOURCE_INCOMING); - gtk_container_set_border_width (GTK_CONTAINER (w), 12); - - /* FIXME: get the toplevel window... */ - dialog = gtk_dialog_new_with_buttons (_("Save Search"), NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - efb->save_dialog = dialog; - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12); - - gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 300); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), w, TRUE, TRUE, 0); - - g_object_ref (rule); - g_object_set_data_full ((GObject *) dialog, "rule", rule, (GDestroyNotify) g_object_unref); - g_signal_connect (dialog, "response", G_CALLBACK (rule_editor_response), efb); - g_object_weak_ref ((GObject *) dialog, (GWeakNotify) rule_editor_destroyed, efb); - - e_search_bar_set_menu_sensitive (esb, E_FILTERBAR_SAVE_ID, FALSE); - gtk_widget_set_sensitive (esb->entry, FALSE); - - gtk_widget_show (dialog); - } - - d(printf("Save menu\n")); - break; - case E_FILTERBAR_ADVANCED_ID: - e_search_bar_set_item_id (esb, E_FILTERBAR_ADVANCED_ID); - break; - default: - if (id >= efb->menu_base && id < efb->menu_base + efb->menu_rules->len) { -#if d(!)0 - GString *out = g_string_new (""); - - printf("Selected rule: %s\n", ((FilterRule *)efb->menu_rules->pdata[id - efb->menu_base])->name); - filter_rule_build_code (efb->menu_rules->pdata[id - efb->menu_base], out); - printf("query: '%s'\n", out->str); - g_string_free (out, TRUE); -#endif - efb->current_query = (FilterRule *)efb->menu_rules->pdata[id - efb->menu_base]; - - efb->setquery = TRUE; - e_search_bar_set_item_id (esb, E_FILTERBAR_ADVANCED_ID); - efb->setquery = FALSE; - - gtk_widget_set_sensitive (esb->entry, FALSE); - } else { - gtk_widget_set_sensitive (esb->entry, TRUE); - return; - } - } - - g_signal_stop_emission_by_name (esb, "menu_activated"); -} - -static void -option_changed (ESearchBar *esb, void *data) -{ - EFilterBar *efb = (EFilterBar *)esb; - int id = e_search_bar_get_item_id (esb); - char *query; - - d(printf("option changed, id = %d, setquery = %s\n", id, efb->setquery ? "true" : "false")); - - if (efb->setquery) - return; - - switch (id) { - case E_FILTERBAR_ADVANCED_ID: - d(printf ("do_advanced\n")); - do_advanced (esb); - break; - default: - if (id >= efb->option_base && id < efb->option_base + efb->option_rules->len) { - efb->current_query = (FilterRule *)efb->option_rules->pdata[id - efb->option_base]; - if (efb->config && efb->current_query) { - g_object_get (G_OBJECT (esb), "text", &query, NULL); - efb->config (efb, efb->current_query, id, query, efb->config_data); - g_free (query); - } - gtk_widget_set_sensitive (esb->entry, TRUE); - } else { - gtk_widget_set_sensitive (esb->entry, id == E_SEARCHBAR_CLEAR_ID); - efb->current_query = NULL; - } - } -} - -static void -dup_item_no_subitems (ESearchBarItem *dest, - const ESearchBarItem *src) -{ - g_assert (src->subitems == NULL); - - dest->id = src->id; - dest->text = g_strdup (src->text); - dest->subitems = NULL; -} - -static GArray * -build_items (ESearchBar *esb, ESearchBarItem *items, int type, int *start, GPtrArray *rules) -{ - FilterRule *rule = NULL; - EFilterBar *efb = (EFilterBar *)esb; - int id = 0, i; - GArray *menu = g_array_new (FALSE, FALSE, sizeof (ESearchBarItem)); - ESearchBarItem item; - char *source; - GSList *gtksux = NULL; - int num; - - /* So gtk calls a signal again if you connect to it WHILE inside a changed event. - So this snot is to work around that shit fucked up situation */ - for (i=0;i<rules->len;i++) - gtksux = g_slist_prepend(gtksux, rules->pdata[i]); - - g_ptr_array_set_size(rules, 0); - - /* find a unique starting point for the id's of our items */ - for (i = 0; items[i].id != -1; i++) { - ESearchBarItem dup_item; - - if (items[i].id >= id) - id = items[i].id + 1; - - dup_item_no_subitems (&dup_item, items + i); - g_array_append_vals (menu, &dup_item, 1); - } - - *start = id; - - if (type == 0) { - source = FILTER_SOURCE_INCOMING; - - /* Add a separator if there is at least one custom rule. */ - if (rule_context_next_rule (efb->context, rule, source) != NULL) { - item.id = 0; - item.text = NULL; - item.subitems = NULL; - g_array_append_vals (menu, &item, 1); - } - } else { - source = FILTER_SOURCE_DEMAND; - } - - num = 1; - while ((rule = rule_context_next_rule (efb->context, rule, source))) { - item.id = id++; - - if (type == 0 && num <= 10) { - item.text = g_strdup_printf ("_%d. %s", num % 10, rule->name); - num ++; - } else { - item.text = g_strdup (rule->name); - } - - item.subitems = NULL; - g_array_append_vals (menu, &item, 1); - - if (g_slist_find(gtksux, rule) == NULL) { - g_object_ref (rule); - g_signal_connect (rule, "changed", G_CALLBACK (rule_changed), efb); - } else { - gtksux = g_slist_remove(gtksux, rule); - } - g_ptr_array_add (rules, rule); - } - - /* anything elft in gtksux has gone away, and we need to unref/disconnect from it */ - while (gtksux) { - GSList *next; - - next = gtksux->next; - rule = gtksux->data; - - g_signal_handlers_disconnect_by_func (rule, G_CALLBACK (rule_changed), efb); - g_object_unref (rule); - - g_slist_free_1(gtksux); - gtksux = next; - } - - /* always add on the advanced menu */ - if (type == 1) { - ESearchBarItem items[2] = { E_FILTERBAR_SEPARATOR, E_FILTERBAR_ADVANCED }; - ESearchBarItem dup_items[2]; - - dup_item_no_subitems (&dup_items[0], &items[0]); - dup_item_no_subitems (&dup_items[1], &items[1]); - g_array_append_vals (menu, &dup_items, 2); - } - - item.id = -1; - item.text = NULL; - item.subitems = NULL; - g_array_append_vals (menu, &item, 1); - - return menu; -} - -static void -free_built_items (GArray *menu) -{ - int i; - - for (i = 0; i < menu->len; i ++) { - ESearchBarItem *item; - - item = & g_array_index (menu, ESearchBarItem, i); - g_free (item->text); - - g_assert (item->subitems == NULL); - } - - g_array_free (menu, TRUE); -} - -static void -generate_menu (ESearchBar *esb, ESearchBarItem *items) -{ - EFilterBar *efb = (EFilterBar *)esb; - GArray *menu; - - menu = build_items (esb, items, 0, &efb->menu_base, efb->menu_rules); - ((ESearchBarClass *)parent_class)->set_menu (esb, (ESearchBarItem *)menu->data); - free_built_items (menu); -} - -static ESearchBarSubitem * -copy_subitems (ESearchBarSubitem *subitems) -{ - ESearchBarSubitem *items; - int i, num; - - for (num = 0; subitems[num].id != -1; num++) - ; - - items = g_new (ESearchBarSubitem, num + 1); - for (i = 0; i < num + 1; i++) { - items[i].text = g_strdup (subitems[i].text); - items[i].id = subitems[i].id; - items[i].translate = subitems[i].translate; - } - - return items; -} - -static void -free_items (ESearchBarItem *items) -{ - int i, j; - - for (i = 0; items[i].id != -1; i++) { - g_free (items[i].text); - if (items[i].subitems) { - for (j = 0; items[i].subitems[j].id != -1; j++) - g_free (items[i].subitems[j].text); - - g_free (items[i].subitems); - } - } - - g_free (items); -} - -/* Virtual methods */ -static void -set_menu (ESearchBar *esb, ESearchBarItem *items) -{ - EFilterBar *efb = E_FILTER_BAR (esb); - ESearchBarItem *default_items; - int i, num; - - if (efb->default_items) - free_items (efb->default_items); - - for (num = 0; items[num].id != -1; num++) - ; - - default_items = g_new (ESearchBarItem, num + 1); - for (i = 0; i < num + 1; i++) { - default_items[i].text = g_strdup (items[i].text); - default_items[i].id = items[i].id; - if (items[i].subitems) - default_items[i].subitems = copy_subitems (items[i].subitems); - else - default_items[i].subitems = NULL; - } - - efb->default_items = default_items; - - generate_menu (esb, default_items); -} - -static void -set_option (ESearchBar *esb, ESearchBarItem *items) -{ - GArray *menu; - EFilterBar *efb = (EFilterBar *)esb; - - menu = build_items (esb, items, 1, &efb->option_base, efb->option_rules); - ((ESearchBarClass *)parent_class)->set_option (esb, (ESearchBarItem *)menu->data); - free_built_items (menu); - - e_search_bar_set_item_id (esb, efb->option_base); -} - -static void -context_changed (RuleContext *context, gpointer user_data) -{ - EFilterBar *efb = E_FILTER_BAR (user_data); - ESearchBar *esb = E_SEARCH_BAR (user_data); - - /* just generate whole menu again */ - generate_menu (esb, efb->default_items); -} - -static void -context_rule_removed (RuleContext *context, FilterRule *rule, gpointer user_data) -{ - EFilterBar *efb = E_FILTER_BAR (user_data); - ESearchBar *esb = E_SEARCH_BAR (user_data); - - /* just generate whole menu again */ - generate_menu (esb, efb->default_items); -} - -static void -rule_changed (FilterRule *rule, gpointer user_data) -{ - EFilterBar *efb = E_FILTER_BAR (user_data); - ESearchBar *esb = E_SEARCH_BAR (user_data); - - /* just generate whole menu again */ - generate_menu (esb, efb->default_items); -} - - -/* GtkObject methods. */ - -static void -get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - EFilterBar *efb = (EFilterBar *) object; - - switch (property_id) { - case PROP_QUERY: - if (efb->current_query) { - GString *out = g_string_new (""); - - filter_rule_build_code (efb->current_query, out); - g_value_set_string_take_ownership (value, out->str); - g_string_free (out, FALSE); - } else { - g_value_set_string (value, NULL); - } - break; - case PROP_STATE: { - /* FIXME: we should have ESearchBar save its own state to the xmlDocPtr */ - char *xmlbuf, *text, buf[12]; - int subitem_id, item_id, n; - xmlNodePtr root, node; - xmlDocPtr doc; - - item_id = e_search_bar_get_item_id ((ESearchBar *) efb); - - doc = xmlNewDoc ("1.0"); - root = xmlNewDocNode (doc, NULL, "state", NULL); - xmlDocSetRootElement (doc, root); - - if (item_id == E_FILTERBAR_ADVANCED_ID) { - /* advanced query, save the filterbar state */ - node = xmlNewChild (root, NULL, "filter-bar", NULL); - xmlAddChild (node, filter_rule_xml_encode (efb->current_query)); - } else { - /* simple query, save the searchbar state */ - text = e_search_bar_get_text ((ESearchBar *) efb); - subitem_id = e_search_bar_get_subitem_id ((ESearchBar *) efb); - - node = xmlNewChild (root, NULL, "search-bar", NULL); - xmlSetProp (node, "text", text ? text : ""); - sprintf (buf, "%d", item_id); - xmlSetProp (node, "item_id", buf); - sprintf (buf, "%d", subitem_id); - xmlSetProp (node, "subitem_id", buf); - g_free (text); - } - - xmlDocDumpMemory (doc, (xmlChar **) &xmlbuf, &n); - xmlFreeDoc (doc); - - /* remap to glib memory */ - text = g_malloc (n + 1); - memcpy (text, xmlbuf, n); - text[n] = '\0'; - xmlFree (xmlbuf); - - g_value_set_string_take_ownership (value, text); - - break; } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static int -xml_get_prop_int (xmlNodePtr node, const char *prop) -{ - char *buf; - int ret; - - if ((buf = xmlGetProp (node, prop))) { - ret = strtol (buf, NULL, 10); - xmlFree (buf); - } else { - ret = -1; - } - - return ret; -} - -static void -set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - EFilterBar *efb = (EFilterBar *) object; - xmlNodePtr root, node; - const char *state; - xmlDocPtr doc; - - - - switch (property_id) { - case PROP_STATE: - if ((state = g_value_get_string (value))) { - if (!(doc = xmlParseDoc ((char *) state))) - return; - - root = doc->children; - if (strcmp (root->name, "state") != 0) { - xmlFreeDoc (doc); - return; - } - - node = root->children; - while (node != NULL) { - if (!strcmp (node->name, "filter-bar")) { - FilterRule *rule = NULL; - - if ((node = node->children)) { - rule = filter_rule_new (); - if (filter_rule_xml_decode (rule, node, efb->context) != 0) { - g_object_unref (rule); - rule = NULL; - } else { - g_object_set_data_full (object, "rule", rule, (GDestroyNotify) g_object_unref); - } - } - - efb->current_query = rule; - - efb->setquery = TRUE; - e_search_bar_set_item_id ((ESearchBar *) efb, E_FILTERBAR_ADVANCED_ID); - efb->setquery = FALSE; - - break; - } else if (!strcmp (node->name, "search-bar")) { - int subitem_id, item_id; - char *text; - - /* set the text first (it doesn't emit a signal) */ - text = xmlGetProp (node, "text"); - e_search_bar_set_text ((ESearchBar *) efb, text); - xmlFree (text); - - /* now set the item_id and subitem_id */ - item_id = xml_get_prop_int (node, "item_id"); - subitem_id = xml_get_prop_int (node, "subitem_id"); - - if (subitem_id >= 0) - e_search_bar_set_ids ((ESearchBar *) efb, item_id, subitem_id); - else - e_search_bar_set_item_id ((ESearchBar *) efb, item_id); - - break; - } - - node = node->next; - } - - xmlFreeDoc (doc); - } else { - /* set default state */ - e_search_bar_set_text ((ESearchBar *) efb, ""); - e_search_bar_set_item_id ((ESearchBar *) efb, 0); - } - - /* we don't want to run option_changed */ - efb->setquery = TRUE; - g_signal_emit_by_name (efb, "search-activated", NULL); - efb->setquery = FALSE; - - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void clear_rules(EFilterBar *efb, GPtrArray *rules) -{ - int i; - FilterRule *rule; - - /* clear out any data on old rules */ - for (i=0;i<rules->len;i++) { - rule = rules->pdata[i]; - g_signal_handlers_disconnect_by_func (rule, G_CALLBACK (rule_changed), efb); - g_object_unref(rule); - } - g_ptr_array_set_size (rules, 0); -} - -static void -dispose (GObject *object) -{ - EFilterBar *bar; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_FILTER_BAR (object)); - - bar = E_FILTER_BAR (object); - - if (bar->context != NULL && bar->userrules != NULL) - rule_context_save (bar->context, bar->userrules); - - if (bar->menu_rules != NULL) { - clear_rules(bar, bar->menu_rules); - clear_rules(bar, bar->option_rules); - - g_ptr_array_free (bar->menu_rules, TRUE); - g_ptr_array_free (bar->option_rules, TRUE); - - g_free (bar->systemrules); - g_free (bar->userrules); - - bar->menu_rules = NULL; - bar->option_rules = NULL; - bar->systemrules = NULL; - bar->userrules = NULL; - } - - if (bar->context != NULL) { - g_signal_handlers_disconnect_by_func (bar->context, G_CALLBACK (context_changed), bar); - g_signal_handlers_disconnect_by_func (bar->context, G_CALLBACK (context_rule_removed), bar); - - g_object_unref (bar->context); - bar->context = NULL; - } - - if (bar->default_items) { - free_items (bar->default_items); - bar->default_items = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - - -static void -class_init (EFilterBarClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - ESearchBarClass *esb_class = (ESearchBarClass *) klass; - GParamSpec *pspec; - - parent_class = g_type_class_ref (e_search_bar_get_type ()); - - object_class->dispose = dispose; - object_class->get_property = get_property; - object_class->set_property = set_property; - - esb_class->set_menu = set_menu; - esb_class->set_option = set_option; - - pspec = g_param_spec_string ("query", NULL, NULL, NULL, G_PARAM_READABLE); - g_object_class_install_property (object_class, PROP_QUERY, pspec); - - pspec = g_param_spec_string ("state", NULL, NULL, NULL, G_PARAM_READWRITE); - g_object_class_install_property (object_class, PROP_STATE, pspec); - - /*gtk_object_add_arg_type ("EFilterBar::query", GTK_TYPE_STRING, GTK_ARG_READABLE, ARG_QUERY);*/ - -#if 0 - esb_signals [QUERY_CHANGED] = - gtk_signal_new ("query_changed", - GTK_RUN_LAST, - object_class->type, - G_STRUCT_OFFSET (EFilterBarClass, query_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - esb_signals [MENU_ACTIVATED] = - gtk_signal_new ("menu_activated", - GTK_RUN_LAST, - object_class->type, - G_STRUCT_OFFSET (EFilterBarClass, menu_activated), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, esb_signals, LAST_SIGNAL); -#endif -} - -static void -init (EFilterBar *efb) -{ - g_signal_connect (efb, "menu_activated", G_CALLBACK (menubar_activated), NULL); - g_signal_connect (efb, "query_changed", G_CALLBACK (option_changed), NULL); - g_signal_connect (efb, "search_activated", G_CALLBACK (option_changed), NULL); - - efb->menu_rules = g_ptr_array_new (); - efb->option_rules = g_ptr_array_new (); -} - - -/* Object construction. */ - -EFilterBar * -e_filter_bar_new (RuleContext *context, - const char *systemrules, - const char *userrules, - EFilterBarConfigRule config, - void *data) -{ - EFilterBar *bar; - ESearchBarItem item = { NULL, -1, NULL }; - - bar = gtk_type_new (e_filter_bar_get_type ()); - - bar->context = context; - g_object_ref (context); - - bar->config = config; - bar->config_data = data; - - bar->systemrules = g_strdup (systemrules); - bar->userrules = g_strdup (userrules); - - e_search_bar_construct ((ESearchBar *)bar, &item, &item); - - g_signal_connect (context, "changed", G_CALLBACK (context_changed), bar); - g_signal_connect (context, "rule_removed", G_CALLBACK (context_rule_removed), bar); - - return bar; -} - -GtkType -e_filter_bar_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GtkTypeInfo info = { - "EFilterBar", - sizeof (EFilterBar), - sizeof (EFilterBarClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (e_search_bar_get_type (), &info); - } - - return type; -} diff --git a/widgets/misc/e-filter-bar.h b/widgets/misc/e-filter-bar.h deleted file mode 100644 index c15343d86f..0000000000 --- a/widgets/misc/e-filter-bar.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-filter-bar.h - * Copyright (C) 2001 Ximian Inc. - * Author: Michael Zucchi <notzed@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_FILTER_BAR_H__ -#define __E_FILTER_BAR_H__ - -#include <gtk/gtk.h> - -#include "e-search-bar.h" - -#include "filter/rule-context.h" -#include "filter/filter-rule.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EFilterBar - A filter rule driven search bar. - * - * The following arguments are available: - * - * name type read/write description - * --------------------------------------------------------------------------------- - * query string R String representing query. - * state string RW XML string representing the state. - */ - -#define E_FILTER_BAR_TYPE (e_filter_bar_get_type ()) -#define E_FILTER_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_FILTER_BAR_TYPE, EFilterBar)) -#define E_FILTER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_FILTER_BAR_TYPE, EFilterBarClass)) -#define E_IS_FILTER_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_FILTER_BAR_TYPE)) -#define E_IS_FILTER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_FILTER_BAR_TYPE)) - -typedef struct _EFilterBar EFilterBar; -typedef struct _EFilterBarClass EFilterBarClass; - -typedef void (*EFilterBarConfigRule)(EFilterBar *, FilterRule *rule, int id, const char *query, void *data); - -struct _EFilterBar { - ESearchBar parent; - - int menu_base, option_base; - GPtrArray *menu_rules, *option_rules; - - ESearchBarItem *default_items; - - GtkWidget *save_dialog; /* current save dialogue (so we dont pop up multiple ones) */ - - FilterRule *current_query; /* as it says */ - int setquery; /* true when we're setting a query directly to advanced, so dont popup the dialog */ - - RuleContext *context; - char *systemrules; - char *userrules; - - EFilterBarConfigRule config; - void *config_data; -}; - -struct _EFilterBarClass -{ - ESearchBarClass parent_class; -}; - -/* "preset" items */ -enum { - /* preset menu options */ - E_FILTERBAR_SAVE_ID = -3, - E_FILTERBAR_EDIT_ID = -4, - - /* preset option options */ - E_FILTERBAR_ADVANCED_ID = -5, -}; - -#define E_FILTERBAR_SAVE { N_("_Save Search..."), E_FILTERBAR_SAVE_ID, NULL } -#define E_FILTERBAR_EDIT { N_("_Edit Saved Searches..."), E_FILTERBAR_EDIT_ID, NULL } -#define E_FILTERBAR_ADVANCED { N_("_Advanced..."), E_FILTERBAR_ADVANCED_ID, NULL } -#define E_FILTERBAR_SEPARATOR { NULL, 0, NULL } - -#ifdef JUST_FOR_TRANSLATORS -const char * strings[] = { - N_("_Save Search..."), - N_("_Edit Saved Searches..."), - N_("_Advanced...") -}; -#endif - - -GType e_filter_bar_get_type (void); - -EFilterBar *e_filter_bar_new (RuleContext *context, - const char *systemrules, - const char *userrules, - EFilterBarConfigRule config, - void *data); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_FILTER_BAR_H__ */ diff --git a/widgets/misc/e-image-chooser.c b/widgets/misc/e-image-chooser.c deleted file mode 100644 index ac71a20d24..0000000000 --- a/widgets/misc/e-image-chooser.c +++ /dev/null @@ -1,532 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-image-chooser.c - * Copyright (C) 2004 Novell, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <stdio.h> -#include <string.h> - -#include <gtk/gtkalignment.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkdnd.h> - -#include <libgnomevfs/gnome-vfs-ops.h> -#include <libgnome/gnome-i18n.h> - -#include "e-image-chooser.h" -#include "e-util-marshal.h" - -struct _EImageChooserPrivate { - - GtkWidget *frame; - GtkWidget *image; - GtkWidget *browse_button; - - char *image_buf; - int image_buf_size; - int image_width; - int image_height; - - gboolean editable; -}; - -enum { - CHANGED, - LAST_SIGNAL -}; - - -static gint image_chooser_signals [LAST_SIGNAL] = { 0 }; - -static void e_image_chooser_init (EImageChooser *chooser); -static void e_image_chooser_class_init (EImageChooserClass *klass); -#if 0 -static void e_image_chooser_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_image_chooser_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -#endif -static void e_image_chooser_dispose (GObject *object); - -static gboolean image_drag_motion_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, gint y, guint time, EImageChooser *chooser); -static void image_drag_leave_cb (GtkWidget *widget, - GdkDragContext *context, - guint time, EImageChooser *chooser); -static gboolean image_drag_drop_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, gint y, guint time, EImageChooser *chooser); -static void image_drag_data_received_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, - guint info, guint time, EImageChooser *chooser); - -static GtkObjectClass *parent_class = NULL; -#define PARENT_TYPE GTK_TYPE_VBOX - -enum DndTargetType { - DND_TARGET_TYPE_URI_LIST -}; -#define URI_LIST_TYPE "text/uri-list" - -static GtkTargetEntry image_drag_types[] = { - { URI_LIST_TYPE, 0, DND_TARGET_TYPE_URI_LIST }, -}; -static const int num_image_drag_types = sizeof (image_drag_types) / sizeof (image_drag_types[0]); - -GtkWidget * -e_image_chooser_new (void) -{ - return g_object_new (E_TYPE_IMAGE_CHOOSER, NULL); -} - -GType -e_image_chooser_get_type (void) -{ - static GType eic_type = 0; - - if (!eic_type) { - static const GTypeInfo eic_info = { - sizeof (EImageChooserClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_image_chooser_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EImageChooser), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_image_chooser_init, - }; - - eic_type = g_type_register_static (PARENT_TYPE, "EImageChooser", &eic_info, 0); - } - - return eic_type; -} - - -static void -e_image_chooser_class_init (EImageChooserClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (PARENT_TYPE); - - image_chooser_signals [CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EImageChooserClass, changed), - NULL, NULL, - e_util_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - /* - object_class->set_property = e_image_chooser_set_property; - object_class->get_property = e_image_chooser_get_property; - */ - object_class->dispose = e_image_chooser_dispose; -} - -#if UI_CHANGE_OK -static void -browse_for_image_cb (GtkWidget *button, gpointer data) -{ -} -#endif - -static void -e_image_chooser_init (EImageChooser *chooser) -{ - EImageChooserPrivate *priv; - GtkWidget *alignment; - - priv = chooser->priv = g_new0 (EImageChooserPrivate, 1); - - alignment = gtk_alignment_new (0, 0, 0, 0); - priv->frame = gtk_frame_new (""); - priv->image = gtk_image_new (); - - gtk_container_add (GTK_CONTAINER (alignment), priv->image); - -#if UI_CHANGE_OK - priv->browse_button = gtk_button_new_with_label (_("Choose Image")); -#endif - - gtk_frame_set_shadow_type (GTK_FRAME (priv->frame), GTK_SHADOW_NONE); - - gtk_container_add (GTK_CONTAINER (priv->frame), alignment); - gtk_box_set_homogeneous (GTK_BOX (chooser), FALSE); - gtk_box_pack_start (GTK_BOX (chooser), priv->frame, TRUE, TRUE, 0); -#if UI_CHANGE_OK - gtk_box_pack_start (GTK_BOX (chooser), priv->browse_button, FALSE, FALSE, 0); - - g_signal_connect (priv->browse_button, "clicked", G_CALLBACK (browse_for_image_cb), NULL); -#endif - - gtk_drag_dest_set (priv->image, 0, image_drag_types, num_image_drag_types, GDK_ACTION_COPY); - g_signal_connect (priv->image, - "drag_motion", G_CALLBACK (image_drag_motion_cb), chooser); - g_signal_connect (priv->image, - "drag_leave", G_CALLBACK (image_drag_leave_cb), chooser); - g_signal_connect (priv->image, - "drag_drop", G_CALLBACK (image_drag_drop_cb), chooser); - g_signal_connect (priv->image, - "drag_data_received", G_CALLBACK (image_drag_data_received_cb), chooser); - - gtk_widget_show_all (priv->frame); -#if UI_CHANGE_OK - gtk_widget_show (priv->browse_button); -#endif - - /* we default to being editable */ - priv->editable = TRUE; -} - -static void -e_image_chooser_dispose (GObject *object) -{ - EImageChooser *eic = E_IMAGE_CHOOSER (object); - - if (eic->priv) { - EImageChooserPrivate *priv = eic->priv; - - if (priv->image_buf) { - g_free (priv->image_buf); - priv->image_buf = NULL; - } - - g_free (eic->priv); - eic->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - - -static gboolean -set_image_from_data (EImageChooser *chooser, - char *data, int length) -{ - gboolean rv = FALSE; - GdkPixbufLoader *loader = gdk_pixbuf_loader_new (); - GdkPixbuf *pixbuf; - - gdk_pixbuf_loader_write (loader, data, length, NULL); - - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (pixbuf) - gdk_pixbuf_ref (pixbuf); - gdk_pixbuf_loader_close (loader, NULL); - g_object_unref (loader); - - if (pixbuf) { - GdkPixbuf *scaled; - GdkPixbuf *composite; - - float scale; - int new_height, new_width; - - new_height = gdk_pixbuf_get_height (pixbuf); - new_width = gdk_pixbuf_get_width (pixbuf); - - printf ("new dimensions = (%d,%d)\n", new_width, new_height); - - if (chooser->priv->image_height == 0 - && chooser->priv->image_width == 0) { - printf ("initial setting of an image. no scaling\n"); - scale = 1.0; - } - else if (chooser->priv->image_height < new_height - || chooser->priv->image_width < new_width) { - /* we need to scale down */ - printf ("we need to scale down\n"); - if (new_height > new_width) - scale = (float)chooser->priv->image_height / new_height; - else - scale = (float)chooser->priv->image_width / new_width; - } - else { - /* we need to scale up */ - printf ("we need to scale up\n"); - if (new_height > new_width) - scale = (float)new_height / chooser->priv->image_height; - else - scale = (float)new_width / chooser->priv->image_width; - } - - printf ("scale = %g\n", scale); - - if (scale == 1.0) { - gtk_image_set_from_pixbuf (GTK_IMAGE (chooser->priv->image), pixbuf); - - chooser->priv->image_width = new_width; - chooser->priv->image_height = new_height; - } - else { - new_width *= scale; - new_height *= scale; - new_width = MIN (new_width, chooser->priv->image_width); - new_height = MIN (new_height, chooser->priv->image_height); - - printf ("new scaled dimensions = (%d,%d)\n", new_width, new_height); - - scaled = gdk_pixbuf_scale_simple (pixbuf, - new_width, new_height, - GDK_INTERP_BILINEAR); - - composite = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, gdk_pixbuf_get_bits_per_sample (pixbuf), - chooser->priv->image_width, chooser->priv->image_height); - - gdk_pixbuf_fill (composite, 0x00000000); - - gdk_pixbuf_copy_area (scaled, 0, 0, new_width, new_height, - composite, - chooser->priv->image_width / 2 - new_width / 2, - chooser->priv->image_height / 2 - new_height / 2); - - gtk_image_set_from_pixbuf (GTK_IMAGE (chooser->priv->image), composite); - gdk_pixbuf_unref (scaled); - gdk_pixbuf_unref (composite); - } - - gdk_pixbuf_unref (pixbuf); - - g_free (chooser->priv->image_buf); - chooser->priv->image_buf = data; - chooser->priv->image_buf_size = length; - - g_signal_emit (chooser, - image_chooser_signals [CHANGED], 0); - - rv = TRUE; - } - - return rv; -} - -static gboolean -image_drag_motion_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, gint y, guint time, EImageChooser *chooser) -{ - GList *p; - - if (!chooser->priv->editable) - return FALSE; - - for (p = context->targets; p != NULL; p = p->next) { - char *possible_type; - - possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data)); - if (!strcmp (possible_type, URI_LIST_TYPE)) { - g_free (possible_type); - gdk_drag_status (context, GDK_ACTION_COPY, time); - gtk_frame_set_shadow_type (GTK_FRAME (chooser->priv->frame), GTK_SHADOW_IN); - return TRUE; - } - - g_free (possible_type); - } - - gtk_frame_set_shadow_type (GTK_FRAME (chooser->priv->frame), GTK_SHADOW_NONE); - return FALSE; -} - -static void -image_drag_leave_cb (GtkWidget *widget, - GdkDragContext *context, - guint time, EImageChooser *chooser) -{ - gtk_frame_set_shadow_type (GTK_FRAME (chooser->priv->frame), GTK_SHADOW_NONE); -} - -static gboolean -image_drag_drop_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, gint y, guint time, EImageChooser *chooser) -{ - GList *p; - - if (!chooser->priv->editable) - return FALSE; - - if (context->targets == NULL) { - gtk_frame_set_shadow_type (GTK_FRAME (chooser->priv->frame), GTK_SHADOW_NONE); - return FALSE; - } - - for (p = context->targets; p != NULL; p = p->next) { - char *possible_type; - - possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data)); - if (!strcmp (possible_type, URI_LIST_TYPE)) { - g_free (possible_type); - gtk_drag_get_data (widget, context, - GDK_POINTER_TO_ATOM (p->data), - time); - gtk_frame_set_shadow_type (GTK_FRAME (chooser->priv->frame), GTK_SHADOW_NONE); - return TRUE; - } - - g_free (possible_type); - } - - gtk_frame_set_shadow_type (GTK_FRAME (chooser->priv->frame), GTK_SHADOW_NONE); - return FALSE; -} - -static void -image_drag_data_received_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, - guint info, guint time, EImageChooser *chooser) -{ - char *target_type; - gboolean handled = FALSE; - - target_type = gdk_atom_name (selection_data->target); - - printf ("target_type == %s\n", target_type); - - if (!strcmp (target_type, URI_LIST_TYPE)) { - GnomeVFSResult result; - GnomeVFSHandle *handle; - char *uri; - char *nl = strstr (selection_data->data, "\r\n"); - char *buf = NULL; - GnomeVFSFileInfo info; - - if (nl) - uri = g_strndup (selection_data->data, nl - (char*)selection_data->data); - else - uri = g_strdup (selection_data->data); - - printf ("uri == %s\n", uri); - - result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ); - if (result == GNOME_VFS_OK) { - result = gnome_vfs_get_file_info_from_handle (handle, &info, GNOME_VFS_FILE_INFO_DEFAULT); - if (result == GNOME_VFS_OK) { - GnomeVFSFileSize num_left; - GnomeVFSFileSize num_read; - GnomeVFSFileSize total_read; - - printf ("file size = %d\n", (int)info.size); - buf = g_malloc (info.size); - - num_left = info.size; - total_read = 0; - - while ((result = gnome_vfs_read (handle, buf + total_read, num_left, &num_read)) == GNOME_VFS_OK) { - num_left -= num_read; - total_read += num_read; - } - - printf ("read %d bytes\n", (int)total_read); - if (set_image_from_data (chooser, buf, total_read)) { - handled = TRUE; - } - else { - /* XXX we should pop up a warning dialog here */ - g_free (buf); - } - } - - gnome_vfs_close (handle); - } - else { - printf ("gnome_vfs_open failed (%s)\n", gnome_vfs_result_to_string (result)); - } - - g_free (uri); - } - - gtk_drag_finish (context, handled, FALSE, time); -} - - - -gboolean -e_image_chooser_set_from_file (EImageChooser *chooser, const char *filename) -{ - gchar *data; - gsize data_length; - - g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), FALSE); - g_return_val_if_fail (filename, FALSE); - - if (!g_file_get_contents (filename, &data, &data_length, NULL)) { - return FALSE; - } - - if (!set_image_from_data (chooser, data, data_length)) - g_free (data); - - return TRUE; -} - -void -e_image_chooser_set_editable (EImageChooser *chooser, gboolean editable) -{ - g_return_if_fail (E_IS_IMAGE_CHOOSER (chooser)); - - chooser->priv->editable = editable; - - gtk_widget_set_sensitive (chooser->priv->browse_button, editable); -} - -gboolean -e_image_chooser_get_image_data (EImageChooser *chooser, char **data, gsize *data_length) -{ - g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), FALSE); - g_return_val_if_fail (data != NULL, FALSE); - g_return_val_if_fail (data_length != NULL, FALSE); - - *data_length = chooser->priv->image_buf_size; - *data = g_malloc (*data_length); - memcpy (*data, chooser->priv->image_buf, *data_length); - - return TRUE; -} - -gboolean -e_image_chooser_set_image_data (EImageChooser *chooser, char *data, gsize data_length) -{ - char *buf; - - g_return_val_if_fail (E_IS_IMAGE_CHOOSER (chooser), FALSE); - g_return_val_if_fail (data != NULL, FALSE); - - /* yuck, a copy... */ - buf = g_malloc (data_length); - memcpy (buf, data, data_length); - - if (!set_image_from_data (chooser, buf, data_length)) { - g_free (buf); - return FALSE; - } - - return TRUE; -} diff --git a/widgets/misc/e-image-chooser.h b/widgets/misc/e-image-chooser.h deleted file mode 100644 index 852bd76dba..0000000000 --- a/widgets/misc/e-image-chooser.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-image-chooser.c - * Copyright (C) 2004 Novell, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _E_IMAGE_CHOOSER_H_ -#define _E_IMAGE_CHOOSER_H_ - -#include <gtk/gtkvbox.h> - -G_BEGIN_DECLS - -#define E_TYPE_IMAGE_CHOOSER (e_image_chooser_get_type ()) -#define E_IMAGE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_IMAGE_CHOOSER, EImageChooser)) -#define E_IMAGE_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_IMAGE_CHOOSER, EImageChooserClass)) -#define E_IS_IMAGE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_IMAGE_CHOOSER)) -#define E_IS_IMAGE_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_IMAGE_CHOOSER)) - -typedef struct _EImageChooser EImageChooser; -typedef struct _EImageChooserClass EImageChooserClass; -typedef struct _EImageChooserPrivate EImageChooserPrivate; - -struct _EImageChooser -{ - GtkVBox parent; - - EImageChooserPrivate *priv; -}; - -struct _EImageChooserClass -{ - GtkVBoxClass parent_class; - - /* signals */ - void (*changed) (EImageChooser *chooser); - - -}; - -GtkWidget *e_image_chooser_new (void); -GType e_image_chooser_get_type (void); - -gboolean e_image_chooser_set_from_file (EImageChooser *chooser, const char *filename); -gboolean e_image_chooser_set_image_data (EImageChooser *chooser, char *data, gsize data_length); -void e_image_chooser_set_editable (EImageChooser *chooser, gboolean editable); - -gboolean e_image_chooser_get_image_data (EImageChooser *chooser, char **data, gsize *data_length); - -#endif /* _E_IMAGE_CHOOSER_H_ */ diff --git a/widgets/misc/e-info-label.c b/widgets/misc/e-info-label.c deleted file mode 100644 index 620e9a3552..0000000000 --- a/widgets/misc/e-info-label.c +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell Inc. (www.novell.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <gtk/gtkimage.h> - -#include "e-info-label.h" -#include <gtk/gtklabel.h> -#include "e-clipped-label.h" - -#include <e-util/e-icon-factory.h> - -static GtkHBoxClass *el_parent; - -static void -el_init(GObject *o) -{ - /*EInfoLabel *el = (EInfoLabel *)o;*/ -} - -static void -el_finalise(GObject *o) -{ - ((GObjectClass *)el_parent)->finalize(o); -} - -static void -el_destroy (GtkObject *o) -{ - ((EInfoLabel *)o)->location = NULL; - ((EInfoLabel *)o)->info = NULL; - - ((GtkObjectClass *)el_parent)->destroy(o); -} - -static int -el_expose_event(GtkWidget *w, GdkEventExpose *event) -{ - int x = ((GtkContainer *)w)->border_width; - - /* This seems a hack to me, but playing with styles wouldn't affect the background */ - gtk_paint_flat_box(w->style, w->window, - GTK_STATE_ACTIVE, GTK_SHADOW_NONE, - &event->area, w, "EInfoLabel", - w->allocation.x+x, w->allocation.y+x, - w->allocation.width-x*2, w->allocation.height-x*2); - - return ((GtkWidgetClass *)el_parent)->expose_event(w, event); -} - -static void -el_class_init(GObjectClass *klass) -{ - klass->finalize = el_finalise; - - ((GtkObjectClass *)klass)->destroy = el_destroy; - ((GtkWidgetClass *)klass)->expose_event = el_expose_event; -} - -GType -e_info_label_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EInfoLabelClass), - NULL, NULL, - (GClassInitFunc)el_class_init, - NULL, NULL, - sizeof(EInfoLabel), 0, - (GInstanceInitFunc)el_init - }; - el_parent = g_type_class_ref(gtk_hbox_get_type()); - type = g_type_register_static(gtk_hbox_get_type(), "EInfoLabel", &info, 0); - } - - return type; -} - -/** - * e_info_label_new: - * @icon: - * - * Create a new info label widget. @icon is the name of the icon - * (from the icon theme) to use for the icon image. - * - * Return value: - **/ -GtkWidget * -e_info_label_new(const char *icon) -{ - EInfoLabel *el = g_object_new(e_info_label_get_type(), 0); - GtkWidget *image; - char *name = e_icon_factory_get_icon_filename (icon, E_ICON_SIZE_MENU); - - image = gtk_image_new_from_file(name); - g_free(name); - gtk_misc_set_padding((GtkMisc *)image, 6, 6); - gtk_box_pack_start((GtkBox *)el, image, FALSE, TRUE, 0); - gtk_widget_show(image); - - gtk_container_set_border_width((GtkContainer *)el, 3); - - return (GtkWidget *)el; -} - -/** - * e_info_label_set_info: - * @el: - * @location: - * @info: - * - * Set the information to show on the label. @location is some - * context about the current view. e.g. the folder name. If the - * label is too wide, this will be truncated. - * - * @info is some info about this location. - **/ -void -e_info_label_set_info(EInfoLabel *el, const char *location, const char *info) -{ - char *tmp; - - if (el->location == NULL) { - el->location = e_clipped_label_new(location, PANGO_WEIGHT_BOLD, 1.0); - el->info = gtk_label_new(NULL); - - gtk_misc_set_alignment((GtkMisc *)el->location, 0.0, 0.0); - gtk_misc_set_padding((GtkMisc *)el->location, 0, 6); - gtk_misc_set_alignment((GtkMisc *)el->info, 0.0, 1.0); - gtk_misc_set_padding((GtkMisc *)el->info, 0, 6); - - gtk_widget_show(el->location); - gtk_widget_show(el->info); - - gtk_box_pack_start((GtkBox *)el, (GtkWidget *)el->location, TRUE, TRUE, 0); - gtk_box_pack_end((GtkBox *)el, (GtkWidget *)el->info, FALSE, TRUE, 6); - gtk_widget_set_state((GtkWidget *)el, GTK_STATE_ACTIVE); - } else { - e_clipped_label_set_text((EClippedLabel *)el->location, location); - } - - tmp = g_strdup_printf("<span size=\"smaller\">%s</span>", info); - gtk_label_set_markup((GtkLabel *)el->info, tmp); - g_free(tmp); -} - diff --git a/widgets/misc/e-info-label.h b/widgets/misc/e-info-label.h deleted file mode 100644 index a0effadb9a..0000000000 --- a/widgets/misc/e-info-label.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- * - * - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell Inc. (www.novell.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _E_INFO_LABEL_H -#define _E_INFO_LABEL_H - -#include <gtk/gtkhbox.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_INFO_LABEL_GET_CLASS(emfv) ((EInfoLabelClass *) G_OBJECT_GET_CLASS (emfv)) - -typedef struct _EInfoLabel EInfoLabel; -typedef struct _EInfoLabelClass EInfoLabelClass; - -struct _EInfoLabel { - GtkHBox parent; - - struct _GtkWidget *location; - struct _GtkWidget *info; -}; - -struct _EInfoLabelClass { - GtkHBoxClass parent_class; -}; - -GType e_info_label_get_type(void); - -GtkWidget *e_info_label_new(const char *icon); -void e_info_label_set_info(EInfoLabel *, const char *loc, const char *info); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ! _E_INFO_LABEL_H */ diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c deleted file mode 100644 index 4e9a377460..0000000000 --- a/widgets/misc/e-map.c +++ /dev/null @@ -1,1788 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Map widget. - * - * Copyright (C) 2000-2001 Ximian, Inc. - * - * Authors: Hans Petter Jansson <hpj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#include <config.h> -#include <math.h> -#include <stdlib.h> -#include <gdk/gdkkeysyms.h> -#include <gtk/gtksignal.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <libart_lgpl/art_filterlevel.h> - -#include "e-map.h" - -/* Scroll step increment */ - -#define SCROLL_STEP_SIZE 32 - - -/* */ - -#define E_MAP_GET_WIDTH(map) gdk_pixbuf_get_width(((EMapPrivate *) E_MAP(map)->priv)->map_render_pixbuf) -#define E_MAP_GET_HEIGHT(map) gdk_pixbuf_get_height(((EMapPrivate *) E_MAP(map)->priv)->map_render_pixbuf) - - -/* Zoom state - keeps track of animation hacks */ - -typedef enum -{ - E_MAP_ZOOMED_IN, - E_MAP_ZOOMED_OUT, - E_MAP_ZOOMING_IN, - E_MAP_ZOOMING_OUT -} -EMapZoomState; - - -/* Private part of the EMap structure */ - -typedef struct -{ - /* Pointer to map image */ - GdkPixbuf *map_pixbuf, *map_render_pixbuf; - - /* Settings */ - gboolean frozen, smooth_zoom; - - /* Adjustments for scrolling */ - GtkAdjustment *hadj; - GtkAdjustment *vadj; - - /* Current scrolling offsets */ - int xofs, yofs; - - /* Realtime zoom data */ - EMapZoomState zoom_state; - double zoom_target_long, zoom_target_lat; - - /* Dots */ - GPtrArray *points; -} -EMapPrivate; - - -/* Internal prototypes */ - -static void e_map_class_init (EMapClass *class); -static void e_map_init (EMap *view); -static void e_map_finalize (GObject *object); -static void e_map_destroy (GtkObject *object); -static void e_map_unmap (GtkWidget *widget); -static void e_map_realize (GtkWidget *widget); -static void e_map_unrealize (GtkWidget *widget); -static void e_map_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void e_map_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static gint e_map_button_press (GtkWidget *widget, GdkEventButton *event); -static gint e_map_button_release (GtkWidget *widget, GdkEventButton *event); -static gint e_map_motion (GtkWidget *widget, GdkEventMotion *event); -static gint e_map_expose (GtkWidget *widget, GdkEventExpose *event); -static gint e_map_key_press (GtkWidget *widget, GdkEventKey *event); -static void e_map_set_scroll_adjustments (GtkWidget *widget, GtkAdjustment *hadj, GtkAdjustment *vadj); - -static void update_render_pixbuf (EMap *map, ArtFilterLevel interp, gboolean render_overlays); -static void set_scroll_area (EMap *view); -static void request_paint_area (EMap *view, GdkRectangle *area); -static void center_at (EMap *map, int x, int y, gboolean scroll); -static void smooth_center_at (EMap *map, int x, int y); -static void scroll_to (EMap *view, int x, int y); -static void zoom_do (EMap *map); -static gint load_map_background (EMap *view, gchar *name); -static void adjustment_changed_cb (GtkAdjustment *adj, gpointer data); -static void update_and_paint (EMap *map); -static void update_render_point (EMap *map, EMapPoint *point); -static void repaint_point (EMap *map, EMapPoint *point); - -static GtkWidgetClass *parent_class; - - -/* ----------------- * - * Widget management * - * ----------------- */ - - -/** - * e_map_get_type: - * @void: - * - * Registers the #EMap class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #EMap class. - **/ - -GtkType -e_map_get_type (void) -{ - static GtkType e_map_type = 0; - - if (!e_map_type) - { - static const GtkTypeInfo e_map_info = - { - "EMap", - sizeof (EMap), - sizeof (EMapClass), - (GtkClassInitFunc) e_map_class_init, - (GtkObjectInitFunc) e_map_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - e_map_type = gtk_type_unique (GTK_TYPE_WIDGET, &e_map_info); - } - - return e_map_type; -} - -/* Class initialization function for the map view */ - -static void -e_map_class_init (EMapClass *class) -{ - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - gobject_class = (GObjectClass *) class; - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = g_type_class_ref(GTK_TYPE_WIDGET); - - gobject_class->finalize = e_map_finalize; - - object_class->destroy = e_map_destroy; - - class->set_scroll_adjustments = e_map_set_scroll_adjustments; - widget_class->set_scroll_adjustments_signal = gtk_signal_new ("set_scroll_adjustments", - GTK_RUN_LAST, - GTK_CLASS_TYPE (object_class), - G_STRUCT_OFFSET (EMapClass, set_scroll_adjustments), - gtk_marshal_NONE__POINTER_POINTER, - GTK_TYPE_NONE, 2, - GTK_TYPE_ADJUSTMENT, - GTK_TYPE_ADJUSTMENT); - - widget_class->unmap = e_map_unmap; - widget_class->realize = e_map_realize; - widget_class->unrealize = e_map_unrealize; - widget_class->size_request = e_map_size_request; - widget_class->size_allocate = e_map_size_allocate; - widget_class->button_press_event = e_map_button_press; - widget_class->button_release_event = e_map_button_release; - widget_class->motion_notify_event = e_map_motion; - widget_class->expose_event = e_map_expose; - widget_class->key_press_event = e_map_key_press; -} - - -/* Object initialization function for the map view */ - -static void -e_map_init (EMap *view) -{ - EMapPrivate *priv; - - priv = g_new0 (EMapPrivate, 1); - view->priv = priv; - - load_map_background (view, MAP_DIR"/world_map-960.png"); - priv->frozen = FALSE; - priv->smooth_zoom = TRUE; - priv->zoom_state = E_MAP_ZOOMED_OUT; - priv->points = g_ptr_array_new (); - - GTK_WIDGET_SET_FLAGS (view, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (view, GTK_NO_WINDOW); -} - - -/* Destroy handler for the map view */ - -static void -e_map_destroy (GtkObject *object) -{ - EMap *view; - EMapPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_E_MAP (object)); - - view = E_MAP (object); - priv = view->priv; - - g_signal_handlers_disconnect_by_func (priv->hadj, adjustment_changed_cb, view); - g_signal_handlers_disconnect_by_func (priv->vadj, adjustment_changed_cb, view); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -/* Finalize handler for the map view */ - -static void -e_map_finalize (GObject *object) -{ - EMap *view; - EMapPrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_E_MAP (object)); - - view = E_MAP (object); - priv = view->priv; - - g_object_unref((priv->hadj)); - priv->hadj = NULL; - - g_object_unref((priv->vadj)); - priv->vadj = NULL; - - if (priv->map_pixbuf) - { - g_object_unref (priv->map_pixbuf); - priv->map_pixbuf = NULL; - } - - if (priv->map_render_pixbuf) - { - g_object_unref (priv->map_render_pixbuf); - priv->map_render_pixbuf = NULL; - } - - g_free (priv); - view->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (*G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Unmap handler for the map view */ - -static void -e_map_unmap (GtkWidget *widget) -{ - g_return_if_fail (widget != NULL); - g_return_if_fail (IS_E_MAP (widget)); - - if (GTK_WIDGET_CLASS (parent_class)->unmap) - (*GTK_WIDGET_CLASS (parent_class)->unmap) (widget); -} - - -/* Realize handler for the map view */ - -static void -e_map_realize (GtkWidget *widget) -{ - GdkWindowAttr attr; - int attr_mask; - - g_return_if_fail (widget != NULL); - g_return_if_fail (IS_E_MAP (widget)); - - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - attr.window_type = GDK_WINDOW_CHILD; - attr.x = widget->allocation.x; - attr.y = widget->allocation.y; - attr.width = widget->allocation.width; - attr.height = widget->allocation.height; - attr.wclass = GDK_INPUT_OUTPUT; - attr.visual = gdk_rgb_get_visual (); - attr.colormap = gdk_rgb_get_cmap (); - attr.event_mask = gtk_widget_get_events (widget) | - GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | - GDK_POINTER_MOTION_MASK; - - attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attr, attr_mask); - gdk_window_set_user_data (widget->window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - - gdk_window_set_back_pixmap (widget->window, NULL, FALSE); - update_render_pixbuf (E_MAP (widget), GDK_INTERP_BILINEAR, TRUE); -} - - -/* Unrealize handler for the map view */ - -static void -e_map_unrealize (GtkWidget *widget) -{ - g_return_if_fail (widget != NULL); - g_return_if_fail (IS_E_MAP (widget)); - - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (*GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); -} - - -/* Size_request handler for the map view */ - -static void -e_map_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - EMap *view; - EMapPrivate *priv; - - g_return_if_fail (widget != NULL); - g_return_if_fail (IS_E_MAP (widget)); - g_return_if_fail (requisition != NULL); - - view = E_MAP (widget); - priv = view->priv; - - /* TODO: Put real sizes here. */ - - requisition->width = gdk_pixbuf_get_width (priv->map_pixbuf); - requisition->height = gdk_pixbuf_get_height (priv->map_pixbuf); -} - - -/* Size_allocate handler for the map view */ - -static void -e_map_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - EMap *view; - EMapPrivate *priv; - int xofs, yofs; - GdkRectangle area; - - g_return_if_fail (widget != NULL); - g_return_if_fail (IS_E_MAP (widget)); - g_return_if_fail (allocation != NULL); - - view = E_MAP (widget); - priv = view->priv; - - xofs = priv->xofs; - yofs = priv->yofs; - - /* Resize the window */ - - widget->allocation = *allocation; - - if (GTK_WIDGET_REALIZED (widget)) - { - gdk_window_move_resize (widget->window, allocation->x, allocation->y, allocation->width, allocation->height); - - area.x = 0; - area.y = 0; - area.width = allocation->width; - area.height = allocation->height; - request_paint_area (E_MAP (widget), &area); - } - - update_render_pixbuf (view, GDK_INTERP_BILINEAR, TRUE); -} - - -/* Button press handler for the map view */ - -static gint -e_map_button_press (GtkWidget *widget, GdkEventButton *event) -{ - EMap *view; - EMapPrivate *priv; - - view = E_MAP (widget); - priv = view->priv; - - if (!GTK_WIDGET_HAS_FOCUS (widget)) gtk_widget_grab_focus (widget); - return TRUE; -} - - -/* Button release handler for the map view */ - -static gint -e_map_button_release (GtkWidget *widget, GdkEventButton *event) -{ - EMap *view; - EMapPrivate *priv; - - view = E_MAP (widget); - priv = view->priv; - - if (event->button != 1) return FALSE; - - gdk_pointer_ungrab (event->time); - return TRUE; -} - - -/* Motion handler for the map view */ - -static gint -e_map_motion (GtkWidget *widget, GdkEventMotion *event) -{ - EMap *view; - EMapPrivate *priv; - - view = E_MAP (widget); - priv = view->priv; - - return FALSE; - -/* - * if (event->is_hint) - * gdk_window_get_pointer(widget->window, &x, &y, &mods); - * else - * { - * x = event->x; - * y = event->y; - * } - * - * return TRUE; - */ -} - - -/* Expose handler for the map view */ - -static gint -e_map_expose (GtkWidget *widget, GdkEventExpose *event) -{ - EMap *view; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (IS_E_MAP (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - view = E_MAP (widget); - - request_paint_area (view, &event->area); - return TRUE; -} - - -/* Set_scroll_adjustments handler for the map view */ - -static void -e_map_set_scroll_adjustments (GtkWidget *widget, GtkAdjustment *hadj, GtkAdjustment *vadj) -{ - EMap *view; - EMapPrivate *priv; - gboolean need_adjust; - - g_return_if_fail (widget != NULL); - g_return_if_fail (IS_E_MAP (widget)); - - view = E_MAP (widget); - priv = view->priv; - - if (hadj) g_return_if_fail (GTK_IS_ADJUSTMENT (hadj)); - else hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - - if (vadj) g_return_if_fail (GTK_IS_ADJUSTMENT (vadj)); - else vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); - - if (priv->hadj && priv->hadj != hadj) - { - g_signal_handlers_disconnect_by_func (priv->hadj, - adjustment_changed_cb, - view); - g_object_unref (priv->hadj); - } - - if (priv->vadj && priv->vadj != vadj) - { - g_signal_handlers_disconnect_by_func (priv->vadj, - adjustment_changed_cb, - view); - g_object_unref (priv->vadj); - } - - need_adjust = FALSE; - - if (priv->hadj != hadj) - { - priv->hadj = hadj; - g_object_ref (priv->hadj); - gtk_object_sink (GTK_OBJECT (priv->hadj)); - - g_signal_connect (priv->hadj, "value_changed", - G_CALLBACK (adjustment_changed_cb), view); - - need_adjust = TRUE; - } - - if (priv->vadj != vadj) - { - priv->vadj = vadj; - g_object_ref (priv->vadj); - gtk_object_sink (GTK_OBJECT (priv->vadj)); - - g_signal_connect (priv->vadj, "value_changed", - G_CALLBACK (adjustment_changed_cb), view); - - need_adjust = TRUE; - } - - if (need_adjust) adjustment_changed_cb (NULL, view); -} - - -/* Key press handler for the map view */ - -static gint -e_map_key_press (GtkWidget *widget, GdkEventKey *event) -{ - EMap *view; - EMapPrivate *priv; - gboolean do_scroll; - int xofs, yofs; - - view = E_MAP (widget); - priv = view->priv; - - do_scroll = FALSE; - xofs = yofs = 0; - - switch (event->keyval) - { - case GDK_Up: - do_scroll = TRUE; - xofs = 0; - yofs = -SCROLL_STEP_SIZE; - break; - - case GDK_Down: - do_scroll = TRUE; - xofs = 0; - yofs = SCROLL_STEP_SIZE; - break; - - case GDK_Left: - do_scroll = TRUE; - xofs = -SCROLL_STEP_SIZE; - yofs = 0; - break; - - case GDK_Right: - do_scroll = TRUE; - xofs = SCROLL_STEP_SIZE; - yofs = 0; - break; - - default: - return FALSE; - } - - if (do_scroll) - { - int x, y; - - x = CLAMP (priv->xofs + xofs, 0, priv->hadj->upper - priv->hadj->page_size); - y = CLAMP (priv->yofs + yofs, 0, priv->vadj->upper - priv->vadj->page_size); - - scroll_to (view, x, y); - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->hadj), view); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->vadj), view); - - priv->hadj->value = x; - priv->vadj->value = y; - - gtk_signal_emit_by_name (GTK_OBJECT (priv->hadj), "value_changed"); - gtk_signal_emit_by_name (GTK_OBJECT (priv->vadj), "value_changed"); - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->hadj), view); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->vadj), view); - } - - return TRUE; -} - - -/* ---------------- * - * Widget interface * - * ---------------- */ - - -/** - * e_map_new: - * @void: - * - * Creates a new empty map widget. - * - * Return value: A newly-created map widget. - **/ - -EMap * -e_map_new () -{ - GtkWidget *widget; - - widget = GTK_WIDGET (gtk_type_new (TYPE_E_MAP)); - return (E_MAP (widget)); -} - - -/* --- Coordinate translation --- */ - - -/* These functions translate coordinates between longitude/latitude and - * the image x/y offsets, using the equidistant cylindrical projection. - * - * Longitude E <-180, 180] - * Latitude E <-90, 90] */ - -void -e_map_window_to_world (EMap *map, double win_x, double win_y, double *world_longitude, double *world_latitude) -{ - EMapPrivate *priv; - int width, height; - - g_return_if_fail (map); - - priv = map->priv; - g_return_if_fail (GTK_WIDGET_REALIZED (GTK_WIDGET (map))); - - width = gdk_pixbuf_get_width (priv->map_render_pixbuf); - height = gdk_pixbuf_get_height (priv->map_render_pixbuf); - - *world_longitude = (win_x + priv->xofs - (double) width / 2.0) / - ((double) width / 2.0) * 180.0; - *world_latitude = ((double) height / 2.0 - win_y - priv->yofs) / - ((double) height / 2.0) * 90.0; -} - - -void -e_map_world_to_window (EMap *map, double world_longitude, double world_latitude, double *win_x, double *win_y) -{ - EMapPrivate *priv; - int width, height; - - g_return_if_fail (map); - - priv = map->priv; - g_return_if_fail (priv->map_render_pixbuf); - g_return_if_fail (world_longitude >= -180.0 && world_longitude <= 180.0); - g_return_if_fail (world_latitude >= -90.0 && world_latitude <= 90.0); - - width = gdk_pixbuf_get_width (priv->map_render_pixbuf); - height = gdk_pixbuf_get_height (priv->map_render_pixbuf); - - *win_x = (width / 2.0 + (width / 2.0) * world_longitude / 180.0) - priv->xofs; - *win_y = (height / 2.0 - (height / 2.0) * world_latitude / 90.0) - priv->yofs; - -#ifdef DEBUG - printf ("Map size: (%d, %d)\nCoords: (%.1f, %.1f) -> (%.1f, %.1f)\n---\n", width, height, world_longitude, world_latitude, *win_x, *win_y); -#endif -} - - -/* --- Zoom --- */ - - -double -e_map_get_magnification (EMap *map) -{ - EMapPrivate *priv; - - priv = map->priv; - if (priv->zoom_state == E_MAP_ZOOMED_IN) return 2.0; - else return 1.0; -} - - -void -e_map_zoom_to_location (EMap *map, double longitude, double latitude) -{ - EMapPrivate *priv; - int width, height; - - g_return_if_fail (map); - g_return_if_fail (GTK_WIDGET_REALIZED (GTK_WIDGET (map))); - - priv = map->priv; - - if (priv->zoom_state == E_MAP_ZOOMED_IN) e_map_zoom_out (map); - else if (priv->zoom_state != E_MAP_ZOOMED_OUT) return; - - width = gdk_pixbuf_get_width (priv->map_render_pixbuf); - height = gdk_pixbuf_get_height (priv->map_render_pixbuf); - - priv->zoom_state = E_MAP_ZOOMING_IN; - priv->zoom_target_long = longitude; - priv->zoom_target_lat = latitude; - - zoom_do (map); -} - - -void -e_map_zoom_out (EMap *map) -{ - EMapPrivate *priv; - int width, height; - - g_return_if_fail (map); - g_return_if_fail (GTK_WIDGET_REALIZED (GTK_WIDGET (map))); - - priv = map->priv; - - if (priv->zoom_state != E_MAP_ZOOMED_IN) return; - - width = gdk_pixbuf_get_width (priv->map_render_pixbuf); - height = gdk_pixbuf_get_height (priv->map_render_pixbuf); - - priv->zoom_state = E_MAP_ZOOMING_OUT; - zoom_do (map); - priv->zoom_state = E_MAP_ZOOMED_OUT; -} - - -void -e_map_set_smooth_zoom (EMap *map, gboolean state) -{ - ((EMapPrivate *) map->priv)->smooth_zoom = state; -} - - -gboolean -e_map_get_smooth_zoom (EMap *map) -{ - return (((EMapPrivate *) map->priv)->smooth_zoom); -} - - -void -e_map_freeze (EMap *map) -{ - ((EMapPrivate *) map->priv)->frozen = TRUE; -} - - -void -e_map_thaw (EMap *map) -{ - ((EMapPrivate *) map->priv)->frozen = FALSE; - update_and_paint (map); -} - - -/* --- Point manipulation --- */ - - -EMapPoint * -e_map_add_point (EMap *map, gchar *name, double longitude, double latitude, guint32 color_rgba) -{ - EMapPrivate *priv; - EMapPoint *point; - - priv = map->priv; - point = g_new0 (EMapPoint, 1); - - point->name = name; /* Can be NULL */ - point->longitude = longitude; - point->latitude = latitude; - point->rgba = color_rgba; - - g_ptr_array_add (priv->points, (gpointer) point); - - if (!priv->frozen) - { - update_render_point (map, point); - repaint_point (map, point); - } - - return point; -} - - -void -e_map_remove_point (EMap *map, EMapPoint *point) -{ - EMapPrivate *priv; - - priv = map->priv; - g_ptr_array_remove (priv->points, point); - - if (!((EMapPrivate *) map->priv)->frozen) - { - /* FIXME: Re-scaling the whole pixbuf is more than a little - * overkill when just one point is removed */ - - update_render_pixbuf (map, GDK_INTERP_BILINEAR, TRUE); - repaint_point (map, point); - } - - g_free (point); -} - - -void -e_map_point_get_location (EMapPoint *point, double *longitude, double *latitude) -{ - *longitude = point->longitude; - *latitude = point->latitude; -} - - -gchar * -e_map_point_get_name (EMapPoint *point) -{ - return point->name; -} - - -guint32 -e_map_point_get_color_rgba (EMapPoint *point) -{ - return point->rgba; -} - - -void -e_map_point_set_color_rgba (EMap *map, EMapPoint *point, guint32 color_rgba) -{ - point->rgba = color_rgba; - - if (!((EMapPrivate *) map->priv)->frozen) - { - /* TODO: Redraw area around point only */ - - update_render_point (map, point); - repaint_point (map, point); - } -} - - -void -e_map_point_set_data (EMapPoint *point, gpointer data) -{ - point->user_data = data; -} - - -gpointer -e_map_point_get_data (EMapPoint *point) -{ - return point->user_data; -} - - -gboolean -e_map_point_is_in_view (EMap *map, EMapPoint *point) -{ - EMapPrivate *priv; - double x, y; - - priv = map->priv; - if (!priv->map_render_pixbuf) return FALSE; - - e_map_world_to_window (map, point->longitude, point->latitude, &x, &y); - - if (x >= 0 && x < GTK_WIDGET (map)->allocation.width && - y >= 0 && y < GTK_WIDGET (map)->allocation.height) - return TRUE; - - return FALSE; -} - - -EMapPoint * -e_map_get_closest_point (EMap *map, double longitude, double latitude, gboolean in_view) -{ - EMapPrivate *priv; - EMapPoint *point_chosen = NULL, *point; - double min_dist = 0.0, dist; - double dx, dy; - int i; - - priv = map->priv; - - for (i = 0; i < priv->points->len; i++) - { - point = g_ptr_array_index (priv->points, i); - if (in_view && !e_map_point_is_in_view (map, point)) continue; - - dx = point->longitude - longitude; - dy = point->latitude - latitude; - dist = dx * dx + dy * dy; - - if (!point_chosen || dist < min_dist) - { - min_dist = dist; - point_chosen = point; - } - } - - return point_chosen; -} - - -/* ------------------ * - * Internal functions * - * ------------------ */ - - -static void -repaint_visible (EMap *map) -{ - GdkRectangle area; - - area.x = 0; - area.y = 0; - area.width = GTK_WIDGET (map)->allocation.width; - area.height = GTK_WIDGET (map)->allocation.height; - - request_paint_area (map, &area); -} - - -static void -update_and_paint (EMap *map) -{ - update_render_pixbuf (map, GDK_INTERP_BILINEAR, TRUE); - repaint_visible (map); -} - - -static gint -load_map_background (EMap *view, gchar *name) -{ - EMapPrivate *priv; - GdkPixbuf *pb0; - - priv = view->priv; - - pb0 = gdk_pixbuf_new_from_file (name, NULL); - if (!pb0) - return FALSE; - - if (priv->map_pixbuf) g_object_unref (priv->map_pixbuf); - priv->map_pixbuf = pb0; - update_render_pixbuf (view, GDK_INTERP_BILINEAR, TRUE); - - return TRUE; -} - - -static void -update_render_pixbuf (EMap *map, ArtFilterLevel interp, gboolean render_overlays) -{ - EMapPrivate *priv; - EMapPoint *point; - int width, height, orig_width, orig_height; - double zoom; - int i; - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (map))) return; - - /* Set up value shortcuts */ - - priv = map->priv; - width = GTK_WIDGET (map)->allocation.width; - height = GTK_WIDGET (map)->allocation.height; - orig_width = gdk_pixbuf_get_width (priv->map_pixbuf); - orig_height = gdk_pixbuf_get_height (priv->map_pixbuf); - - /* Compute scaled width and height based on the extreme dimension */ - - if ((double) width / orig_width > (double) height / orig_height) - { - zoom = (double) width / (double) orig_width; - } - else - { - zoom = (double) height / (double) orig_height; - } - - if (priv->zoom_state == E_MAP_ZOOMED_IN) zoom *= 2.0; - height = (orig_height * zoom) + 0.5; - width = (orig_width * zoom) + 0.5; - - /* Reallocate the pixbuf */ - - if (priv->map_render_pixbuf) g_object_unref (priv->map_render_pixbuf); - priv->map_render_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, /* No alpha */ - 8, width, height); - - /* Scale the original map into the rendering pixbuf */ - - if (width > 1 && height > 1) - { - gdk_pixbuf_scale (priv->map_pixbuf, priv->map_render_pixbuf, 0, 0, /* Dest (x, y) */ - width, height, 0, 0, /* Offset (x, y) */ - zoom, zoom, /* Scale (x, y) */ - interp); - } - - if (render_overlays) - { - /* Add points */ - - for (i = 0; i < priv->points->len; i++) - { - point = g_ptr_array_index (priv->points, i); - update_render_point (map, point); - } - } - - /* Compute image offsets with respect to window */ - - set_scroll_area (map); -} - - -/* Queues a repaint of the specified area in window coordinates */ - -static void -request_paint_area (EMap *view, GdkRectangle *area) -{ - EMapPrivate *priv; - int width, height; - - if (!GTK_WIDGET_DRAWABLE (GTK_WIDGET (view)) || - !GTK_WIDGET_REALIZED (GTK_WIDGET (view))) return; - - priv = view->priv; - if (!priv->map_render_pixbuf) return; - - width = MIN (area->width, E_MAP_GET_WIDTH (view)); - height = MIN (area->height, E_MAP_GET_HEIGHT (view)); - - /* This satisfies paranoia. To be removed */ - - if (priv->xofs + width > gdk_pixbuf_get_width (priv->map_render_pixbuf)) - width = gdk_pixbuf_get_width (priv->map_render_pixbuf) - priv->xofs; - - if (priv->yofs + height > gdk_pixbuf_get_height (priv->map_render_pixbuf)) - height = gdk_pixbuf_get_height (priv->map_render_pixbuf) - priv->yofs; - - /* We rely on the fast case always being the case, since we load and - * preprocess the source pixbuf ourselves */ - - if (gdk_pixbuf_get_colorspace (priv->map_render_pixbuf) == GDK_COLORSPACE_RGB && !gdk_pixbuf_get_has_alpha (priv->map_render_pixbuf) && - gdk_pixbuf_get_bits_per_sample (priv->map_render_pixbuf) == 8) - { - guchar *pixels; - int rowstride; - - rowstride = gdk_pixbuf_get_rowstride (priv->map_render_pixbuf); - pixels = gdk_pixbuf_get_pixels (priv->map_render_pixbuf) + (area->y + priv->yofs) * rowstride + 3 * (area->x + priv->xofs); - gdk_draw_rgb_image_dithalign (GTK_WIDGET (view)->window, GTK_WIDGET (view)->style->black_gc, area->x, area->y, width, height, GDK_RGB_DITHER_NORMAL, pixels, rowstride, 0, 0); - return; - } - -#ifdef DEBUG - g_print ("Doing hard redraw.\n"); -#endif -} - -static void -put_pixel_with_clipping (GdkPixbuf *pixbuf, gint x, gint y, guint rgba) -{ - gint width, height; - gint rowstride, n_channels; - guchar *pixels, *pixel; - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - rowstride = gdk_pixbuf_get_rowstride (pixbuf); - n_channels = gdk_pixbuf_get_n_channels (pixbuf); - pixels = gdk_pixbuf_get_pixels (pixbuf); - - if (x < 0 || x >= width || y < 0 || y >= height) - return; - - pixel = pixels + (y * rowstride) + (x * n_channels); - - *pixel = (rgba >> 24); - *(pixel + 1) = (rgba >> 16) & 0x000000ff; - *(pixel + 2) = (rgba >> 8) & 0x000000ff; - - if (n_channels > 3) - { - *(pixel + 3) = rgba & 0x000000ff; - } -} - - -/* Redraw point in client pixbuf */ - -static void -update_render_point (EMap *map, EMapPoint *point) -{ - EMapPrivate *priv; - GdkPixbuf *pb; - int width, height; - double px, py; - - priv = map->priv; - pb = priv->map_render_pixbuf; - if (!pb) return; - - width = gdk_pixbuf_get_width (pb); - height = gdk_pixbuf_get_height (pb); - - e_map_world_to_window (map, point->longitude, point->latitude, &px, &py); - px += priv->xofs; - py += priv->yofs; - - put_pixel_with_clipping (pb, px, py, point->rgba); - put_pixel_with_clipping (pb, px - 1, py, point->rgba); - put_pixel_with_clipping (pb, px + 1, py, point->rgba); - put_pixel_with_clipping (pb, px, py - 1, point->rgba); - put_pixel_with_clipping (pb, px, py + 1, point->rgba); - - put_pixel_with_clipping (pb, px - 2, py, 0x000000ff); - put_pixel_with_clipping (pb, px + 2, py, 0x000000ff); - put_pixel_with_clipping (pb, px, py - 2, 0x000000ff); - put_pixel_with_clipping (pb, px, py + 2, 0x000000ff); - put_pixel_with_clipping (pb, px - 1, py - 1, 0x000000ff); - put_pixel_with_clipping (pb, px - 1, py + 1, 0x000000ff); - put_pixel_with_clipping (pb, px + 1, py - 1, 0x000000ff); - put_pixel_with_clipping (pb, px + 1, py + 1, 0x000000ff); -} - - -/* Repaint point on X server */ - -static void -repaint_point (EMap *map, EMapPoint *point) -{ - EMapPrivate *priv; - GdkRectangle area; - double px, py; - - if (!e_map_point_is_in_view (map, point)) return; - priv = map->priv; - - e_map_world_to_window (map, point->longitude, point->latitude, &px, &py); - - area.x = (int) px - 2; - area.y = (int) py - 2; - area.width = 5; - area.height = 5; - request_paint_area (map, &area); -} - - -static void -center_at (EMap *map, int x, int y, gboolean scroll) -{ - EMapPrivate *priv; - int pb_width, pb_height, - view_width, view_height; - - priv = map->priv; - - pb_width = E_MAP_GET_WIDTH (map); - pb_height = E_MAP_GET_HEIGHT (map); - - view_width = GTK_WIDGET (map)->allocation.width; - view_height = GTK_WIDGET (map)->allocation.height; - - x = CLAMP (x - (view_width / 2), 0, pb_width - view_width); - y = CLAMP (y - (view_height / 2), 0, pb_height - view_height); - - if (scroll) scroll_to (map, x, y); - else - { - priv->xofs = x; - priv->yofs = y; - } -} - - -static void -smooth_center_at (EMap *map, int x, int y) -{ - EMapPrivate *priv; - int pb_width, pb_height, - view_width, view_height; - int dx, dy; - - priv = map->priv; - - pb_width = E_MAP_GET_WIDTH (map); - pb_height = E_MAP_GET_HEIGHT (map); - - view_width = GTK_WIDGET (map)->allocation.width; - view_height = GTK_WIDGET (map)->allocation.height; - - x = CLAMP (x - (view_width / 2), 0, pb_width - view_width); - y = CLAMP (y - (view_height / 2), 0, pb_height - view_height); - - for (;;) - { - if (priv->xofs == x && priv->yofs == y) break; - - dx = (x < priv->xofs) ? -1 : (x > priv->xofs) ? 1 : 0; - dy = (y < priv->yofs) ? -1 : (y > priv->yofs) ? 1 : 0; - - scroll_to (map, priv->xofs + dx, priv->yofs + dy); - } -} - - -/* Scrolls the view to the specified offsets. Does not perform range checking! */ - -static void -scroll_to (EMap *view, int x, int y) -{ - EMapPrivate *priv; - int xofs, yofs; - GdkWindow *window; - GdkGC *gc; - int width, height; - int src_x, src_y; - int dest_x, dest_y; - GdkEvent *event; - - priv = view->priv; - - /* Compute offsets and check bounds */ - - xofs = x - priv->xofs; - yofs = y - priv->yofs; - - if (xofs == 0 && yofs == 0) return; - - priv->xofs = x; - priv->yofs = y; - - if (!GTK_WIDGET_DRAWABLE (view)) return; - - width = GTK_WIDGET (view)->allocation.width; - height = GTK_WIDGET (view)->allocation.height; - - if (abs (xofs) >= width || abs (yofs) >= height) - { - GdkRectangle area; - - area.x = 0; - area.y = 0; - area.width = width; - area.height = height; - - request_paint_area (view, &area); - return; - } - - window = GTK_WIDGET (view)->window; - - /* Copy the window area */ - - src_x = xofs < 0 ? 0 : xofs; - src_y = yofs < 0 ? 0 : yofs; - dest_x = xofs < 0 ? -xofs : 0; - dest_y = yofs < 0 ? -yofs : 0; - - gc = gdk_gc_new (window); - gdk_gc_set_exposures (gc, TRUE); - - gdk_window_copy_area (window, gc, dest_x, dest_y, window, src_x, src_y, width - abs (xofs), height - abs (yofs)); - - gdk_gc_destroy (gc); - - /* Add the scrolled-in region */ - - if (xofs) - { - GdkRectangle r; - - r.x = xofs < 0 ? 0 : width - xofs; - r.y = 0; - r.width = abs (xofs); - r.height = height; - - request_paint_area (view, &r); - } - - if (yofs) - { - GdkRectangle r; - - r.x = 0; - r.y = yofs < 0 ? 0 : height - yofs; - r.width = width; - r.height = abs (yofs); - - request_paint_area (view, &r); - } - - /* Process graphics exposures */ - - while ((event = gdk_event_get_graphics_expose (window)) != NULL) - { - gtk_widget_event (GTK_WIDGET (view), event); - - if (event->expose.count == 0) - { - gdk_event_free (event); - break; - } - - gdk_event_free (event); - } -} - - -static int divide_seq[] = -{ - /* Dividends for divisor of 2 */ - - -2, - - 1, - - /* Dividends for divisor of 4 */ - - -4, - - 1, 3, - - /* Dividends for divisor of 8 */ - - -8, - - 1, 5, 3, 7, - - /* Dividends for divisor of 16 */ - - -16, - - 1, 9, 5, 13, 3, 11, 7, 15, - - /* Dividends for divisor of 32 */ - - -32, - - 1, 17, 9, 25, 5, 21, 13, 29, 3, 19, - 11, 27, 7, 23, 15, 31, - - /* Dividends for divisor of 64 */ - - -64, - - 1, 33, 17, 49, 9, 41, 25, 57, 5, 37, - 21, 53, 13, 45, 29, 61, 3, 35, 19, 51, - 11, 43, 27, 59, 7, 39, 23, 55, 15, 47, - 31, 63, - - /* Dividends for divisor of 128 */ - - -128, - - 1, 65, 33, 97, 17, 81, 49, 113, 9, 73, - 41, 105, 25, 89, 57, 121, 5, 69, 37, 101, - 21, 85, 53, 117, 13, 77, 45, 109, 29, 93, - 61, 125, 3, 67, 35, 99, 19, 83, 51, 115, - 11, 75, 43, 107, 27, 91, 59, 123, 7, 71, - 39, 103, 23, 87, 55, 119, 15, 79, 47, 111, - 31, 95, 63, 127, - - /* Dividends for divisor of 256 */ - - -256, - - 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, - 81, 209, 49, 177, 113, 241, 9, 137, 73, 201, - 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, - 121, 249, 5, 133, 69, 197, 37, 165, 101, 229, - 21, 149, 85, 213, 53, 181, 117, 245, 13, 141, - 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, - 61, 189, 125, 253, 3, 131, 67, 195, 35, 163, - 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, - 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, - 91, 219, 59, 187, 123, 251, 7, 135, 71, 199, - 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, - 119, 247, 15, 143, 79, 207, 47, 175, 111, 239, - 31, 159, 95, 223, 63, 191, 127, 255, - - 0 -}; - - -typedef enum -{ - AXIS_X, - AXIS_Y -} -AxisType; - - -static void -blowup_window_area (GdkWindow *window, gint area_x, gint area_y, gint target_x, gint target_y, gint total_width, gint total_height, gfloat zoom_factor) -{ - GdkGC *gc; - AxisType strong_axis; - gfloat axis_factor, axis_counter; - gint zoom_chunk; - gint divisor_width = 0, divisor_height = 0; - gint divide_width_index, divide_height_index; - gint area_width, area_height; - gint i, j; - int line; - - - /* Set up the GC we'll be using */ - - gc = gdk_gc_new (window); - gdk_gc_set_exposures (gc, FALSE); - - /* Get area constraints */ - - gdk_window_get_size (window, &area_width, &area_height); - - /* Initialize area division array indexes */ - - divide_width_index = divide_height_index = 0; - - /* Initialize axis counter */ - - axis_counter = 0.0; - - /* Find the strong axis (which is the basis for iteration) and the ratio - * at which the other axis will be scaled. - * - * Also determine how many lines to expand in one fell swoop, and store - * this figure in zoom_chunk. */ - - if (area_width > area_height) - { - strong_axis = AXIS_X; - axis_factor = (double) area_height / (double) area_width; - zoom_chunk = MAX (1, area_width / 250); - i = (area_width * (zoom_factor - 1.0)) / zoom_chunk; - } - else - { - strong_axis = AXIS_Y; - axis_factor = (double) area_width / (double) area_height; - zoom_chunk = MAX (1, area_height / 250); - i = (area_height * (zoom_factor - 1.0)) / zoom_chunk; - } - - /* Go, go, devil bunnies! Gogo devil bunnies! */ - - for (; i > 0; i--) - { - /* Reset division sequence table indexes as necessary */ - - if (!divide_seq[divide_width_index]) divide_width_index = 0; - if (!divide_seq[divide_height_index]) divide_height_index = 0; - - /* Set new divisor if found in table */ - - if (divide_seq[divide_width_index] < 0) - divisor_width = abs (divide_seq[divide_width_index++]); - if (divide_seq[divide_height_index] < 0) - divisor_height = abs (divide_seq[divide_height_index++]); - - /* Widen */ - - if (strong_axis == AXIS_X || axis_counter >= 1.0) - { - line = ((divide_seq[divide_width_index] * area_width) / divisor_width) + 0.5; - - if ((line < target_x && target_x > area_width / 2) || (line > target_x && target_x > (area_width / 2) + zoom_chunk)) - { - /* Push left */ - - for (j = 0; j < zoom_chunk - 1; j++) - gdk_window_copy_area (window, gc, line + j + 1, 0, window, line, 0, 1, area_height); - - gdk_window_copy_area (window, gc, 0, 0, window, zoom_chunk, 0, line, area_height); - if (line > target_x) target_x -= zoom_chunk; - } - else - { - /* Push right */ - - for (j = 0; j < zoom_chunk - 1; j++) - gdk_window_copy_area (window, gc, line + j - (zoom_chunk - 1), 0, window, line - zoom_chunk, 0, 1, area_height); - - gdk_window_copy_area (window, gc, line, 0, window, line - zoom_chunk, 0, area_width - line, area_height); - if (line < target_x) target_x += zoom_chunk; - } - } - - if (strong_axis == AXIS_Y || axis_counter >= 1.0) - { - /* Heighten */ - - line = ((divide_seq[divide_height_index] * area_height) / divisor_height) + 0.5; - - if ((line < target_y && target_y > area_height / 2) || (line > target_y && target_y > (area_height / 2) + zoom_chunk)) - { - /* Push up */ - - for (j = 0; j < zoom_chunk - 1; j++) - gdk_window_copy_area (window, gc, 0, line + j + 1, window, 0, line, area_width, 1); - - gdk_window_copy_area (window, gc, 0, 0, window, 0, zoom_chunk, area_width, line); - if (line > target_y) target_y -= zoom_chunk; - } - else - { - /* Push down */ - - for (j = 0; j < zoom_chunk - 1; j++) - gdk_window_copy_area (window, gc, 0, line + j - (zoom_chunk - 1), window, 0, line - zoom_chunk, area_width, 1); - - gdk_window_copy_area (window, gc, 0, line, window, 0, line - zoom_chunk, area_width, area_height - line); - if (line < target_y) target_y += zoom_chunk; - } - } - - divide_width_index++; - divide_height_index++; - if (axis_counter >= 1.0) axis_counter -= 1.0; - axis_counter += axis_factor; - } - - /* Free our GC */ - - gdk_gc_destroy (gc); -} - - -static void -zoom_in_smooth (EMap *map) -{ - GdkRectangle area; - EMapPrivate *priv; - GdkWindow *window; - int width, height; - int win_width, win_height; - int target_width, target_height; - double x, y; - - g_return_if_fail (map); - g_return_if_fail (GTK_WIDGET_REALIZED (GTK_WIDGET (map))); - - area.x = 0; - area.y = 0; - area.width = GTK_WIDGET (map)->allocation.width; - area.height = GTK_WIDGET (map)->allocation.height; - - priv = map->priv; - window = GTK_WIDGET (map)->window; - width = gdk_pixbuf_get_width (priv->map_render_pixbuf); - height = gdk_pixbuf_get_height (priv->map_render_pixbuf); - win_width = GTK_WIDGET (map)->allocation.width; - win_height = GTK_WIDGET (map)->allocation.height; - target_width = win_width / 4; - target_height = win_height / 4; - - /* Center the target point as much as possible */ - - e_map_world_to_window (map, priv->zoom_target_long, priv->zoom_target_lat, &x, &y); - smooth_center_at (map, x + priv->xofs, y + priv->yofs); - - /* Render and paint a temporary map without overlays, so they don't get in - * the way (look ugly) while zooming */ - - update_render_pixbuf (map, GDK_INTERP_BILINEAR, FALSE); - request_paint_area (map, &area); - - /* Find out where in the area we're going to zoom to */ - - e_map_world_to_window (map, priv->zoom_target_long, priv->zoom_target_lat, &x, &y); - - /* Pre-render the zoomed-in map, so we can put it there quickly when the - * blowup sequence ends */ - - priv->zoom_state = E_MAP_ZOOMED_IN; - update_render_pixbuf (map, GDK_INTERP_BILINEAR, TRUE); - - /* Do the blowup */ - - blowup_window_area (window, priv->xofs, priv->yofs, x, y, width, height, 1.68); - - /* Set new scroll offsets and paint the zoomed map */ - - e_map_world_to_window (map, priv->zoom_target_long, priv->zoom_target_lat, &x, &y); - priv->xofs = CLAMP (priv->xofs + x - area.width / 2.0, 0, E_MAP_GET_WIDTH (map) - area.width); - priv->yofs = CLAMP (priv->yofs + y - area.height / 2.0, 0, E_MAP_GET_HEIGHT (map) - area.height); - - request_paint_area (map, &area); -} - - -static void -zoom_in (EMap *map) -{ - GdkRectangle area; - EMapPrivate *priv; - double x, y; - - priv = map->priv; - - area.x = 0; - area.y = 0; - area.width = GTK_WIDGET (map)->allocation.width; - area.height = GTK_WIDGET (map)->allocation.height; - - priv->zoom_state = E_MAP_ZOOMED_IN; - - update_render_pixbuf (map, GDK_INTERP_BILINEAR, TRUE); - - e_map_world_to_window (map, priv->zoom_target_long, priv->zoom_target_lat, &x, &y); - priv->xofs = CLAMP (priv->xofs + x - area.width / 2.0, 0, E_MAP_GET_WIDTH (map) - area.width); - priv->yofs = CLAMP (priv->yofs + y - area.height / 2.0, 0, E_MAP_GET_HEIGHT (map) - area.height); - - request_paint_area (map, &area); -} - - -static void -zoom_out (EMap *map) -{ - GdkRectangle area; - EMapPrivate *priv; - double longitude, latitude; - double x, y; - - priv = map->priv; - - area.x = 0; - area.y = 0; - area.width = GTK_WIDGET (map)->allocation.width; - area.height = GTK_WIDGET (map)->allocation.height; - - /* Must be done before update_render_pixbuf() */ - - e_map_window_to_world (map, area.width / 2, area.height / 2, - &longitude, &latitude); - - priv->zoom_state = E_MAP_ZOOMED_OUT; - update_render_pixbuf (map, GDK_INTERP_BILINEAR, TRUE); - - e_map_world_to_window (map, longitude, latitude, &x, &y); - center_at (map, x + priv->xofs, y + priv->yofs, FALSE); -/* request_paint_area (map, &area); */ - repaint_visible (map); -} - - -static void -zoom_do (EMap *map) -{ - EMapPrivate *priv; - - priv = map->priv; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->hadj), map); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->vadj), map); - - if (priv->zoom_state == E_MAP_ZOOMING_IN) - { - if (e_map_get_smooth_zoom (map)) zoom_in_smooth (map); - else zoom_in (map); - } - else if (priv->zoom_state == E_MAP_ZOOMING_OUT) - { -/* if (e_map_get_smooth_zoom(map)) zoom_out_smooth(map); */ - zoom_out (map); - } - - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->hadj), map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->vadj), map); - - set_scroll_area(map); -} - - -/* Callback used when an adjustment is changed */ - -static void -adjustment_changed_cb (GtkAdjustment *adj, gpointer data) -{ - EMap *view; - EMapPrivate *priv; - - view = E_MAP (data); - priv = view->priv; - - scroll_to (view, priv->hadj->value, priv->vadj->value); -} - - -static void -set_scroll_area (EMap *view) -{ - EMapPrivate *priv; - - priv = view->priv; - - if (!GTK_WIDGET_REALIZED (GTK_WIDGET (view))) return; - if (!priv->hadj || !priv->vadj) return; - - /* Set scroll increments */ - - priv->hadj->page_size = GTK_WIDGET (view)->allocation.width; - priv->hadj->page_increment = GTK_WIDGET (view)->allocation.width / 2; - priv->hadj->step_increment = SCROLL_STEP_SIZE; - - priv->vadj->page_size = GTK_WIDGET (view)->allocation.height; - priv->vadj->page_increment = GTK_WIDGET (view)->allocation.height / 2; - priv->vadj->step_increment = SCROLL_STEP_SIZE; - - /* Set scroll bounds and new offsets */ - - priv->hadj->lower = 0; - if (priv->map_render_pixbuf) - priv->hadj->upper = gdk_pixbuf_get_width (priv->map_render_pixbuf); - - priv->vadj->lower = 0; - if (priv->map_render_pixbuf) - priv->vadj->upper = gdk_pixbuf_get_height (priv->map_render_pixbuf); - - gtk_signal_emit_by_name (GTK_OBJECT (priv->hadj), "changed"); - gtk_signal_emit_by_name (GTK_OBJECT (priv->vadj), "changed"); - - priv->xofs = CLAMP (priv->xofs, 0, priv->hadj->upper - priv->hadj->page_size); - priv->yofs = CLAMP (priv->yofs, 0, priv->vadj->upper - priv->vadj->page_size); - - if (priv->hadj->value != priv->xofs) - { - priv->hadj->value = priv->xofs; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->hadj), view); - gtk_signal_emit_by_name (GTK_OBJECT (priv->hadj), "value_changed"); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->hadj), view); - } - - if (priv->vadj->value != priv->yofs) - { - priv->vadj->value = priv->yofs; - - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->vadj), view); - gtk_signal_emit_by_name (GTK_OBJECT (priv->vadj), "value_changed"); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->vadj), view); - } -} diff --git a/widgets/misc/e-map.h b/widgets/misc/e-map.h deleted file mode 100644 index 9e0098a5a2..0000000000 --- a/widgets/misc/e-map.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Map widget. - * - * Copyright (C) 2000-2001 Ximian, Inc. - * - * Authors: Hans Petter Jansson <hpj@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - */ - -#ifndef E_MAP_H -#define E_MAP_H - -#include <gtk/gtkwidget.h> - -#define TYPE_E_MAP (e_map_get_type ()) -#define E_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_E_MAP, EMap)) -#define E_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_E_MAP, EMapClass)) -#define IS_E_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_E_MAP)) -#define IS_E_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_E_MAP)) - -typedef struct _EMap EMap; -typedef struct _EMapClass EMapClass; -typedef struct _EMapPoint EMapPoint; - -struct _EMap -{ - GtkWidget widget; - - /* Private data */ - gpointer priv; -}; - -struct _EMapClass -{ - GtkWidgetClass parent_class; - - /* Notification signals */ - void (*zoom_fit) (EMap * view); - - /* GTK+ scrolling interface */ - void (*set_scroll_adjustments) (GtkWidget * widget, - GtkAdjustment * hadj, - GtkAdjustment * vadj); -}; - -/* The definition of Dot */ - -struct _EMapPoint -{ - gchar *name; /* Can be NULL */ - double longitude, latitude; - guint32 rgba; - gpointer user_data; -}; - - -/* --- Widget --- */ - -GtkType e_map_get_type (void); - -EMap *e_map_new (void); - -/* Stop doing redraws when map data changes (e.g. by modifying points) */ -void e_map_freeze (EMap *map); - -/* Do an immediate repaint, and start doing realtime repaints again */ -void e_map_thaw (EMap *map); - -/* --- Coordinate translation --- */ - -/* Translates window-relative coords to lat/long */ -void e_map_window_to_world (EMap *map, - double win_x, double win_y, - double *world_longitude, double *world_latitude); - -/* Translates lat/long to window-relative coordinates. Note that the - * returned coordinates can be negative or greater than the current size - * of the allocation area */ -void e_map_world_to_window (EMap *map, - double world_longitude, double world_latitude, - double *win_x, double *win_y); - -/* --- Zoom --- */ - -double e_map_get_magnification (EMap *map); - -/* Pass TRUE if we want the smooth zoom hack */ -void e_map_set_smooth_zoom (EMap *map, gboolean state); - -/* TRUE if smooth zoom hack will be employed */ -gboolean e_map_get_smooth_zoom (EMap *map); - -/* NB: Function definition will change shortly */ -void e_map_zoom_to_location (EMap *map, double longitude, double latitude); - -/* Zoom to mag factor 1.0 */ -void e_map_zoom_out (EMap *map); - -/* --- Points --- */ - -EMapPoint *e_map_add_point (EMap *map, gchar *name, - double longitude, double latitude, - guint32 color_rgba); - -void e_map_remove_point (EMap *map, EMapPoint *point); - -void e_map_point_get_location (EMapPoint *point, - double *longitude, double *latitude); - -gchar *e_map_point_get_name (EMapPoint *point); - -guint32 e_map_point_get_color_rgba (EMapPoint *point); - -void e_map_point_set_color_rgba (EMap *map, EMapPoint *point, guint32 color_rgba); - -void e_map_point_set_data (EMapPoint *point, gpointer data); - -gpointer e_map_point_get_data (EMapPoint *point); - -gboolean e_map_point_is_in_view (EMap *map, EMapPoint *point); - -EMapPoint *e_map_get_closest_point (EMap *map, double longitude, double latitude, - gboolean in_view); - -#endif diff --git a/widgets/misc/e-multi-config-dialog.c b/widgets/misc/e-multi-config-dialog.c deleted file mode 100644 index aa38ad1e34..0000000000 --- a/widgets/misc/e-multi-config-dialog.c +++ /dev/null @@ -1,444 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-multi-config-dialog.c - * - * Copyright (C) 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-multi-config-dialog.h" - -#include "e-clipped-label.h" - -#include <gal/e-table/e-table-scrolled.h> -#include <gal/e-table/e-table-memory-store.h> -#include <gal/e-table/e-cell-pixbuf.h> -#include <gal/e-table/e-cell-vbox.h> -#include <gal/e-table/e-cell-text.h> - -#include <gdk-pixbuf/gdk-pixbuf.h> - - -#define PARENT_TYPE gtk_dialog_get_type () -static GtkDialogClass *parent_class = NULL; - -#define SWITCH_PAGE_INTERVAL 250 - - -struct _EMultiConfigDialogPrivate { - GSList *pages; - - GtkWidget *list_e_table; - ETableModel *list_e_table_model; - - GtkWidget *notebook; - - int set_page_timeout_id; - int set_page_timeout_page; -}; - - -/* ETable stuff. */ - -static char *list_e_table_spec = - "<ETableSpecification cursor-mode=\"line\"" - " selection-mode=\"browse\"" - " no-headers=\"true\"" - " alternating-row-colors=\"false\"" - " horizontal-resize=\"true\"" - ">" - " <ETableColumn model_col=\"0\"" - " expansion=\"1.0\"" - " cell=\"vbox\"" - " minimum_width=\"32\"" - " resizable=\"true\"" - " _title=\"blah\"" - " compare=\"string\"/>" - " <ETableState>" - " <column source=\"0\"/>" - " <grouping>" - " </grouping>" - " </ETableState>" - "</ETableSpecification>"; - -/* Page handling. */ - -static GtkWidget * -create_page_container (const char *description, - GtkWidget *widget) -{ - GtkWidget *vbox; - - vbox = gtk_vbox_new (FALSE, 0); - -#if 0 - label = e_clipped_label_new (description); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); - - separator = gtk_hseparator_new (); - gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0); - - gtk_widget_show (label); - gtk_widget_show (separator); -#endif - - gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0); - - gtk_widget_show (widget); - gtk_widget_show (vbox); - - return vbox; -} - -/* Timeout for switching pages (so it's more comfortable navigating with the - keyboard). */ - -static int -set_page_timeout_callback (void *data) -{ - EMultiConfigDialog *multi_config_dialog; - EMultiConfigDialogPrivate *priv; - - multi_config_dialog = E_MULTI_CONFIG_DIALOG (data); - priv = multi_config_dialog->priv; - - gtk_notebook_set_page (GTK_NOTEBOOK (priv->notebook), priv->set_page_timeout_page); - - priv->set_page_timeout_id = 0; - return FALSE; -} - - -/* Button handling. */ - -static void -do_close (EMultiConfigDialog *dialog) -{ - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - - -/* ETable signals. */ - -static void -table_cursor_change_callback (ETable *etable, - int row, - void *data) -{ - EMultiConfigDialog *dialog; - EMultiConfigDialogPrivate *priv; - - dialog = E_MULTI_CONFIG_DIALOG (data); - priv = dialog->priv; - - if (priv->set_page_timeout_id == 0) - priv->set_page_timeout_id = g_timeout_add (SWITCH_PAGE_INTERVAL, - set_page_timeout_callback, - dialog); - - priv->set_page_timeout_page = row; -} - - -/* GObject methods. */ - -static void -impl_finalize (GObject *object) -{ - EMultiConfigDialog *dialog; - EMultiConfigDialogPrivate *priv; - - dialog = E_MULTI_CONFIG_DIALOG (object); - priv = dialog->priv; - - if (priv->set_page_timeout_id != 0) - g_source_remove (priv->set_page_timeout_id); - - g_slist_free (priv->pages); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* GtkDialog methods. */ - -static void -impl_response (GtkDialog *dialog, int response_id) -{ - EMultiConfigDialog *multi_config_dialog; - EMultiConfigDialogPrivate *priv; - GError *error; - - multi_config_dialog = E_MULTI_CONFIG_DIALOG (dialog); - priv = multi_config_dialog->priv; - - error = NULL; - - switch (response_id) { - case GTK_RESPONSE_HELP: - gnome_help_display_desktop (NULL, - "evolution-" BASE_VERSION, - "evolution-" BASE_VERSION ".xml", - "config-prefs", - &error); - if (error != NULL) - g_warning ("%s", error->message); - break; - case GTK_RESPONSE_CLOSE: - default: - do_close (multi_config_dialog); - break; - } -} - - -/* GObject ctors. */ - -static void -class_init (EMultiConfigDialogClass *class) -{ - GObjectClass *object_class; - GtkDialogClass *dialog_class; - - object_class = G_OBJECT_CLASS (class); - object_class->finalize = impl_finalize; - - dialog_class = GTK_DIALOG_CLASS (class); - dialog_class->response = impl_response; - - parent_class = g_type_class_ref (PARENT_TYPE); -} - -#define RGB_COLOR(color) (((color).red & 0xff00) << 8 | \ - ((color).green & 0xff00) | \ - ((color).blue & 0xff00) >> 8) - -static void -fill_in_pixbufs (EMultiConfigDialog *dialog, int row) -{ - GdkPixbuf *original = e_table_model_value_at (dialog->priv->list_e_table_model, 1, row); - GtkWidget *canvas; - guint32 colors[3]; - int i; - - if (original == NULL) - return; - - canvas = GTK_WIDGET (e_table_scrolled_get_table (E_TABLE_SCROLLED (dialog->priv->list_e_table))->table_canvas); - - colors[0] = RGB_COLOR (canvas->style->bg [GTK_STATE_SELECTED]); - colors[1] = RGB_COLOR (canvas->style->bg [GTK_STATE_ACTIVE]); - colors[2] = RGB_COLOR (canvas->style->base [GTK_STATE_NORMAL]); - - for (i = 0; i < 3; i++) { - GdkPixbuf *pixbuf = gdk_pixbuf_composite_color_simple (original, - gdk_pixbuf_get_width (original), - gdk_pixbuf_get_height (original), - GDK_INTERP_BILINEAR, - 255, - 1, - colors[i], colors[i]); - e_table_model_set_value_at (dialog->priv->list_e_table_model, i + 2, row, pixbuf); - g_object_unref(pixbuf); - } -} - -static void -canvas_realize (GtkWidget *widget, EMultiConfigDialog *dialog) -{ - int i; - int row_count; - - row_count = e_table_model_row_count (dialog->priv->list_e_table_model); - for (i = 0; i < row_count; i++) { - fill_in_pixbufs (dialog, i); - } -} - - -static ETableMemoryStoreColumnInfo columns[] = { - E_TABLE_MEMORY_STORE_STRING, - E_TABLE_MEMORY_STORE_PIXBUF, - E_TABLE_MEMORY_STORE_PIXBUF, - E_TABLE_MEMORY_STORE_PIXBUF, - E_TABLE_MEMORY_STORE_PIXBUF, - E_TABLE_MEMORY_STORE_TERMINATOR -}; - -static void -init (EMultiConfigDialog *multi_config_dialog) -{ - EMultiConfigDialogPrivate *priv; - ETableModel *list_e_table_model; - GtkWidget *dialog_vbox; - GtkWidget *hbox; - GtkWidget *notebook; - GtkWidget *list_e_table; - ETableExtras *extras; - ECell *pixbuf; - ECell *text; - ECell *vbox; - - gtk_dialog_set_has_separator (GTK_DIALOG (multi_config_dialog), FALSE); - gtk_widget_realize (GTK_WIDGET (multi_config_dialog)); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (multi_config_dialog)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (multi_config_dialog)->action_area), 12); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); - dialog_vbox = GTK_DIALOG (multi_config_dialog)->vbox; - - gtk_container_add (GTK_CONTAINER (dialog_vbox), hbox); - - list_e_table_model = e_table_memory_store_new (columns); - - vbox = e_cell_vbox_new (); - - pixbuf = e_cell_pixbuf_new(); - g_object_set (G_OBJECT (pixbuf), - "focused_column", 2, - "selected_column", 3, - "unselected_column", 4, - NULL); - e_cell_vbox_append (E_CELL_VBOX (vbox), pixbuf, 1); - g_object_unref (pixbuf); - - text = e_cell_text_new (NULL, GTK_JUSTIFY_CENTER); - e_cell_vbox_append (E_CELL_VBOX (vbox), text, 0); - g_object_unref (text); - - extras = e_table_extras_new (); - e_table_extras_add_cell (extras, "vbox", vbox); - - list_e_table = e_table_scrolled_new (list_e_table_model, extras, list_e_table_spec, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_e_table), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (list_e_table)), - "cursor_change", G_CALLBACK (table_cursor_change_callback), multi_config_dialog); - - g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (list_e_table))->table_canvas, - "realize", G_CALLBACK (canvas_realize), multi_config_dialog); - - g_object_unref (extras); - - gtk_box_pack_start (GTK_BOX (hbox), list_e_table, FALSE, TRUE, 0); - - notebook = gtk_notebook_new (); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE); - gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE); - gtk_box_pack_start (GTK_BOX (hbox), notebook, TRUE, TRUE, 0); - - gtk_widget_show (hbox); - gtk_widget_show (notebook); - gtk_widget_show (list_e_table); - - gtk_dialog_add_buttons (GTK_DIALOG (multi_config_dialog), - GTK_STOCK_HELP, GTK_RESPONSE_HELP, - GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (multi_config_dialog), GTK_RESPONSE_OK); - - - gtk_window_set_policy (GTK_WINDOW (multi_config_dialog), - FALSE /* allow_shrink */, - TRUE /* allow_grow */, - FALSE /* auto_shrink */); - - priv = g_new (EMultiConfigDialogPrivate, 1); - priv->pages = NULL; - priv->list_e_table = list_e_table; - priv->list_e_table_model = list_e_table_model; - priv->notebook = notebook; - priv->set_page_timeout_id = 0; - priv->set_page_timeout_page = 0; - - multi_config_dialog->priv = priv; -} - - -GtkWidget * -e_multi_config_dialog_new (void) -{ - EMultiConfigDialog *dialog; - - dialog = gtk_type_new (e_multi_config_dialog_get_type ()); - - return GTK_WIDGET (dialog); -} - - -void -e_multi_config_dialog_add_page (EMultiConfigDialog *dialog, - const char *title, - const char *description, - GdkPixbuf *icon, - EConfigPage *page_widget) -{ - EMultiConfigDialogPrivate *priv; - - g_return_if_fail (E_IS_MULTI_CONFIG_DIALOG (dialog)); - g_return_if_fail (title != NULL); - g_return_if_fail (description != NULL); - g_return_if_fail (E_IS_CONFIG_PAGE (page_widget)); - - priv = dialog->priv; - - priv->pages = g_slist_append (priv->pages, page_widget); - - e_table_memory_store_insert (E_TABLE_MEMORY_STORE (priv->list_e_table_model), -1, NULL, title, icon, NULL, NULL, NULL); - - if (GTK_WIDGET_REALIZED (e_table_scrolled_get_table (E_TABLE_SCROLLED (dialog->priv->list_e_table))->table_canvas)) { - fill_in_pixbufs (dialog, e_table_model_row_count (priv->list_e_table_model) - 1); - } - - gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), - create_page_container (description, GTK_WIDGET (page_widget)), - NULL); - - if (priv->pages->next == NULL) { - ETable *table; - - /* FIXME: This is supposed to select the first entry by default - but it doesn't seem to work at all. */ - table = e_table_scrolled_get_table (E_TABLE_SCROLLED (priv->list_e_table)); - e_table_set_cursor_row (table, 0); - e_selection_model_select_all (e_table_get_selection_model (table)); - } -} - -void -e_multi_config_dialog_show_page (EMultiConfigDialog *dialog, int page) -{ - EMultiConfigDialogPrivate *priv; - - g_return_if_fail (dialog != NULL); - g_return_if_fail (E_IS_MULTI_CONFIG_DIALOG (dialog)); - - priv = dialog->priv; - - e_table_set_cursor_row (e_table_scrolled_get_table (E_TABLE_SCROLLED (priv->list_e_table)), page); - gtk_notebook_set_page (GTK_NOTEBOOK (priv->notebook), page); -} - - -E_MAKE_TYPE (e_multi_config_dialog, "EMultiConfigDialog", EMultiConfigDialog, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-multi-config-dialog.h b/widgets/misc/e-multi-config-dialog.h deleted file mode 100644 index 0a4c32d7a4..0000000000 --- a/widgets/misc/e-multi-config-dialog.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-multi-config-dialog.h - * - * Copyright (C) 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_MULTI_CONFIG_DIALOG_H_ -#define _E_MULTI_CONFIG_DIALOG_H_ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-config-page.h" - -#include <gtk/gtkdialog.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_MULTI_CONFIG_DIALOG (e_multi_config_dialog_get_type ()) -#define E_MULTI_CONFIG_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_MULTI_CONFIG_DIALOG, EMultiConfigDialog)) -#define E_MULTI_CONFIG_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_MULTI_CONFIG_DIALOG, EMultiConfigDialogClass)) -#define E_IS_MULTI_CONFIG_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_MULTI_CONFIG_DIALOG)) -#define E_IS_MULTI_CONFIG_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MULTI_CONFIG_DIALOG)) - - -typedef struct _EMultiConfigDialog EMultiConfigDialog; -typedef struct _EMultiConfigDialogPrivate EMultiConfigDialogPrivate; -typedef struct _EMultiConfigDialogClass EMultiConfigDialogClass; - -struct _EMultiConfigDialog { - GtkDialog parent; - - EMultiConfigDialogPrivate *priv; -}; - -struct _EMultiConfigDialogClass { - GtkDialogClass parent_class; -}; - - -GtkType e_multi_config_dialog_get_type (void); -GtkWidget *e_multi_config_dialog_new (void); - -void e_multi_config_dialog_add_page (EMultiConfigDialog *dialog, - const char *title, - const char *description, - GdkPixbuf *icon, - EConfigPage *page); -void e_multi_config_dialog_show_page (EMultiConfigDialog *dialog, - int page); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_MULTI_CONFIG_DIALOG_H_ */ diff --git a/widgets/misc/e-pilot-settings.c b/widgets/misc/e-pilot-settings.c deleted file mode 100644 index 2304b570de..0000000000 --- a/widgets/misc/e-pilot-settings.c +++ /dev/null @@ -1,198 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-pilot-settings.c - * - * Copyright (C) 2001 JP Rosevear - * - * 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: JP Rosevear - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> -#include <libgnome/gnome-i18n.h> -#include "e-source-option-menu.h" -#include "e-pilot-settings.h" - -struct _EPilotSettingsPrivate -{ - GtkWidget *source; - GtkWidget *secret; - GtkWidget *cat; - GtkWidget *cat_btn; -}; - - -static void class_init (EPilotSettingsClass *klass); -static void init (EPilotSettings *ps); - -static GObjectClass *parent_class = NULL; - - -GType -e_pilot_settings_get_type (void) -{ - static GType type = 0; - - if (!type) { - static GTypeInfo info = { - sizeof (EPilotSettingsClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) class_init, - NULL, NULL, - sizeof (EPilotSettings), - 0, - (GInstanceInitFunc) init - }; - type = g_type_register_static (GTK_TYPE_TABLE, "EPilotSettings", &info, 0); - } - - return type; -} - -static void -class_init (EPilotSettingsClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (GTK_TYPE_TABLE); -} - -static void -init (EPilotSettings *ps) -{ - EPilotSettingsPrivate *priv; - - priv = g_new0 (EPilotSettingsPrivate, 1); - - ps->priv = priv; -} - - -static void -build_ui (EPilotSettings *ps, ESourceList *source_list) -{ - EPilotSettingsPrivate *priv; - GtkWidget *lbl; - - priv = ps->priv; - - gtk_table_resize (GTK_TABLE (ps), 2, 2); - gtk_container_set_border_width (GTK_CONTAINER (ps), 4); - gtk_table_set_col_spacings (GTK_TABLE (ps), 6); - - lbl = gtk_label_new (_("Sync with:")); - gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5); - priv->source = e_source_option_menu_new (source_list); - gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 0, 1); - gtk_table_attach_defaults (GTK_TABLE (ps), priv->source, 1, 2, 0, 1); - gtk_widget_show (lbl); - gtk_widget_show (priv->source); - - lbl = gtk_label_new (_("Sync Private Records:")); - gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5); - priv->secret = gtk_check_button_new (); - gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 1, 2); - gtk_table_attach_defaults (GTK_TABLE (ps), priv->secret, 1, 2, 1, 2); - gtk_widget_show (lbl); - gtk_widget_show (priv->secret); - -#if 0 - lbl = gtk_label_new (_("Sync Categories:")); - gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5); - priv->cat = gtk_check_button_new (); - gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 2, 3); - gtk_table_attach_defaults (GTK_TABLE (ps), priv->cat, 1, 2, 2, 3); - gtk_widget_show (lbl); - gtk_widget_show (priv->cat); -#endif -} - - - -GtkWidget * -e_pilot_settings_new (ESourceList *source_list) -{ - EPilotSettings *ps; - EPilotSettingsPrivate *priv; - - ps = g_object_new (E_TYPE_PILOT_SETTINGS, NULL); - priv = ps->priv; - - build_ui (ps, source_list); - - return GTK_WIDGET (ps); -} - -ESource * -e_pilot_settings_get_source (EPilotSettings *ps) -{ - EPilotSettingsPrivate *priv; - - g_return_val_if_fail (ps != NULL, FALSE); - g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), FALSE); - - priv = ps->priv; - - return e_source_option_menu_peek_selected (E_SOURCE_OPTION_MENU (priv->source)); -} - -void -e_pilot_settings_set_source (EPilotSettings *ps, ESource *source) -{ - EPilotSettingsPrivate *priv; - - g_return_if_fail (ps != NULL); - g_return_if_fail (E_IS_PILOT_SETTINGS (ps)); - - priv = ps->priv; - - e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source), source); -} - -gboolean -e_pilot_settings_get_secret (EPilotSettings *ps) -{ - EPilotSettingsPrivate *priv; - - g_return_val_if_fail (ps != NULL, FALSE); - g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), FALSE); - - priv = ps->priv; - - return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->secret)); -} - -void -e_pilot_settings_set_secret (EPilotSettings *ps, gboolean secret) -{ - EPilotSettingsPrivate *priv; - - g_return_if_fail (ps != NULL); - g_return_if_fail (E_IS_PILOT_SETTINGS (ps)); - - priv = ps->priv; - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->secret), - secret); -} - diff --git a/widgets/misc/e-pilot-settings.h b/widgets/misc/e-pilot-settings.h deleted file mode 100644 index 123265a393..0000000000 --- a/widgets/misc/e-pilot-settings.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-pilot-settings.h - * - * Copyright (C) 2001 JP Rosevear - * - * 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: JP Rosevear - */ - -#ifndef _E_PILOT_SETTINGS_H_ -#define _E_PILOT_SETTINGS_H_ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libedataserver/e-source-list.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define E_TYPE_PILOT_SETTINGS (e_pilot_settings_get_type ()) -#define E_PILOT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_PILOT_SETTINGS, EPilotSettings)) -#define E_PILOT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_PILOT_SETTINGS, EPilotSettingsClass)) -#define E_IS_PILOT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_PILOT_SETTINGS)) -#define E_IS_PILOT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_PILOT_SETTINGS)) - - -typedef struct _EPilotSettings EPilotSettings; -typedef struct _EPilotSettingsPrivate EPilotSettingsPrivate; -typedef struct _EPilotSettingsClass EPilotSettingsClass; - -#define E_PILOT_SETTINGS_TABLE_ROWS 3 -#define E_PILOT_SETTINGS_TABLE_COLS 3 - -struct _EPilotSettings { - GtkTable parent; - - EPilotSettingsPrivate *priv; -}; - -struct _EPilotSettingsClass { - GtkTableClass parent_class; -}; - - -GType e_pilot_settings_get_type (void); -GtkWidget *e_pilot_settings_new (ESourceList *source_list); - -ESource *e_pilot_settings_get_source (EPilotSettings *ps); -void e_pilot_settings_set_source (EPilotSettings *ps, ESource *source); - -gboolean e_pilot_settings_get_secret (EPilotSettings *ps); -void e_pilot_settings_set_secret (EPilotSettings *ps, gboolean secret); - -G_END_DECLS - -#endif diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c deleted file mode 100644 index 3851fad9a7..0000000000 --- a/widgets/misc/e-search-bar.c +++ /dev/null @@ -1,1244 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-search-bar.c - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * Ettore Perazzoli <ettore@ximian.com> - * Jon Trowbridge <trow@ximian.com> - - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkdrawingarea.h> -#include <gtk/gtkeventbox.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkoptionmenu.h> -#include <gtk/gtkmain.h> - -#include <gal/widgets/e-unicode.h> -#include <gal/widgets/e-gui-utils.h> - -#include <libgnome/gnome-i18n.h> - -#include <bonobo/bonobo-ui-util.h> - -#include <stdlib.h> -#include <string.h> - -#include "e-search-bar.h" -#include "e-util-marshal.h" - - -enum { - QUERY_CHANGED, - MENU_ACTIVATED, - SEARCH_ACTIVATED, - - LAST_SIGNAL -}; - -static gint esb_signals [LAST_SIGNAL] = { 0, }; - -static GtkHBoxClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_ITEM_ID, - PROP_SUBITEM_ID, - PROP_TEXT, -}; - - -/* Forward decls. */ - -static int find_id (GtkWidget *menu, int idin, const char *type, GtkWidget **widget); -static void activate_by_subitems (ESearchBar *esb, gint item_id, ESearchBarSubitem *subitems); - -static void emit_search_activated (ESearchBar *esb); -static void emit_query_changed (ESearchBar *esb); - - -/* Utility functions. */ - -static void -set_find_now_sensitive (ESearchBar *search_bar, - gboolean sensitive) -{ - if (search_bar->ui_component != NULL) - bonobo_ui_component_set_prop (search_bar->ui_component, - "/commands/ESearchBar:FindNow", - "sensitive", sensitive ? "1" : "0", NULL); - - gtk_widget_set_sensitive (search_bar->activate_button, sensitive); -} - -static char * -verb_name_from_id (int id) -{ - return g_strdup_printf ("ESearchBar:Activate:%d", id); -} - -/* This implements the "clear" action, i.e. clears the text and then emits - * ::search_activated. */ - -static void -clear_search (ESearchBar *esb) -{ - int item_row; - GtkWidget *widget; - ESearchBarSubitem *subitems; - - e_search_bar_set_text (esb, ""); - e_search_bar_set_item_id (esb, 0); - - item_row = find_id (esb->option_menu, 0, "EsbChoiceId", &widget); - - subitems = g_object_get_data (G_OBJECT (widget), "EsbChoiceSubitems"); - activate_by_subitems (esb, 0, subitems); - - emit_search_activated (esb); -} - -/* Frees an array of subitem information */ -static void -free_subitems (ESearchBarSubitem *subitems) -{ - ESearchBarSubitem *s; - - g_assert (subitems != NULL); - - for (s = subitems; s->id != -1; s++) { - if (s->text) - g_free (s->text); - } - - g_free (subitems); -} - -static void -free_menu_items (ESearchBar *esb) -{ - GSList *p; - - if (esb->menu_items == NULL) - return; - - for (p = esb->menu_items; p != NULL; p = p->next) { - ESearchBarItem *item; - - item = (ESearchBarItem *) p->data; - - /* (No submitems for the menu_items, so no need to free that - member.) */ - - g_free (item->text); - g_free (item); - } - - g_slist_free (esb->menu_items); - esb->menu_items = NULL; -} - - -/* Signals. */ - -static void -emit_query_changed (ESearchBar *esb) -{ - g_signal_emit (esb, esb_signals [QUERY_CHANGED], 0); -} - -static void -emit_search_activated (ESearchBar *esb) -{ - if (esb->pending_activate) { - g_source_remove (esb->pending_activate); - esb->pending_activate = 0; - } - - g_signal_emit (esb, esb_signals [SEARCH_ACTIVATED], 0); - - set_find_now_sensitive (esb, FALSE); -} - -static void -emit_menu_activated (ESearchBar *esb, int item) -{ - g_signal_emit (esb, - esb_signals [MENU_ACTIVATED], 0, - item); -} - - -/* Callbacks -- Standard verbs. */ - -static void -search_now_verb_cb (BonoboUIComponent *ui_component, - void *data, - const char *verb_name) -{ - ESearchBar *esb; - - esb = E_SEARCH_BAR (data); - emit_search_activated (esb); -} - -static void -clear_verb_cb (BonoboUIComponent *ui_component, - void *data, - const char *verb_name) -{ - ESearchBar *esb; - - esb = E_SEARCH_BAR (data); - clear_search (esb); -} - -static void -setup_standard_verbs (ESearchBar *search_bar) -{ - bonobo_ui_component_add_verb (search_bar->ui_component, "ESearchBar:Clear", - clear_verb_cb, search_bar); - bonobo_ui_component_add_verb (search_bar->ui_component, "ESearchBar:FindNow", - search_now_verb_cb, search_bar); - - bonobo_ui_component_set (search_bar->ui_component, "/", - ("<commands>" - " <cmd name=\"ESearchBar:Clear\"/>" - " <cmd name=\"ESearchBar:FindNow\"/>" - "</commands>"), - NULL); - - /* Make sure the entries are created with the correct sensitivity. */ - set_find_now_sensitive (search_bar, FALSE); -} - -/* Callbacks -- The verbs for all the definable items. */ - -static void -search_verb_cb (BonoboUIComponent *ui_component, - void *data, - const char *verb_name) -{ - ESearchBar *esb; - const char *p; - int id; - - esb = E_SEARCH_BAR (data); - - p = strrchr (verb_name, ':'); - g_assert (p != NULL); - - id = atoi (p + 1); - emit_menu_activated (esb, id); -} - -static void -entry_activated_cb (GtkWidget *widget, - ESearchBar *esb) -{ - emit_search_activated (esb); -} - -static void -entry_changed_cb (GtkWidget *widget, - ESearchBar *esb) -{ - set_find_now_sensitive (esb, TRUE); -} - -static void -subitem_activated_cb (GtkWidget *widget, ESearchBar *esb) -{ - gint id, subid; - - id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbItemId")); - subid = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbSubitemId")); - - esb->item_id = id; - esb->subitem_id = subid; - - set_find_now_sensitive (esb, TRUE); -} - -static char * -string_without_underscores (const char *s) -{ - char *new_string; - const char *sp; - char *dp; - - new_string = g_malloc (strlen (s) + 1); - - dp = new_string; - for (sp = s; *sp != '\0'; sp ++) { - if (*sp != '_') { - *dp = *sp; - dp ++; - } else if (sp[1] == '_') { - /* Translate "__" in "_". */ - *dp = '_'; - dp ++; - sp ++; - } - } - *dp = 0; - - return new_string; -} - -static void -activate_by_subitems (ESearchBar *esb, gint item_id, ESearchBarSubitem *subitems) -{ - if (subitems == NULL) { - /* This item uses the entry. */ - - /* Remove the menu */ - if (esb->suboption && esb->subitem_id != -1) { - g_assert (esb->suboption->parent == esb->entry_box); - g_assert (!esb->entry || esb->entry->parent == NULL); - gtk_container_remove (GTK_CONTAINER (esb->entry_box), esb->suboption); - } - - /* Create and add the entry */ - - if (esb->entry == NULL) { - esb->entry = gtk_entry_new(); - gtk_widget_set_size_request (esb->entry, 4, -1); - g_object_ref (esb->entry); - g_signal_connect (esb->entry, "changed", - G_CALLBACK (entry_changed_cb), esb); - g_signal_connect (esb->entry, "activate", - G_CALLBACK (entry_activated_cb), esb); - gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->entry); - gtk_widget_show(esb->entry); - - esb->subitem_id = -1; - } - - if (esb->subitem_id == -1) { - g_assert (esb->entry->parent == esb->entry_box); - g_assert (!esb->suboption || esb->suboption->parent == NULL); - } else { - gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->entry); - gtk_widget_grab_focus (esb->entry); - - esb->subitem_id = -1; - - } - } else { - /* This item uses a submenu */ - GtkWidget *menu; - GtkWidget *menu_item; - gint i; - - /* Remove the entry */ - if (esb->entry && esb->subitem_id == -1) { - g_assert (esb->entry->parent == esb->entry_box); - g_assert (!esb->suboption || esb->suboption->parent == NULL); - gtk_container_remove (GTK_CONTAINER (esb->entry_box), esb->entry); - } - - /* Create and add the menu */ - - if (esb->suboption == NULL) { - esb->suboption = gtk_option_menu_new (); - g_object_ref (esb->suboption); - gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->suboption); - gtk_widget_show (esb->suboption); - - esb->subitem_id = subitems[0].id; - } - - if (esb->subitem_id != -1) { - g_assert (esb->suboption->parent == esb->entry_box); - g_assert (!esb->entry || esb->entry->parent == NULL); - } else { - gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->suboption); - esb->subitem_id = subitems[0].id; - } - - /* Create the items */ - - esb->suboption_menu = menu = gtk_menu_new (); - for (i = 0; subitems[i].id != -1; ++i) { - if (subitems[i].text) { - char *str; - - if (subitems[i].translate) - str = string_without_underscores (_(subitems[i].text)); - else - str = string_without_underscores (subitems[i].text); - - menu_item = gtk_menu_item_new_with_label (str); - - g_free (str); - } else { - menu_item = gtk_menu_item_new (); - gtk_widget_set_sensitive (menu_item, FALSE); - } - - g_object_set_data (G_OBJECT (menu_item), "EsbItemId", - GINT_TO_POINTER (item_id)); - g_object_set_data (G_OBJECT (menu_item), "EsbSubitemId", - GINT_TO_POINTER (subitems[i].id)); - - g_signal_connect (menu_item, - "activate", - G_CALLBACK (subitem_activated_cb), - esb); - - gtk_widget_show (menu_item); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item); - } - - gtk_option_menu_remove_menu (GTK_OPTION_MENU (esb->suboption)); - gtk_option_menu_set_menu (GTK_OPTION_MENU (esb->suboption), menu); - } - - if (esb->activate_button) - gtk_widget_set_sensitive (esb->activate_button, subitems == NULL); -} - -static void -option_activated_cb (GtkWidget *widget, - ESearchBar *esb) -{ - int id; - - id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "EsbChoiceId")); - - activate_by_subitems (esb, id, g_object_get_data (G_OBJECT (widget), "EsbChoiceSubitems")); - - esb->item_id = id; - emit_query_changed (esb); -} - -static void -activate_button_clicked_cb (GtkWidget *widget, - ESearchBar *esb) -{ - emit_search_activated (esb); - - gtk_widget_grab_focus (esb->entry); -} - -static void -clear_button_clicked_cb (GtkWidget *widget, - ESearchBar *esb) -{ - clear_search (esb); - - gtk_widget_grab_focus (esb->entry); -} - - -/* Widgetry creation. */ - -/* This function exists to fix the irreparable GtkOptionMenu stupidity. In - fact, this lame-ass widget adds a 1-pixel-wide empty border around the - button for no reason. So we have add a 1-pixel-wide border around the the - buttons we have in the search bar to make things look right. This is done - through an event box. */ -static GtkWidget * -put_in_spacer_widget (GtkWidget *widget) -{ - GtkWidget *holder; - - holder = gtk_event_box_new (); - gtk_container_set_border_width (GTK_CONTAINER (holder), 1); - gtk_container_add (GTK_CONTAINER (holder), widget); - - return holder; -} - -static ESearchBarSubitem * -copy_subitems (ESearchBarSubitem *subitems) -{ - gint i, N; - ESearchBarSubitem *copy; - - if (subitems == NULL) - return NULL; - - for (N=0; subitems[N].id != -1; ++N); - copy = g_new (ESearchBarSubitem, N+1); - - for (i=0; i<N; ++i) { - copy[i].text = g_strdup (subitems[i].text); - copy[i].id = subitems[i].id; - copy[i].translate = subitems[i].translate; - } - - copy[N].text = NULL; - copy[N].id = -1; - - return copy; -} - -static void -append_xml_menu_item (GString *xml, - const char *name, - const char *label, - const char *verb, - const char *accelerator) -{ - char *encoded_label; - - encoded_label = bonobo_ui_util_encode_str (label); - g_string_append_printf (xml, "<menuitem name=\"%s\" verb=\"%s\" label=\"%s\"", - name, verb, encoded_label); - g_free (encoded_label); - - if (accelerator != NULL) - g_string_append_printf (xml, " accel=\"%s\"", accelerator); - - g_string_append (xml, "/>"); -} - -static void -remove_bonobo_menus (ESearchBar *esb) -{ - if (bonobo_ui_component_get_container (esb->ui_component) == CORBA_OBJECT_NIL) - return; - - bonobo_ui_component_rm (esb->ui_component, "/menu/SearchPlaceholder", NULL); -} - -static void -setup_bonobo_menus (ESearchBar *esb) -{ - GString *xml; - GSList *p; - char *verb_name; - char *encoded_title; - - xml = g_string_new (""); - - encoded_title = bonobo_ui_util_encode_str (_("_Search")); - g_string_append_printf (xml, "<submenu name=\"Search\" label=\"%s\">", encoded_title); - g_free (encoded_title); - - g_string_append (xml, "<placeholder name=\"SearchBar\">"); - - append_xml_menu_item (xml, "FindNow", _("_Find Now"), "ESearchBar:FindNow", NULL); - append_xml_menu_item (xml, "Clear", _("_Clear"), "ESearchBar:Clear", "*Control**Shift*q"); - - for (p = esb->menu_items; p != NULL; p = p->next) { - const ESearchBarItem *item; - - item = (const ESearchBarItem *) p->data; - - verb_name = verb_name_from_id (item->id); - bonobo_ui_component_add_verb (esb->ui_component, verb_name, search_verb_cb, esb); - - if (item->text == NULL) - g_string_append (xml, "<separator/>"); - else - append_xml_menu_item (xml, verb_name, item->text, verb_name, NULL); - - g_free (verb_name); - } - - g_string_append (xml, "</placeholder>"); - g_string_append (xml, "</submenu>"); - - remove_bonobo_menus (esb); - bonobo_ui_component_set (esb->ui_component, "/menu/SearchPlaceholder", xml->str, NULL); - - g_string_free (xml, TRUE); -} - -static void -update_bonobo_menus (ESearchBar *esb) -{ - setup_bonobo_menus (esb); -} - -static void -set_menu (ESearchBar *esb, - ESearchBarItem *items) -{ - int i; - - free_menu_items (esb); - - if (items == NULL) - return; - - for (i = 0; items[i].id != -1; i++) { - ESearchBarItem *new_item; - - g_assert (items[i].subitems == NULL); - - new_item = g_new (ESearchBarItem, 1); - new_item->text = g_strdup (_(items[i].text)); - new_item->id = items[i].id; - new_item->subitems = NULL; - - esb->menu_items = g_slist_append (esb->menu_items, new_item); - } - - if (esb->ui_component != NULL) - update_bonobo_menus (esb); -} - -/* Callback used when an option item is destroyed. We have to destroy its - * suboption items. - */ -static void -option_item_destroy_cb (GtkObject *object, gpointer data) -{ - ESearchBarSubitem *subitems; - - subitems = data; - - g_assert (subitems != NULL); - free_subitems (subitems); - g_object_set_data (G_OBJECT (object), "EsbChoiceSubitems", NULL); -} - -static void -set_option (ESearchBar *esb, ESearchBarItem *items) -{ - GtkWidget *menu; - int i; - - if (esb->option) { - gtk_widget_destroy (esb->option_menu); - } else { - esb->option = gtk_option_menu_new (); - gtk_widget_show (esb->option); - gtk_box_pack_start (GTK_BOX (esb), esb->option, FALSE, FALSE, 0); - } - - esb->option_menu = menu = gtk_menu_new (); - for (i = 0; items[i].id != -1; i++) { - GtkWidget *item; - ESearchBarSubitem *subitems = NULL; - - if (items[i].text) { - char *str; - - str = string_without_underscores (_(items[i].text)); - item = gtk_menu_item_new_with_label (str); - g_free (str); - } else { - item = gtk_menu_item_new (); - gtk_widget_set_sensitive (item, FALSE); - } - - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - - g_object_set_data (G_OBJECT (item), "EsbChoiceId", GINT_TO_POINTER(items[i].id)); - - if (items[i].subitems != NULL) { - subitems = copy_subitems (items[i].subitems); - g_object_set_data (G_OBJECT (item), "EsbChoiceSubitems", subitems); - g_signal_connect (item, "destroy", - G_CALLBACK (option_item_destroy_cb), subitems); - } - - if (i == 0) - activate_by_subitems (esb, items[i].id, subitems); - - g_signal_connect (item, "activate", - G_CALLBACK (option_activated_cb), - esb); - } - - gtk_widget_show_all (menu); - - gtk_option_menu_set_menu (GTK_OPTION_MENU (esb->option), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (esb->option), 0); - - gtk_widget_set_sensitive (esb->option, TRUE); -} - -static GtkWidget * -add_button (ESearchBar *esb, - const char *text, - GCallback callback) -{ - GtkWidget *label; - GtkWidget *holder; - GtkWidget *button; - - label = gtk_label_new_with_mnemonic (text); - gtk_misc_set_padding (GTK_MISC (label), 2, 0); - gtk_widget_show (label); - - /* See the comment in `put_in_spacer_widget()' to understand - why we have to do this. */ - - button = gtk_button_new (); - gtk_widget_show (button); - gtk_container_add (GTK_CONTAINER (button), label); - - holder = put_in_spacer_widget (button); - gtk_widget_show (holder); - - g_signal_connect (G_OBJECT (button), "clicked", callback, esb); - - gtk_box_pack_end (GTK_BOX (esb), holder, FALSE, FALSE, 1); - - return button; -} - -static int -find_id (GtkWidget *menu, int idin, const char *type, GtkWidget **widget) -{ - GList *l = GTK_MENU_SHELL (menu)->children; - int row = -1, i = 0, id; - - if (widget) - *widget = NULL; - while (l) { - id = GPOINTER_TO_INT (g_object_get_data (l->data, type)); - if (id == idin) { - row = i; - if (widget) - *widget = l->data; - break; - } - i++; - l = l->next; - } - return row; -} - - -/* GtkObject methods. */ - -static void -impl_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - ESearchBar *esb = E_SEARCH_BAR (object); - - switch (prop_id) { - case PROP_ITEM_ID: - g_value_set_int (value, e_search_bar_get_item_id (esb)); - break; - - case PROP_SUBITEM_ID: - g_value_set_int (value, e_search_bar_get_subitem_id (esb)); - break; - - case PROP_TEXT: - g_value_set_string_take_ownership (value, e_search_bar_get_text (esb)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -impl_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - ESearchBar *esb = E_SEARCH_BAR(object); - - switch (prop_id) { - case PROP_ITEM_ID: - e_search_bar_set_item_id (esb, g_value_get_int (value)); - break; - - case PROP_SUBITEM_ID: - e_search_bar_set_subitem_id (esb, g_value_get_int (value)); - break; - - case PROP_TEXT: - e_search_bar_set_text (esb, g_value_get_string (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -impl_dispose (GObject *object) -{ - ESearchBar *esb = E_SEARCH_BAR (object); - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_SEARCH_BAR (object)); - - /* These three we do need to unref, because we explicitly hold - references to them. */ - - if (esb->ui_component != NULL) { - bonobo_object_unref (BONOBO_OBJECT (esb->ui_component)); - esb->ui_component = NULL; - } - if (esb->entry) { - g_object_unref (esb->entry); - esb->entry = NULL; - } - if (esb->suboption) { - g_object_unref (esb->suboption); - esb->suboption = NULL; - } - - if (esb->pending_activate) { - g_source_remove (esb->pending_activate); - esb->pending_activate = 0; - } - - free_menu_items (esb); - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - - -static void -class_init (ESearchBarClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (gtk_hbox_get_type ()); - - object_class->set_property = impl_set_property; - object_class->get_property = impl_get_property; - object_class->dispose = impl_dispose; - - klass->set_menu = set_menu; - klass->set_option = set_option; - - g_object_class_install_property (object_class, PROP_ITEM_ID, - g_param_spec_int ("item_id", - _("Item ID"), - /*_( */"XXX blurb" /*)*/, - 0, 0, 0, - G_PARAM_READWRITE | G_PARAM_LAX_VALIDATION)); - - g_object_class_install_property (object_class, PROP_SUBITEM_ID, - g_param_spec_int ("subitem_id", - _("Subitem ID"), - /*_( */"XXX blurb" /*)*/, - 0, 0, 0, - G_PARAM_READWRITE | G_PARAM_LAX_VALIDATION)); - - g_object_class_install_property (object_class, PROP_TEXT, - g_param_spec_string ("text", - _("Text"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - esb_signals [QUERY_CHANGED] = - g_signal_new ("query_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESearchBarClass, query_changed), - NULL, NULL, - e_util_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - esb_signals [MENU_ACTIVATED] = - g_signal_new ("menu_activated", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESearchBarClass, menu_activated), - NULL, NULL, - e_util_marshal_NONE__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - - esb_signals [SEARCH_ACTIVATED] = - g_signal_new ("search_activated", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESearchBarClass, search_activated), - NULL, NULL, - e_util_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -init (ESearchBar *esb) -{ - esb->ui_component = NULL; - esb->menu_items = NULL; - - esb->option = NULL; - esb->entry = NULL; - esb->suboption = NULL; - - esb->option_menu = NULL; - esb->suboption_menu = NULL; - esb->activate_button = NULL; - esb->clear_button = NULL; - esb->entry_box = NULL; - - esb->pending_activate = 0; - - esb->item_id = 0; - esb->subitem_id = 0; -} - - -/* Object construction. */ - -static gint -idle_activate_hack (gpointer ptr) -{ - ESearchBar *esb = E_SEARCH_BAR (ptr); - esb->pending_activate = 0; - emit_search_activated (esb); - return FALSE; -} - -void -e_search_bar_construct (ESearchBar *search_bar, - ESearchBarItem *menu_items, - ESearchBarItem *option_items) -{ - g_return_if_fail (search_bar != NULL); - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - g_return_if_fail (option_items != NULL); - - gtk_box_set_spacing (GTK_BOX (search_bar), 1); - - search_bar->clear_button = add_button (search_bar, _("_Clear"), - G_CALLBACK (clear_button_clicked_cb)); - search_bar->activate_button = add_button (search_bar, _("Find _Now"), - G_CALLBACK (activate_button_clicked_cb)); - - e_search_bar_set_menu (search_bar, menu_items); - - search_bar->entry_box = gtk_hbox_new (0, FALSE); - - e_search_bar_set_option (search_bar, option_items); - - gtk_widget_show (search_bar->entry_box); - gtk_box_pack_start (GTK_BOX(search_bar), search_bar->entry_box, TRUE, TRUE, 0); - - /* - * If the default choice for the option menu has subitems, then we need to - * activate the search immediately. However, the developer won't have - * connected to the activated signal until after the object is constructed, - * so we can't emit here. Thus we launch a one-shot idle function that will - * emit the changed signal, so that the proper callback will get invoked. - */ - if (search_bar->subitem_id >= 0) { - gtk_widget_set_sensitive (search_bar->activate_button, FALSE); - - search_bar->pending_activate = g_idle_add (idle_activate_hack, search_bar); - } -} - -void -e_search_bar_set_menu (ESearchBar *search_bar, ESearchBarItem *menu_items) -{ - g_return_if_fail (search_bar != NULL); - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - - ((ESearchBarClass *) GTK_OBJECT_GET_CLASS (search_bar))->set_menu (search_bar, menu_items); -} - -void -e_search_bar_add_menu (ESearchBar *search_bar, ESearchBarItem *menu_item) -{ - g_return_if_fail (search_bar != NULL); - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - - set_menu (search_bar, menu_item); -} - -void -e_search_bar_set_option (ESearchBar *search_bar, ESearchBarItem *option_items) -{ - g_return_if_fail (search_bar != NULL); - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - g_return_if_fail (option_items != NULL); - - ((ESearchBarClass *) GTK_OBJECT_GET_CLASS (search_bar))->set_option (search_bar, option_items); -} - -/** - * e_search_bar_set_suboption: - * @search_bar: A search bar. - * @option_id: Identifier of the main option menu item under which the subitems - * are to be set. - * @subitems: Array of subitem information. - * - * Sets the items for the secondary option menu of a search bar. - **/ -void -e_search_bar_set_suboption (ESearchBar *search_bar, int option_id, ESearchBarSubitem *subitems) -{ - int row; - GtkWidget *item; - ESearchBarSubitem *old_subitems; - ESearchBarSubitem *new_subitems; - - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - - row = find_id (search_bar->option_menu, option_id, "EsbChoiceId", &item); - g_return_if_fail (row != -1); - g_assert (item != NULL); - - old_subitems = g_object_get_data (G_OBJECT (item), "EsbChoiceSubitems"); - if (old_subitems) { - /* This was connected in set_option() */ - g_signal_handlers_disconnect_matched (item, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - old_subitems); - free_subitems (old_subitems); - g_object_set_data (G_OBJECT (item), "EsbChoiceSubitems", NULL); - } - - if (subitems) { - new_subitems = copy_subitems (subitems); - g_object_set_data (G_OBJECT (item), "EsbChoiceSubitems", new_subitems); - g_signal_connect (item, "destroy", - G_CALLBACK (option_item_destroy_cb), new_subitems); - } else - new_subitems = NULL; - - if (search_bar->item_id == option_id) - activate_by_subitems (search_bar, option_id, new_subitems); -} - -GtkWidget * -e_search_bar_new (ESearchBarItem *menu_items, - ESearchBarItem *option_items) -{ - GtkWidget *widget; - - g_return_val_if_fail (option_items != NULL, NULL); - - widget = GTK_WIDGET (gtk_type_new (e_search_bar_get_type ())); - - e_search_bar_construct (E_SEARCH_BAR (widget), menu_items, option_items); - - return widget; -} - -void -e_search_bar_set_ui_component (ESearchBar *search_bar, - BonoboUIComponent *ui_component) -{ - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - - if (search_bar->ui_component != NULL) { - remove_bonobo_menus (search_bar); - bonobo_object_unref (BONOBO_OBJECT (search_bar->ui_component)); - } - - search_bar->ui_component = ui_component; - if (ui_component != NULL) { - bonobo_object_ref (BONOBO_OBJECT (ui_component)); - setup_standard_verbs (search_bar); - setup_bonobo_menus (search_bar); - } -} - -void -e_search_bar_set_menu_sensitive (ESearchBar *search_bar, int id, gboolean state) -{ - char *verb_name; - char *path; - - verb_name = verb_name_from_id (id); - path = g_strconcat ("/commands/", verb_name, NULL); - g_free (verb_name); - - bonobo_ui_component_set_prop (search_bar->ui_component, path, - "sensitive", state ? "1" : "0", - NULL); - - g_free (path); -} - -GType -e_search_bar_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESearchBarClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESearchBar), - 0, /* n_preallocs */ - (GInstanceInitFunc) init, - }; - - type = g_type_register_static (gtk_hbox_get_type (), "ESearchBar", &info, 0); - } - - return type; -} - -/** - * e_search_bar_set_item_id: - * @search_bar: A search bar. - * @id: Identifier of the item to set. - * - * Sets the active item in the options menu of a search bar. - **/ -void -e_search_bar_set_item_id (ESearchBar *search_bar, int id) -{ - int row; - - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - - row = find_id (search_bar->option_menu, id, "EsbChoiceId", NULL); - g_return_if_fail (row != -1); - - search_bar->item_id = id; - gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->option), row); - emit_query_changed (search_bar); -} - -/** - * e_search_bar_get_item_id: - * @search_bar: A search bar. - * - * Queries the currently selected item in the options menu of a search bar. - * - * Return value: Identifier of the selected item in the options menu. - **/ -int -e_search_bar_get_item_id (ESearchBar *search_bar) -{ - g_return_val_if_fail (search_bar != NULL, -1); - g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), -1); - - return search_bar->item_id; -} - -void -e_search_bar_set_subitem_id (ESearchBar *search_bar, int id) -{ - int row; - - g_return_if_fail (search_bar != NULL); - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - - row = find_id (search_bar->suboption_menu, id, "EsbSubitemId", NULL); - g_return_if_fail (row != -1); - - search_bar->subitem_id = id; - gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->suboption), row); -} - -/** - * e_search_bar_get_subitem_id: - * @search_bar: A search bar. - * - * Queries the currently selected item in the suboptions menu of a search bar. - * - * Return value: Identifier of the selected item in the suboptions menu. - * If the search bar currently contains an entry rather than a a suboption menu, - * a value less than zero is returned. - **/ -int -e_search_bar_get_subitem_id (ESearchBar *search_bar) -{ - g_return_val_if_fail (search_bar != NULL, -1); - g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), -1); - - return search_bar->subitem_id; -} - -/** - * e_search_bar_set_ids: - * @search_bar: A search bar. - * @item_id: Identifier of the item to set. - * @subitem_id: Identifier of the subitem to set. - * - * Sets the item and subitem ids for a search bar. This is intended to switch - * to an item that has subitems. - **/ -void -e_search_bar_set_ids (ESearchBar *search_bar, int item_id, int subitem_id) -{ - int item_row; - GtkWidget *item_widget; - ESearchBarSubitem *subitems; - - g_return_if_fail (search_bar != NULL); - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - - item_row = find_id (search_bar->option_menu, item_id, "EsbChoiceId", &item_widget); - g_return_if_fail (item_row != -1); - g_assert (item_widget != NULL); - - subitems = g_object_get_data (G_OBJECT (item_widget), "EsbChoiceSubitems"); - g_return_if_fail (subitems != NULL); - - search_bar->item_id = item_id; - gtk_option_menu_set_history (GTK_OPTION_MENU (search_bar->option), item_row); - - activate_by_subitems (search_bar, item_id, subitems); - e_search_bar_set_subitem_id (search_bar, subitem_id); -} - -/** - * e_search_bar_set_text: - * @search_bar: A search bar. - * @text: Text to set in the search bar's entry line. - * - * Sets the text string inside the entry line of a search bar. - **/ -void -e_search_bar_set_text (ESearchBar *search_bar, const char *text) -{ - g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); - - gtk_entry_set_text (GTK_ENTRY (search_bar->entry), text); -} - -/** - * e_search_bar_get_text: - * @search_bar: A search bar. - * - * Queries the text of the entry line in a search bar. - * - * Return value: The text string that is in the entry line of the search bar. - * This must be freed using g_free(). If a suboption menu is active instead - * of an entry, NULL is returned. - **/ -char * -e_search_bar_get_text (ESearchBar *search_bar) -{ - g_return_val_if_fail (search_bar != NULL, NULL); - g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), NULL); - - return search_bar->subitem_id < 0 ? g_strdup (gtk_entry_get_text (GTK_ENTRY (search_bar->entry))) : NULL; -} diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h deleted file mode 100644 index b0333ad58b..0000000000 --- a/widgets/misc/e-search-bar.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-search-bar.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_SEARCH_BAR_H__ -#define __E_SEARCH_BAR_H__ - -#include <gtk/gtkhbox.h> - -#include <bonobo/bonobo-ui-component.h> - -G_BEGIN_DECLS - -/* ESearchBar - A card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * --------------------------------------------------------------------------------- - * item_id int RW Which option item is currently selected. - * subitem_id int RW Which option subitem is currently selected. - * text string RW Text in the entry box. - */ - -#define E_SEARCH_BAR_TYPE (e_search_bar_get_type ()) -#define E_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_SEARCH_BAR_TYPE, ESearchBar)) -#define E_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_SEARCH_BAR_TYPE, ESearchBarClass)) -#define E_IS_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_SEARCH_BAR_TYPE)) -#define E_IS_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_SEARCH_BAR_TYPE)) - -typedef struct { - char *text; - int id; - gboolean translate; /* whether to translate the text */ -} ESearchBarSubitem; - -typedef struct { - char *text; - int id; - ESearchBarSubitem *subitems; -} ESearchBarItem; - -typedef struct _ESearchBar ESearchBar; -typedef struct _ESearchBarClass ESearchBarClass; - -struct _ESearchBar -{ - GtkHBox parent; - - BonoboUIComponent *ui_component; - - GSList *menu_items; - - /* item specific fields */ - GtkWidget *option; - GtkWidget *entry; - GtkWidget *suboption; /* an option menu for the choices associated with some options */ - - /* PRIVATE */ - GtkWidget *dropdown_holder; /* holds the dropdown */ - GtkWidget *option_menu; - GtkWidget *suboption_menu; - GtkWidget *activate_button; - GtkWidget *clear_button; - GtkWidget *entry_box; - guint pending_activate; - - /* The currently-selected item & subitem */ - int item_id; - int subitem_id; /* < 0 if the entry widget is active */ -}; - -struct _ESearchBarClass -{ - GtkHBoxClass parent_class; - - void (*set_menu) (ESearchBar *, ESearchBarItem *); - void (*set_option) (ESearchBar *, ESearchBarItem *); - - /* signals */ - void (*search_activated) (ESearchBar *search); - void (*query_changed) (ESearchBar *search); - void (*menu_activated) (ESearchBar *search, int item); -}; - -enum { - E_SEARCHBAR_FIND_NOW_ID = -1, - E_SEARCHBAR_CLEAR_ID = -2 -}; - - -GType e_search_bar_get_type (void); -void e_search_bar_construct (ESearchBar *search_bar, - ESearchBarItem *menu_items, - ESearchBarItem *option_items); -GtkWidget *e_search_bar_new (ESearchBarItem *menu_items, - ESearchBarItem *option_items); - -void e_search_bar_set_ui_component (ESearchBar *search_bar, - BonoboUIComponent *ui_component); - -void e_search_bar_set_menu (ESearchBar *search_bar, - ESearchBarItem *menu_items); -void e_search_bar_add_menu (ESearchBar *search_bar, - ESearchBarItem *menu_item); - -void e_search_bar_set_option (ESearchBar *search_bar, - ESearchBarItem *option_items); -void e_search_bar_set_suboption (ESearchBar *search_bar, - int option_id, - ESearchBarSubitem *subitems); - -void e_search_bar_set_menu_sensitive (ESearchBar *search_bar, - int id, - gboolean state); - -void e_search_bar_set_item_id (ESearchBar *search_bar, - int id); -int e_search_bar_get_item_id (ESearchBar *search_bar); - -void e_search_bar_set_subitem_id (ESearchBar *search_bar, - int id); -int e_search_bar_get_subitem_id (ESearchBar *search_bar); - -void e_search_bar_set_ids (ESearchBar *search_bar, - int item_id, - int subitem_id); - -void e_search_bar_set_text (ESearchBar *search_bar, - const char *text); -char *e_search_bar_get_text (ESearchBar *search_bar); - -G_END_DECLS - - -#endif /* __E_SEARCH_BAR_H__ */ diff --git a/widgets/misc/e-source-option-menu.c b/widgets/misc/e-source-option-menu.c deleted file mode 100644 index fd1fd3de1f..0000000000 --- a/widgets/misc/e-source-option-menu.c +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-source-option-menu.c - * - * Copyright (C) 2003 Novell, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#include <config.h> - -#include "e-source-option-menu.h" - -#include "e-util-marshal.h" - -#include <gal/util/e-util.h> - -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenuitem.h> - - -#define PARENT_TYPE gtk_option_menu_get_type () -static GtkOptionMenuClass *parent_class = NULL; - - -/* We set data on each menu item specifying the corresponding ESource using this key. */ -#define MENU_ITEM_SOURCE_DATA_ID "ESourceOptionMenu:Source" - - -struct _ESourceOptionMenuPrivate { - ESourceList *source_list; - - ESource *selected_source; -}; - - -enum { - SOURCE_SELECTED, - NUM_SIGNALS -}; - -static uint signals[NUM_SIGNALS] = { 0 }; - - -/* Selecting a source. */ - -typedef struct { - ESourceOptionMenu *option_menu; - ESource *source; - ESource *found_source; - int i; -} ForeachMenuItemData; - -static void -select_source_foreach_menu_item (GtkWidget *menu_item, - ForeachMenuItemData *data) -{ - ESource *source = gtk_object_get_data (GTK_OBJECT (menu_item), MENU_ITEM_SOURCE_DATA_ID); - - if (data->found_source) - return; - - if (source && e_source_equal (source, data->source)) { - data->found_source = source; - gtk_option_menu_set_history (GTK_OPTION_MENU (data->option_menu), data->i); - } - - data->i ++; -} - -static void -select_source (ESourceOptionMenu *menu, - ESource *source) -{ - ForeachMenuItemData *foreach_data; - - foreach_data = g_new0 (ForeachMenuItemData, 1); - foreach_data->option_menu = menu; - foreach_data->source = source; - - gtk_container_foreach (GTK_CONTAINER (GTK_OPTION_MENU (menu)->menu), - (GtkCallback) select_source_foreach_menu_item, foreach_data); - - if (foreach_data->found_source) { - menu->priv->selected_source = foreach_data->found_source; - g_signal_emit (menu, signals[SOURCE_SELECTED], 0, foreach_data->found_source); - } - - g_free (foreach_data); -} - - -/* Menu callback. */ - -static void -menu_item_activate_callback (GtkMenuItem *menu_item, - ESourceOptionMenu *option_menu) -{ - ESource *source = gtk_object_get_data (GTK_OBJECT (menu_item), MENU_ITEM_SOURCE_DATA_ID); - - if (source != NULL) - select_source (option_menu, source); -} - - -/* Functions to keep the menu in sync with the ESourceList. */ - -static void -populate (ESourceOptionMenu *option_menu) -{ - GtkWidget *menu = gtk_menu_new (); - GSList *groups = e_source_list_peek_groups (option_menu->priv->source_list); - GSList *p; - ESource *first_source = NULL; - int first_source_item = -1; - int selected_item = -1; - int i; - - i = 0; - for (p = groups; p != NULL; p = p->next) { - ESourceGroup *group = E_SOURCE_GROUP (p->data); - GtkWidget *item = gtk_menu_item_new_with_label (e_source_group_peek_name (group)); - GSList *q; - - gtk_widget_set_sensitive (item, FALSE); - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - - i ++; - - for (q = e_source_group_peek_sources (group); q != NULL; q = q->next) { - ESource *source = E_SOURCE (q->data); - char *label = g_strconcat (" ", e_source_peek_name (source), NULL); - GtkWidget *item = gtk_menu_item_new_with_label (label); - - gtk_object_set_data_full (GTK_OBJECT (item), MENU_ITEM_SOURCE_DATA_ID, source, - (GtkDestroyNotify) g_object_unref); - g_object_ref (source); - - g_signal_connect (item, "activate", G_CALLBACK (menu_item_activate_callback), option_menu); - - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - - if (first_source_item == -1) { - first_source_item = i; - first_source = source; - } - - if (source == option_menu->priv->selected_source) - selected_item = i; - - i ++; - } - } - - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); - - if (selected_item != -1) { - gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), selected_item); - } else { - if (option_menu->priv->selected_source != NULL) - g_object_unref (option_menu->priv->selected_source); - option_menu->priv->selected_source = first_source; - if (option_menu->priv->selected_source != NULL) - g_object_ref (option_menu->priv->selected_source); - - gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), first_source_item); - } -} - - -static void -source_list_changed_callback (ESourceList *list, - ESourceOptionMenu *menu) -{ - populate (menu); -} - -static void -connect_signals (ESourceOptionMenu *menu) -{ - g_signal_connect_object (menu->priv->source_list, "changed", - G_CALLBACK (source_list_changed_callback), G_OBJECT (menu), 0); -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ESourceOptionMenuPrivate *priv = E_SOURCE_OPTION_MENU (object)->priv; - - if (priv->source_list != NULL) { - g_object_unref (priv->source_list); - priv->source_list = NULL; - } - - if (priv->selected_source != NULL) { - g_object_unref (priv->selected_source); - priv->selected_source = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - ESourceOptionMenuPrivate *priv = E_SOURCE_OPTION_MENU (object)->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Initialization. */ - -static void -class_init (ESourceOptionMenuClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - parent_class = g_type_class_peek_parent (class); - - signals[SOURCE_SELECTED] = - g_signal_new ("source_selected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESourceOptionMenuClass, source_selected), - NULL, NULL, - e_util_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); -} - -static void -init (ESourceOptionMenu *source_option_menu) -{ - ESourceOptionMenuPrivate *priv; - - priv = g_new0 (ESourceOptionMenuPrivate, 1); - - source_option_menu->priv = priv; -} - - -/* Public methods. */ - -GtkWidget * -e_source_option_menu_new (ESourceList *source_list) -{ - ESourceOptionMenu *menu; - - g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), NULL); - - menu = g_object_new (e_source_option_menu_get_type (), NULL); - - menu->priv->source_list = source_list; - g_object_ref (source_list); - - connect_signals (menu); - populate (menu); - - return GTK_WIDGET (menu); -} - - -ESource * -e_source_option_menu_peek_selected (ESourceOptionMenu *menu) -{ - g_return_val_if_fail (E_IS_SOURCE_OPTION_MENU (menu), NULL); - - return menu->priv->selected_source; -} - - -void -e_source_option_menu_select (ESourceOptionMenu *menu, - ESource *source) -{ - g_return_if_fail (E_IS_SOURCE_OPTION_MENU (menu)); - g_return_if_fail (E_IS_SOURCE (source)); - - select_source (menu, source); -} - - -E_MAKE_TYPE (e_source_option_menu, "ESourceOptionMenu", ESourceOptionMenu, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-source-option-menu.h b/widgets/misc/e-source-option-menu.h deleted file mode 100644 index 74a85d629e..0000000000 --- a/widgets/misc/e-source-option-menu.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-source-option-menu.h - * - * Copyright (C) 2003 Novell, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_SOURCE_OPTION_MENU_H_ -#define _E_SOURCE_OPTION_MENU_H_ - -#include <libedataserver/e-source-list.h> - -#include <gtk/gtkoptionmenu.h> - -#define E_TYPE_SOURCE_OPTION_MENU (e_source_option_menu_get_type ()) -#define E_SOURCE_OPTION_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SOURCE_OPTION_MENU, ESourceOptionMenu)) -#define E_SOURCE_OPTION_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SOURCE_OPTION_MENU, ESourceOptionMenuClass)) -#define E_IS_SOURCE_OPTION_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SOURCE_OPTION_MENU)) -#define E_IS_SOURCE_OPTION_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SOURCE_OPTION_MENU)) - - -typedef struct _ESourceOptionMenu ESourceOptionMenu; -typedef struct _ESourceOptionMenuPrivate ESourceOptionMenuPrivate; -typedef struct _ESourceOptionMenuClass ESourceOptionMenuClass; - -struct _ESourceOptionMenu { - GtkOptionMenu parent; - - ESourceOptionMenuPrivate *priv; -}; - -struct _ESourceOptionMenuClass { - GtkOptionMenuClass parent_class; - - void (* source_selected) (ESourceOptionMenu *menu, - ESource *selected_source); -}; - - -GType e_source_option_menu_get_type (void); - -GtkWidget *e_source_option_menu_new (ESourceList *list); - -ESource *e_source_option_menu_peek_selected (ESourceOptionMenu *menu); -void e_source_option_menu_select (ESourceOptionMenu *menu, - ESource *source); - - -#endif /* _E_SOURCE_OPTION_MENU_H_ */ diff --git a/widgets/misc/e-source-selector.c b/widgets/misc/e-source-selector.c deleted file mode 100644 index 898e8b6c00..0000000000 --- a/widgets/misc/e-source-selector.c +++ /dev/null @@ -1,1097 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-source-selector.c - * - * Copyright (C) 2003 Ximian, 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 <ettore@ximian.com> - */ - -#include <config.h> - -#include "e-source-selector.h" - -#include "e-util-marshal.h" - -#include <gal/util/e-util.h> - -#include <gtk/gtkmenu.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtktreestore.h> -#include <gtk/gtkcellrenderertoggle.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkcellrendererpixbuf.h> - -#define PARENT_TYPE gtk_tree_view_get_type () -static GtkTreeViewClass *parent_class = NULL; - - -struct _ESourceSelectorPrivate { - ESourceList *list; - - GtkTreeStore *tree_store; - - GHashTable *selected_sources; - GtkTreeRowReference *saved_primary_selection; - - int rebuild_model_idle_id; - - gboolean toggled_last; - gboolean checkboxes_shown; - gboolean select_new; -}; - -typedef struct { - ESourceSelector *selector; - - GHashTable *remaining_uids; - GSList *deleted_uids; - - gboolean selection_changed; -} ESourceSelectorRebuildData; - -enum { - SELECTION_CHANGED, - PRIMARY_SELECTION_CHANGED, - FILL_POPUP_MENU, - NUM_SIGNALS -}; -static unsigned int signals[NUM_SIGNALS] = { 0 }; - - -/* Selection management. */ - -static GHashTable * -create_selected_sources_hash (void) -{ - return g_hash_table_new_full (g_direct_hash, g_direct_equal, - (GDestroyNotify) g_object_unref, NULL); -} - -static ESourceSelectorRebuildData * -create_rebuild_data (ESourceSelector *selector) -{ - ESourceSelectorRebuildData *rebuild_data; - - rebuild_data = g_new0 (ESourceSelectorRebuildData, 1); - - rebuild_data->selector = selector; - rebuild_data->remaining_uids = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, - (GDestroyNotify) gtk_tree_row_reference_free); - rebuild_data->deleted_uids = NULL; - - return rebuild_data; -} - - -static void -free_rebuild_data (ESourceSelectorRebuildData *rebuild_data) -{ - GSList *p; - - g_hash_table_destroy (rebuild_data->remaining_uids); - for (p = rebuild_data->deleted_uids; p; p = p->next) - gtk_tree_row_reference_free (p->data); - g_slist_free (rebuild_data->deleted_uids); - - g_free (rebuild_data); -} - -static void -clear_saved_primary_selection (ESourceSelector *selector) -{ - if (selector->priv->saved_primary_selection != NULL) { - gtk_tree_row_reference_free (selector->priv->saved_primary_selection); - selector->priv->saved_primary_selection = NULL; - } -} - -static gboolean -source_is_selected (ESourceSelector *selector, - ESource *source) -{ - if (g_hash_table_lookup (selector->priv->selected_sources, source) == NULL) - return FALSE; - else - return TRUE; -} - -static void -select_source (ESourceSelector *selector, - ESource *source) -{ - if (g_hash_table_lookup (selector->priv->selected_sources, source) != NULL) - return; - - g_hash_table_insert (selector->priv->selected_sources, source, source); - g_object_ref (source); -} - -static void -unselect_source (ESourceSelector *selector, - ESource *source) -{ - if (g_hash_table_lookup (selector->priv->selected_sources, source) == NULL) - return; - - /* (This will unref the source.) */ - g_hash_table_remove (selector->priv->selected_sources, source); -} - -static gboolean -find_source_iter (ESourceSelector *selector, ESource *source, GtkTreeIter *parent_iter, GtkTreeIter *source_iter) -{ - GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store); - - if (gtk_tree_model_get_iter_first (model, parent_iter)) { - do { - if (gtk_tree_model_iter_children (model, source_iter, parent_iter)) { - do { - void *data; - - gtk_tree_model_get (model, source_iter, 0, &data, -1); - g_assert (E_IS_SOURCE (data)); - - if (E_SOURCE (data) == source) { - g_object_unref (data); - - return TRUE; - } - - g_object_unref (data); - } while (gtk_tree_model_iter_next (model, source_iter)); - } - } while (gtk_tree_model_iter_next (model, parent_iter)); - } - - return FALSE; -} - -/* Setting up the model. */ -static gboolean -rebuild_existing_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) -{ - ESourceSelectorRebuildData *rebuild_data = data; - void *node; - const char *uid; - - gtk_tree_model_get (model, iter, 0, &node, -1); - - if (E_IS_SOURCE_GROUP (node)) { - uid = e_source_group_peek_uid (E_SOURCE_GROUP (node)); - - if (e_source_list_peek_group_by_uid (rebuild_data->selector->priv->list, uid)) { - g_hash_table_insert (rebuild_data->remaining_uids, g_strdup (uid), - gtk_tree_row_reference_new (model, path)); - } else { - rebuild_data->deleted_uids = g_slist_prepend (rebuild_data->deleted_uids, - gtk_tree_row_reference_new (model, path)); - } - } else { - uid = e_source_peek_uid (E_SOURCE (node)); - if (e_source_list_peek_source_by_uid (rebuild_data->selector->priv->list, uid)) { - g_hash_table_insert (rebuild_data->remaining_uids, g_strdup (uid), - gtk_tree_row_reference_new (model, path)); - } else { - rebuild_data->deleted_uids = g_slist_prepend (rebuild_data->deleted_uids, - gtk_tree_row_reference_new (model, path)); - - if (g_hash_table_remove (rebuild_data->selector->priv->selected_sources, node)) - rebuild_data->selection_changed = TRUE; - } - } - - g_object_unref (node); - - return FALSE; -} - -static void -rebuild_model (ESourceSelector *selector) -{ - ESourceSelectorRebuildData *rebuild_data; - GtkTreeStore *tree_store; - GtkTreeIter iter; - GSList *groups, *p; - gboolean set_primary; - - tree_store = selector->priv->tree_store; - - rebuild_data = create_rebuild_data (selector); - set_primary = e_source_selector_peek_primary_selection (selector) != NULL; - - /* Remove any delete sources or groups */ - gtk_tree_model_foreach (GTK_TREE_MODEL (tree_store), rebuild_existing_cb, rebuild_data); - for (p = rebuild_data->deleted_uids; p; p = p->next) { - GtkTreeRowReference *row_ref = p->data; - GtkTreePath *path; - - path = gtk_tree_row_reference_get_path (row_ref); - gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &iter, path); - gtk_tree_store_remove (tree_store, &iter); - - gtk_tree_path_free (path); - } - - /* Add new sources/groups or call row_changed in case they were renamed */ - groups = e_source_list_peek_groups (selector->priv->list); - for (p = groups; p != NULL; p = p->next) { - ESourceGroup *group = E_SOURCE_GROUP (p->data); - GSList *sources, *q; - GtkTreeRowReference *row_ref; - - row_ref = g_hash_table_lookup (rebuild_data->remaining_uids, e_source_group_peek_uid (group)); - if (!row_ref) { - gtk_tree_store_append (GTK_TREE_STORE (tree_store), &iter, NULL); - gtk_tree_store_set (GTK_TREE_STORE (tree_store), &iter, 0, group, -1); - } else { - GtkTreePath *path; - - path = gtk_tree_row_reference_get_path (row_ref); - gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &iter, path); - - gtk_tree_model_row_changed (GTK_TREE_MODEL (tree_store), path, &iter); - - gtk_tree_path_free (path); - } - - sources = e_source_group_peek_sources (group); - for (q = sources; q != NULL; q = q->next) { - ESource *source = E_SOURCE (q->data); - GtkTreeIter child_iter; - - row_ref = g_hash_table_lookup (rebuild_data->remaining_uids, e_source_peek_uid (source)); - if (!row_ref) { - if (selector->priv->select_new) { - select_source (selector, source); - rebuild_data->selection_changed = TRUE; - } - gtk_tree_store_append (GTK_TREE_STORE (tree_store), &child_iter, &iter); - gtk_tree_store_set (GTK_TREE_STORE (tree_store), &child_iter, 0, source, -1); - - } else { - GtkTreePath *path; - - path = gtk_tree_row_reference_get_path (row_ref); - gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_store), &child_iter, path); - - gtk_tree_model_row_changed (GTK_TREE_MODEL (tree_store), path, &child_iter); - - gtk_tree_path_free (path); - } - } - } - - if (rebuild_data->selection_changed) - g_signal_emit (selector, signals[SELECTION_CHANGED], 0); - - if (set_primary && !e_source_selector_peek_primary_selection (selector)) - e_source_selector_set_primary_selection (selector, e_source_list_peek_source_any (selector->priv->list)); - - free_rebuild_data (rebuild_data); -} - -static int -on_idle_rebuild_model_callback (ESourceSelector *selector) -{ - rebuild_model (selector); - selector->priv->rebuild_model_idle_id = 0; - - return FALSE; -} - -static void -list_changed_callback (ESourceList *list, - ESourceSelector *selector) -{ - ESourceSelectorPrivate *priv = selector->priv; - - if (priv->rebuild_model_idle_id == 0) - priv->rebuild_model_idle_id = g_idle_add ((GSourceFunc) on_idle_rebuild_model_callback, - selector); -} - -static void -setup_model (ESourceSelector *selector) -{ - rebuild_model (selector); - - g_signal_connect_object (selector->priv->list, "changed", G_CALLBACK (list_changed_callback), G_OBJECT (selector), 0); -} - - -/* Data functions for rendering the model. */ - -static void -toggle_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - ESourceSelector *selector) -{ - void *data; - - gtk_tree_model_get (model, iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_set (renderer, "visible", FALSE, NULL); - } else { - g_assert (E_IS_SOURCE (data)); - - g_object_set (renderer, "visible", selector->priv->checkboxes_shown, NULL); - if (source_is_selected (selector, E_SOURCE (data))) - g_object_set (renderer, "active", TRUE, NULL); - else - g_object_set (renderer, "active", FALSE, NULL); - } - - g_object_unref (data); -} - -static void -text_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - ESourceSelector *selector) -{ - void *data; - - gtk_tree_model_get (model, iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_set (renderer, - "text", e_source_group_peek_name (E_SOURCE_GROUP (data)), - "weight", PANGO_WEIGHT_BOLD, - "foreground_set", FALSE, - NULL); - } else { - ESource *source; - - g_assert (E_IS_SOURCE (data)); - source = E_SOURCE (data); - - g_object_set (renderer, - "text", e_source_peek_name (source), - "weight", PANGO_WEIGHT_NORMAL, - "foreground_set", FALSE, - NULL); - } - - g_object_unref (data); -} - -static void -pixbuf_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *renderer, - GtkTreeModel *model, - GtkTreeIter *iter, - ESourceSelector *selector) -{ - void *data; - - gtk_tree_model_get (model, iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_set (renderer, - "visible", FALSE, - NULL); - } else { - ESource *source; - guint32 color; - GdkPixbuf *pixbuf = NULL; - - g_assert (E_IS_SOURCE (data)); - source = E_SOURCE (data); - - if (e_source_get_color (source, &color)) { - pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 16, 16); - gdk_pixbuf_fill (pixbuf, color << 8); - } - - g_object_set (renderer, - "visible", pixbuf != NULL, - "pixbuf", pixbuf, - NULL); - - if (pixbuf) - g_object_unref (pixbuf); - } - - g_object_unref (data); -} - -/* Custom selection function to make groups non selectable. */ -static gboolean -selection_func (GtkTreeSelection *selection, - GtkTreeModel *model, - GtkTreePath *path, - gboolean path_currently_selected, - ESourceSelector *selector) -{ - GtkTreeIter iter; - void *data; - - if (selector->priv->toggled_last) { - selector->priv->toggled_last = FALSE; - - return FALSE; - } - - if (path_currently_selected) - return TRUE; - - if (! gtk_tree_model_get_iter (model, &iter, path)) - return FALSE; - - - gtk_tree_model_get (model, &iter, 0, &data, -1); - if (E_IS_SOURCE_GROUP (data)) { - g_object_unref (data); - - return FALSE; - } - - clear_saved_primary_selection (selector); - g_object_unref (data); - - return TRUE; -} - - -/* Callbacks. */ - -static void -cell_toggled_callback (GtkCellRendererToggle *renderer, - const char *path_string, - ESourceSelector *selector) -{ - GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store); - GtkTreePath *path = gtk_tree_path_new_from_string (path_string); - GtkTreeIter iter; - ESource *source; - void *data; - - if (! gtk_tree_model_get_iter (model, &iter, path)) { - gtk_tree_path_free (path); - return; - } - - gtk_tree_model_get (model, &iter, 0, &data, -1); - if (!E_IS_SOURCE_GROUP (data)) { - source = E_SOURCE (data); - - if (source_is_selected (selector, source)) - unselect_source (selector, source); - else - select_source (selector, source); - - selector->priv->toggled_last = TRUE; - - gtk_tree_model_row_changed (model, path, &iter); - g_signal_emit (selector, signals[SELECTION_CHANGED], 0); - } - - gtk_tree_path_free (path); - - g_object_unref (data); -} - -static void -selection_changed_callback (GtkTreeSelection *selection, - ESourceSelector *selector) -{ - g_signal_emit (selector, signals[PRIMARY_SELECTION_CHANGED], 0); -} - -static gboolean -test_collapse_row_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, gpointer data) -{ - ESourceSelector *selector = data; - ESourceSelectorPrivate *priv; - GtkTreeIter child_iter; - - priv = selector->priv; - - /* Clear this because something else has been clicked on now */ - priv->toggled_last = FALSE; - - if (priv->saved_primary_selection) - return FALSE; - - if (!gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)), NULL, &child_iter)) - return FALSE; - - if (gtk_tree_store_is_ancestor (priv->tree_store, iter, &child_iter)) { - GtkTreePath *child_path; - - child_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &child_iter); - priv->saved_primary_selection = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->tree_store), child_path); - gtk_tree_path_free (child_path); - } - - return FALSE; -} - -static gboolean -row_expanded_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, gpointer data) -{ - ESourceSelector *selector = data; - ESourceSelectorPrivate *priv; - GtkTreePath *child_path; - GtkTreeIter child_iter; - - priv = selector->priv; - - if (!priv->saved_primary_selection) - return FALSE; - - child_path = gtk_tree_row_reference_get_path (priv->saved_primary_selection); - gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->tree_store), &child_iter, child_path); - - if (gtk_tree_store_is_ancestor (priv->tree_store, iter, &child_iter)) { - GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)); - - gtk_tree_selection_select_iter (selection, &child_iter); - clear_saved_primary_selection (selector); - } - - gtk_tree_path_free (child_path); - - return FALSE; -} - -static gboolean -selector_button_press_event (GtkWidget *widget, GdkEventButton *event, ESourceSelector *selector) -{ - ESourceSelectorPrivate *priv = selector->priv; - GtkWidget *menu; - GtkTreePath *path; - ESource *source = NULL; - - priv->toggled_last = FALSE; - - /* only process right-clicks */ - if (event->button != 3 || event->type != GDK_BUTTON_PRESS) - return FALSE; - - /* Get the source/group */ - if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), event->x, event->y, &path, NULL, NULL, NULL)) { - GtkTreeIter iter; - gpointer data; - - if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->tree_store), &iter, path)) { - gtk_tree_model_get (GTK_TREE_MODEL (priv->tree_store), &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_unref (data); - - return FALSE; - } - - source = E_SOURCE (data); - } - } - - if (source) { - e_source_selector_set_primary_selection (selector, source); - g_object_unref (source); - } - - /* create the menu */ - menu = gtk_menu_new (); - g_signal_emit (G_OBJECT (selector), signals[FILL_POPUP_MENU], 0, GTK_MENU (menu)); - - /* popup the menu */ - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time); - - return TRUE; -} - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ESourceSelectorPrivate *priv = E_SOURCE_SELECTOR (object)->priv; - - if (priv->selected_sources != NULL) { - g_hash_table_destroy (priv->selected_sources); - priv->selected_sources = NULL; - } - - if (priv->rebuild_model_idle_id != 0) { - g_source_remove (priv->rebuild_model_idle_id); - priv->rebuild_model_idle_id = 0; - } - - if (priv->list != NULL) { - g_object_unref (priv->list); - priv->list = NULL; - } - - if (priv->tree_store != NULL) { - g_object_unref (priv->tree_store); - priv->tree_store = NULL; - } - - clear_saved_primary_selection (E_SOURCE_SELECTOR (object)); - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - ESourceSelectorPrivate *priv = E_SOURCE_SELECTOR (object)->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Initialization. */ - -static void -class_init (ESourceSelectorClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - parent_class = g_type_class_peek_parent (class); - - signals[SELECTION_CHANGED] = - g_signal_new ("selection_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESourceSelectorClass, selection_changed), - NULL, NULL, - e_util_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - signals[PRIMARY_SELECTION_CHANGED] = - g_signal_new ("primary_selection_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESourceSelectorClass, primary_selection_changed), - NULL, NULL, - e_util_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[FILL_POPUP_MENU] = - g_signal_new ("fill_popup_menu", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESourceSelectorClass, fill_popup_menu), - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, G_TYPE_OBJECT); -} - -static void -init (ESourceSelector *selector) -{ - ESourceSelectorPrivate *priv; - GtkTreeViewColumn *column; - GtkCellRenderer *cell_renderer; - GtkTreeSelection *selection; - - priv = g_new0 (ESourceSelectorPrivate, 1); - selector->priv = priv; - - g_signal_connect (G_OBJECT (selector), "button_press_event", - G_CALLBACK (selector_button_press_event), selector); - - priv->toggled_last = FALSE; - priv->checkboxes_shown = TRUE; - priv->select_new = FALSE; - - priv->selected_sources = create_selected_sources_hash (); - - priv->tree_store = gtk_tree_store_new (1, G_TYPE_OBJECT); - gtk_tree_view_set_model (GTK_TREE_VIEW (selector), GTK_TREE_MODEL (priv->tree_store)); - - column = gtk_tree_view_column_new (); - gtk_tree_view_append_column (GTK_TREE_VIEW (selector), column); - - cell_renderer = gtk_cell_renderer_pixbuf_new (); - g_object_set (G_OBJECT (cell_renderer), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); - gtk_tree_view_column_pack_start (column, cell_renderer, FALSE); - gtk_tree_view_column_set_cell_data_func (column, cell_renderer, (GtkTreeCellDataFunc) pixbuf_cell_data_func, selector, NULL); - cell_renderer = gtk_cell_renderer_toggle_new (); - gtk_tree_view_column_pack_start (column, cell_renderer, FALSE); - gtk_tree_view_column_set_cell_data_func (column, cell_renderer, (GtkTreeCellDataFunc) toggle_cell_data_func, selector, NULL); - g_signal_connect (cell_renderer, "toggled", G_CALLBACK (cell_toggled_callback), selector); - - cell_renderer = gtk_cell_renderer_text_new (); - g_object_set (G_OBJECT (cell_renderer), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); - gtk_tree_view_column_pack_start (column, cell_renderer, TRUE); - gtk_tree_view_column_set_cell_data_func (column, cell_renderer, (GtkTreeCellDataFunc) text_cell_data_func, selector, NULL); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)); - gtk_tree_selection_set_select_function (selection, (GtkTreeSelectionFunc) selection_func, selector, NULL); - g_signal_connect_object (selection, "changed", G_CALLBACK (selection_changed_callback), G_OBJECT (selector), 0); - - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (selector), FALSE); - - g_signal_connect (G_OBJECT (selector), "test-collapse-row", G_CALLBACK (test_collapse_row_callback), selector); - g_signal_connect (G_OBJECT (selector), "row-expanded", G_CALLBACK (row_expanded_callback), selector); -} - - -/* Public API. */ - -/** - * e_source_selector_new: - * @list: A source list. - * - * Create a new view for @list. The view will update automatically when @list - * changes. - * - * Return value: The newly created widget. - **/ -GtkWidget * -e_source_selector_new (ESourceList *list) -{ - ESourceSelector *selector; - - g_return_val_if_fail (E_IS_SOURCE_LIST (list), NULL); - - selector = g_object_new (e_source_selector_get_type (), NULL); - - selector->priv->list = list; - g_object_ref (list); - - setup_model (selector); - - gtk_tree_view_expand_all (GTK_TREE_VIEW (selector)); - - return GTK_WIDGET (selector); -} - - -/** - * e_source_selector_get_selection: - * @selector: - * - * Get the list of selected sources, i.e. those that were enabled through the - * corresponding checkboxes in the tree. - * - * Return value: A list of the ESources currently selected. The sources will - * be in the same order as they appear on the screen, and the list should be - * freed using e_source_selector_free_selection(). - **/ -GSList * -e_source_selector_get_selection (ESourceSelector *selector) -{ - GSList *selection_list; - GSList *groups; - GSList *p; - - g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), NULL); - - selection_list = NULL; - - groups = e_source_list_peek_groups (selector->priv->list); - for (p = groups; p != NULL; p = p->next) { - ESourceGroup *group = E_SOURCE_GROUP (p->data); - GSList *sources; - GSList *q; - - sources = e_source_group_peek_sources (group); - for (q = sources; q != NULL; q = q->next) { - ESource *source = E_SOURCE (q->data); - - if (source_is_selected (selector, source)) { - selection_list = g_slist_prepend (selection_list, source); - g_object_ref (source); - } - } - } - - return g_slist_reverse (selection_list); -} - -/** - * e_source_list_free_selection: - * @list: A selection list returned by e_source_selector_get_selection(). - * - * Free the selection list. - **/ -void -e_source_selector_free_selection (GSList *list) -{ - g_slist_foreach (list, (GFunc) g_object_unref, NULL); - g_slist_free (list); -} - - -/** - * e_source_selector_show_selection: - * @selector: An ESourceSelector widget - * - * Specify whether the checkboxes in the ESourceSelector should be shown or - * not. - **/ -void -e_source_selector_show_selection (ESourceSelector *selector, - gboolean show) -{ - g_return_if_fail (E_IS_SOURCE_SELECTOR (selector)); - - show = !! show; - if (show == selector->priv->checkboxes_shown) - return; - - selector->priv->checkboxes_shown = show; - - gtk_tree_model_foreach (GTK_TREE_MODEL (selector->priv->tree_store), - (GtkTreeModelForeachFunc) gtk_tree_model_row_changed, - NULL); -} - -/** - * e_source_selector_selection_shown: - * @selector: - * - * Check whether the checkboxes in the ESourceSelector are being shown or not. - * - * Return value: %TRUE if the checkboxes are shown, %FALSE otherwise. - **/ -gboolean -e_source_selector_selection_shown (ESourceSelector *selector) -{ - g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), FALSE); - - return selector->priv->checkboxes_shown; -} - -/** - * e_source_selector_set_select_new: - * @selector: An ESourceSelector widget - * @state: A gboolean - * - * Set whether or not to select new sources added to @selector. - **/ -void -e_source_selector_set_select_new (ESourceSelector *selector, gboolean state) -{ - g_return_if_fail (E_IS_SOURCE_SELECTOR (selector)); - - selector->priv->select_new = state; -} - -/** - * e_source_selector_select_source: - * @selector: An ESourceSelector widget - * @source: An ESource. - * - * Select @source in @selector. - **/ -void -e_source_selector_select_source (ESourceSelector *selector, - ESource *source) -{ - GtkTreeIter parent_iter, source_iter; - - g_return_if_fail (E_IS_SOURCE_SELECTOR (selector)); - g_return_if_fail (E_IS_SOURCE (source)); - - if (source_is_selected (selector, source)) - return; - - select_source (selector, source); - - if (find_source_iter (selector, source, &parent_iter, &source_iter)) { - GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store); - GtkTreePath *path; - - path = gtk_tree_model_get_path (model, &source_iter); - gtk_tree_model_row_changed (model, path, &source_iter); - gtk_tree_path_free (path); - - g_signal_emit (selector, signals[SELECTION_CHANGED], 0); - } -} - -/** - * e_source_selector_unselect_source: - * @selector: An ESourceSelector widget - * @source: An ESource. - * - * Unselect @source in @selector. - **/ -void -e_source_selector_unselect_source (ESourceSelector *selector, - ESource *source) -{ - GtkTreeIter parent_iter, source_iter; - - g_return_if_fail (E_IS_SOURCE_SELECTOR (selector)); - g_return_if_fail (E_IS_SOURCE (source)); - - if (! source_is_selected (selector, source)) - return; - - unselect_source (selector, source); - - if (find_source_iter (selector, source, &parent_iter, &source_iter)) { - GtkTreeModel *model = GTK_TREE_MODEL (selector->priv->tree_store); - GtkTreePath *path; - - path = gtk_tree_model_get_path (model, &source_iter); - gtk_tree_model_row_changed (model, path, &source_iter); - gtk_tree_path_free (path); - - g_signal_emit (selector, signals[SELECTION_CHANGED], 0); - } -} - -/** - * e_source_selector_source_is_selected: - * @selector: An ESourceSelector widget - * @source: An ESource. - * - * Check whether @source is selected in @selector. - * - * Return value: %TRUE if @source is currently selected, %FALSE otherwise. - **/ -gboolean -e_source_selector_source_is_selected (ESourceSelector *selector, - ESource *source) -{ - g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), FALSE); - g_return_val_if_fail (E_IS_SOURCE (source), FALSE); - - return source_is_selected (selector, source); -} - -/** - * e_source_selector_peek_primary_selection: - * @selector: An ESourceSelector widget - * - * Get the primary selected source. The primary selection is the one that is - * highlighted through the normal GtkTreeView selection mechanism (as opposed - * to the "normal" selection, which is the set of source whose checkboxes are - * checked). - * - * Return value: The selected source. - **/ -ESource * -e_source_selector_peek_primary_selection (ESourceSelector *selector) -{ - GtkTreeModel *model; - GtkTreeIter iter; - gboolean have_iter = FALSE; - void *data = NULL; - - g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), NULL); - - model = GTK_TREE_MODEL (selector->priv->tree_store); - - if (selector->priv->saved_primary_selection) { - GtkTreePath *child_path; - - child_path = gtk_tree_row_reference_get_path (selector->priv->saved_primary_selection); - if (child_path) { - if (gtk_tree_model_get_iter (GTK_TREE_MODEL (selector->priv->tree_store), &iter, child_path)) - have_iter = TRUE; - gtk_tree_path_free (child_path); - } - } - - if (!have_iter && ! gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)), NULL, &iter)) - return NULL; - - gtk_tree_model_get (model, &iter, 0, &data, -1); - if (!data) - return NULL; - - if (! E_IS_SOURCE (data)) { - g_object_unref (data); - - return NULL; - } - - g_object_unref (data); - - return E_SOURCE (data); -} - -/** - * e_source_selector_set_primary_selection: - * @selector: An ESourceSelector widget - * @source: Source to select - * - * Set the primary selected source. - **/ -void -e_source_selector_set_primary_selection (ESourceSelector *selector, ESource *source) -{ - ESourceSelectorPrivate *priv; - GtkTreeIter parent_iter, source_iter; - - g_return_if_fail (selector != NULL); - g_return_if_fail (E_IS_SOURCE_SELECTOR (selector)); - g_return_if_fail (source != NULL); - g_return_if_fail (E_IS_SOURCE (source)); - - priv = selector->priv; - - if (find_source_iter (selector, source, &parent_iter, &source_iter)) { - GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector)); - GtkTreePath *path; - - /* We block the signal because this all needs to be atomic */ - g_signal_handlers_block_matched (selection, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, selection_changed_callback, NULL); - gtk_tree_selection_unselect_all (selection); - g_signal_handlers_unblock_matched (selection, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, selection_changed_callback, NULL); - - clear_saved_primary_selection (selector); - - path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &parent_iter); - - if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (selector), path)) { - gtk_tree_selection_select_iter (selection, &source_iter); - } else { - GtkTreePath *child_path; - - child_path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tree_store), &source_iter); - priv->saved_primary_selection = gtk_tree_row_reference_new (GTK_TREE_MODEL (priv->tree_store), child_path); - gtk_tree_path_free (child_path); - - /* We do this by hand because we aren't changing the tree selection */ - if (!source_is_selected (selector, source)) { - select_source (selector, source); - gtk_tree_model_row_changed (GTK_TREE_MODEL (priv->tree_store), path, &source_iter); - g_signal_emit (selector, signals[SELECTION_CHANGED], 0); - } - - g_signal_emit (selector, signals[PRIMARY_SELECTION_CHANGED], 0); - } - - gtk_tree_path_free (path); - } else { - g_warning (G_STRLOC ": Cannot find source %p (%s) in selector %p", - source, e_source_peek_name (source), selector); - } -} - - -E_MAKE_TYPE (e_source_selector, "ESourceSelector", ESourceSelector, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-source-selector.h b/widgets/misc/e-source-selector.h deleted file mode 100644 index 92b5e7b67c..0000000000 --- a/widgets/misc/e-source-selector.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-source-selector.h - * - * Copyright (C) 2003 Ximian, 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 <ettore@ximian.com> - */ - -#ifndef _E_SOURCE_SELECTOR_H_ -#define _E_SOURCE_SELECTOR_H_ - -#include <gtk/gtkmenu.h> -#include <gtk/gtktreeview.h> -#include <libedataserver/e-source-list.h> - -#define E_TYPE_SOURCE_SELECTOR (e_source_selector_get_type ()) -#define E_SOURCE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SOURCE_SELECTOR, ESourceSelector)) -#define E_SOURCE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SOURCE_SELECTOR, ESourceSelectorClass)) -#define E_IS_SOURCE_SELECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SOURCE_SELECTOR)) -#define E_IS_SOURCE_SELECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SOURCE_SELECTOR)) - - -typedef struct _ESourceSelector ESourceSelector; -typedef struct _ESourceSelectorPrivate ESourceSelectorPrivate; -typedef struct _ESourceSelectorClass ESourceSelectorClass; - -struct _ESourceSelector { - GtkTreeView parent; - - ESourceSelectorPrivate *priv; -}; - -struct _ESourceSelectorClass { - GtkTreeViewClass parent_class; - - void (* selection_changed) (ESourceSelector *selector); - void (* primary_selection_changed) (ESourceSelector *selector); - void (* fill_popup_menu) (ESourceSelector *selector, GtkMenu *menu); -}; - - -GType e_source_selector_get_type (void); - -GtkWidget *e_source_selector_new (ESourceList *list); - -void e_source_selector_select_source (ESourceSelector *selector, - ESource *source); -void e_source_selector_unselect_source (ESourceSelector *selector, - ESource *source); -gboolean e_source_selector_source_is_selected (ESourceSelector *selector, - ESource *source); - -GSList *e_source_selector_get_selection (ESourceSelector *selector); -void e_source_selector_free_selection (GSList *list); - -void e_source_selector_show_selection (ESourceSelector *selector, - gboolean show); -gboolean e_source_selector_selection_shown (ESourceSelector *selector); - -void e_source_selector_set_select_new (ESourceSelector *selector, gboolean state); - -ESource *e_source_selector_peek_primary_selection (ESourceSelector *selector); -void e_source_selector_set_primary_selection (ESourceSelector *selector, - ESource *source); - - -#endif /* _E_SOURCE_SELECTOR_H_ */ diff --git a/widgets/misc/e-system-errors.xml b/widgets/misc/e-system-errors.xml deleted file mode 100644 index 6bef345263..0000000000 --- a/widgets/misc/e-system-errors.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0"?> -<error-list domain="system"> - - <error id="ask-save-file-exists-overwrite" type="error" default="GTK_RESPONSE_CANCEL"> - <title>Overwrite file?</title> - <primary>File exists "{0}".</primary> - <secondary>Do you wish to overwrite it?</secondary> - <button stock="gtk-cancel" response="GTK_RESPONSE_CANCEL"/> - <button label="_Overwrite" response="GTK_RESPONSE_OK"/> - </error> - - <error id="no-save-file" type="error"> - <primary>Cannot save file "{0}".</primary> - <secondary>Because "{1}".</secondary> - </error> - - <error id="no-load-file" type="error"> - <primary>Cannot open file "{0}".</primary> - <secondary>Because "{1}".</secondary> - </error> - -</error-list> diff --git a/widgets/misc/e-system-errors.xml.h b/widgets/misc/e-system-errors.xml.h deleted file mode 100644 index 16f0891e9f..0000000000 --- a/widgets/misc/e-system-errors.xml.h +++ /dev/null @@ -1,15 +0,0 @@ -/* system:ask-save-file-exists-overwrite title */ -char *s = N_("Overwrite file?"); -/* system:ask-save-file-exists-overwrite primary */ -char *s = N_("File exists \"{0}\"."); -/* system:ask-save-file-exists-overwrite secondary */ -char *s = N_("Do you wish to overwrite it?"); -char *s = N_("_Overwrite"); -/* system:no-save-file primary */ -char *s = N_("Cannot save file \"{0}\"."); -/* system:no-save-file secondary */ -char *s = N_("Because \"{1}\"."); -/* system:no-load-file primary */ -char *s = N_("Cannot open file \"{0}\"."); -/* system:no-load-file secondary */ -char *s = N_("Because \"{1}\"."); diff --git a/widgets/misc/e-task-bar.c b/widgets/misc/e-task-bar.c deleted file mode 100644 index bb1fdb96ff..0000000000 --- a/widgets/misc/e-task-bar.c +++ /dev/null @@ -1,231 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-bar.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-task-bar.h" - -#include <gal/util/e-util.h> -#include "widgets/misc/e-clipped-label.h" - - -struct _ETaskBarPrivate -{ - EClippedLabel *message_label; - GtkHBox *hbox; -}; - -#define PARENT_TYPE gtk_hbox_get_type () -static GtkHBoxClass *parent_class = NULL; - - -/* WARNING: Ugly hack starts here. */ - -#define MAX_ACTIVITIES_PER_COMPONENT 2 - -static void -reduce_displayed_activities_per_component (ETaskBar *task_bar) -{ - GHashTable *component_ids_hash; - GtkBox *box; - GList *p; - - component_ids_hash = g_hash_table_new (g_str_hash, g_str_equal); - - box = GTK_BOX (task_bar->priv->hbox); - - for (p = box->children; p != NULL; p = p->next) { - GtkBoxChild *child; - const char *component_id; - void *hash_item; - - child = (GtkBoxChild *) p->data; - component_id = e_task_widget_get_component_id (E_TASK_WIDGET (child->widget)); - - hash_item = g_hash_table_lookup (component_ids_hash, component_id); - - if (hash_item == NULL) { - gtk_widget_show (child->widget); - g_hash_table_insert (component_ids_hash, (void *) component_id, GINT_TO_POINTER (1)); - } else { - int num_items; - - num_items = GPOINTER_TO_INT (hash_item); - g_assert (num_items <= MAX_ACTIVITIES_PER_COMPONENT); - - if (num_items == MAX_ACTIVITIES_PER_COMPONENT) { - gtk_widget_hide (child->widget); - } else { - num_items ++; - gtk_widget_show (child->widget); - g_hash_table_insert (component_ids_hash, (void *) component_id, GINT_TO_POINTER (num_items)); - } - } - } - - g_hash_table_destroy (component_ids_hash); -} - - -static void -class_init (GtkObjectClass *object_class) -{ - parent_class = g_type_class_ref(PARENT_TYPE); -} - -static void -init (ETaskBar *task_bar) -{ - GtkWidget *label, *hbox; - - task_bar->priv = g_new (ETaskBarPrivate, 1); - - gtk_box_set_spacing (GTK_BOX (task_bar), 10); - - label = e_clipped_label_new ("", PANGO_WEIGHT_NORMAL, 1.0); - gtk_box_pack_start (GTK_BOX (task_bar), label, TRUE, TRUE, 0); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - task_bar->priv->message_label = E_CLIPPED_LABEL (label); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (task_bar), hbox); - task_bar->priv->hbox = GTK_HBOX (hbox); -} - - -void -e_task_bar_construct (ETaskBar *task_bar) -{ - g_return_if_fail (task_bar != NULL); - g_return_if_fail (E_IS_TASK_BAR (task_bar)); - - /* Nothing to do here. */ -} - -GtkWidget * -e_task_bar_new (void) -{ - ETaskBar *task_bar; - - task_bar = g_object_new (e_task_bar_get_type (), NULL); - e_task_bar_construct (task_bar); - - return GTK_WIDGET (task_bar); -} - -void -e_task_bar_set_message (ETaskBar *task_bar, - const char *message) -{ - if (message) { - gtk_widget_show (GTK_WIDGET (task_bar->priv->message_label)); - e_clipped_label_set_text (task_bar->priv->message_label, - message); - } else { - e_task_bar_unset_message (task_bar); - } -} - -void -e_task_bar_unset_message (ETaskBar *task_bar) -{ - gtk_widget_hide (GTK_WIDGET (task_bar->priv->message_label)); -} - -void -e_task_bar_prepend_task (ETaskBar *task_bar, - ETaskWidget *task_widget) -{ - GtkBoxChild *child_info; - GtkBox *box; - - g_return_if_fail (task_bar != NULL); - g_return_if_fail (E_IS_TASK_BAR (task_bar)); - g_return_if_fail (task_widget != NULL); - g_return_if_fail (E_IS_TASK_WIDGET (task_widget)); - - /* Hah hah. GTK+ sucks. This is adapted from `gtkhbox.c'. */ - - child_info = g_new (GtkBoxChild, 1); - child_info->widget = GTK_WIDGET (task_widget); - child_info->padding = 0; - child_info->expand = TRUE; - child_info->fill = TRUE; - child_info->pack = GTK_PACK_START; - - box = GTK_BOX (task_bar->priv->hbox); - - box->children = g_list_prepend (box->children, child_info); - - gtk_widget_set_parent (GTK_WIDGET (task_widget), GTK_WIDGET (task_bar->priv->hbox)); - - if (GTK_WIDGET_REALIZED (task_bar)) - gtk_widget_realize (GTK_WIDGET (task_widget)); - - if (GTK_WIDGET_VISIBLE (task_bar) && GTK_WIDGET_VISIBLE (task_widget)) { - if (GTK_WIDGET_MAPPED (task_bar)) - gtk_widget_map (GTK_WIDGET (task_widget)); - gtk_widget_queue_resize (GTK_WIDGET (task_widget)); - } - - reduce_displayed_activities_per_component (task_bar); - - gtk_widget_show (GTK_WIDGET (task_bar->priv->hbox)); -} - -void -e_task_bar_remove_task (ETaskBar *task_bar, - int n) -{ - ETaskWidget *task_widget; - - g_return_if_fail (task_bar != NULL); - g_return_if_fail (E_IS_TASK_BAR (task_bar)); - g_return_if_fail (n >= 0); - - task_widget = e_task_bar_get_task_widget (task_bar, n); - gtk_widget_destroy (GTK_WIDGET (task_widget)); - - reduce_displayed_activities_per_component (task_bar); - - if (g_list_length (GTK_BOX (task_bar->priv->hbox)->children) == 0) - gtk_widget_hide (GTK_WIDGET (task_bar->priv->hbox)); -} - -ETaskWidget * -e_task_bar_get_task_widget (ETaskBar *task_bar, - int n) -{ - GtkBoxChild *child_info; - - g_return_val_if_fail (task_bar != NULL, NULL); - g_return_val_if_fail (E_IS_TASK_BAR (task_bar), NULL); - - child_info = (GtkBoxChild *) g_list_nth (GTK_BOX (task_bar->priv->hbox)->children, n)->data; - - return E_TASK_WIDGET (child_info->widget); -} - - -E_MAKE_TYPE (e_task_bar, "ETaskBar", ETaskBar, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-task-bar.h b/widgets/misc/e-task-bar.h deleted file mode 100644 index e91e5fab65..0000000000 --- a/widgets/misc/e-task-bar.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-bar.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_TASK_BAR_H_ -#define _E_TASK_BAR_H_ - -#include "e-task-widget.h" - -#include <gtk/gtkhbox.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_TASK_BAR (e_task_bar_get_type ()) -#define E_TASK_BAR(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TASK_BAR, ETaskBar)) -#define E_TASK_BAR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TASK_BAR, ETaskBarClass)) -#define E_IS_TASK_BAR(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TASK_BAR)) -#define E_IS_TASK_BAR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_TASK_BAR)) - - -typedef struct _ETaskBar ETaskBar; -typedef struct _ETaskBarPrivate ETaskBarPrivate; -typedef struct _ETaskBarClass ETaskBarClass; - -struct _ETaskBar { - GtkHBox parent; - - ETaskBarPrivate *priv; -}; - -struct _ETaskBarClass { - GtkHBoxClass parent_class; -}; - - -GtkType e_task_bar_get_type (void); -void e_task_bar_construct (ETaskBar *task_bar); -GtkWidget *e_task_bar_new (void); - -void e_task_bar_set_message (ETaskBar *task_bar, - const char *message); -void e_task_bar_unset_message (ETaskBar *task_bar); - -void e_task_bar_prepend_task (ETaskBar *task_bar, - ETaskWidget *task_widget); -void e_task_bar_remove_task (ETaskBar *task_bar, - int n); - -ETaskWidget *e_task_bar_get_task_widget (ETaskBar *task_bar, - int n); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_TASK_BAR_H_ */ diff --git a/widgets/misc/e-task-widget.c b/widgets/misc/e-task-widget.c deleted file mode 100644 index ab610f77f9..0000000000 --- a/widgets/misc/e-task-widget.c +++ /dev/null @@ -1,252 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-widget.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-task-widget.h" - -#include <gtk/gtkframe.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkimage.h> -#include <gtk/gtktooltips.h> - -#include <libgnome/gnome-i18n.h> - -#include <gal/util/e-util.h> - - -#define SPACING 2 - -#define PARENT_TYPE (gtk_event_box_get_type ()) -static GtkEventBoxClass *parent_class = NULL; - -struct _ETaskWidgetPrivate { - char *component_id; - - GtkTooltips *tooltips; - - GdkPixbuf *icon_pixbuf; - GtkWidget *label; - GtkWidget *image; -}; - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ETaskWidget *task_widget; - ETaskWidgetPrivate *priv; - - task_widget = E_TASK_WIDGET (object); - - priv = task_widget->priv; - - if (priv->tooltips != NULL) { - g_object_unref (priv->tooltips); - priv->tooltips = NULL; - } - - if (priv->icon_pixbuf != NULL) { - g_object_unref (priv->icon_pixbuf); - priv->icon_pixbuf = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - ETaskWidget *task_widget; - ETaskWidgetPrivate *priv; - - task_widget = E_TASK_WIDGET (object); - priv = task_widget->priv; - - g_free (priv->component_id); - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -class_init (GObjectClass *object_class) -{ - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; -} - -static void -init (ETaskWidget *task_widget) -{ - ETaskWidgetPrivate *priv; - - priv = g_new (ETaskWidgetPrivate, 1); - - priv->component_id = NULL; - priv->tooltips = NULL; - priv->icon_pixbuf = NULL; - priv->label = NULL; - priv->image = NULL; - - task_widget->priv = priv; -} - - -void -e_task_widget_construct (ETaskWidget *task_widget, - GdkPixbuf *icon_pixbuf, - const char *component_id, - const char *information) -{ - ETaskWidgetPrivate *priv; - GdkPixmap *pixmap; - GdkBitmap *mask; - GtkWidget *box; - GtkWidget *frame; - - g_return_if_fail (task_widget != NULL); - g_return_if_fail (E_IS_TASK_WIDGET (task_widget)); - g_return_if_fail (icon_pixbuf != NULL); - g_return_if_fail (component_id != NULL); - g_return_if_fail (information != NULL); - - priv = task_widget->priv; - - priv->component_id = g_strdup (component_id); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (task_widget), frame); - gtk_widget_show (frame); - - box = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), box); - gtk_widget_show (box); - - gtk_widget_set_size_request (box, 1, -1); - - priv->icon_pixbuf = g_object_ref (icon_pixbuf); - - gdk_pixbuf_render_pixmap_and_mask (icon_pixbuf, &pixmap, &mask, 128); - - priv->image = gtk_image_new_from_pixmap (pixmap, mask); - gtk_widget_show (priv->image); - gtk_box_pack_start (GTK_BOX (box), priv->image, FALSE, TRUE, 0); - - priv->label = gtk_label_new (""); - gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5); - gtk_widget_show (priv->label); - gtk_box_pack_start (GTK_BOX (box), priv->label, TRUE, TRUE, 0); - - gdk_pixmap_unref (pixmap); - if (mask) - gdk_bitmap_unref (mask); - - priv->tooltips = gtk_tooltips_new (); - g_object_ref (priv->tooltips); - gtk_object_sink (GTK_OBJECT (priv->tooltips)); - - e_task_widget_update (task_widget, information, -1.0); -} - -GtkWidget * -e_task_widget_new (GdkPixbuf *icon_pixbuf, - const char *component_id, - const char *information) -{ - ETaskWidget *task_widget; - - g_return_val_if_fail (icon_pixbuf != NULL, NULL); - g_return_val_if_fail (information != NULL, NULL); - - task_widget = g_object_new (e_task_widget_get_type (), NULL); - e_task_widget_construct (task_widget, icon_pixbuf, component_id, information); - - return GTK_WIDGET (task_widget); -} - - -void -e_task_widget_update (ETaskWidget *task_widget, - const char *information, - double completion) -{ - ETaskWidgetPrivate *priv; - char *text; - - g_return_if_fail (task_widget != NULL); - g_return_if_fail (E_IS_TASK_WIDGET (task_widget)); - g_return_if_fail (information != NULL); - - priv = task_widget->priv; - - if (completion < 0.0) { - text = g_strdup_printf (_("%s (...)"), information); - } else { - int percent_complete; - - percent_complete = (int) (completion * 100.0 + .5); - text = g_strdup_printf (_("%s (%d%% complete)"), information, percent_complete); - } - - gtk_label_set_text (GTK_LABEL (priv->label), text); - - gtk_tooltips_set_tip (priv->tooltips, GTK_WIDGET (task_widget), text, NULL); - - g_free (text); -} - -void -e_task_wiget_alert (ETaskWidget *task_widget) -{ - g_return_if_fail (task_widget != NULL); - g_return_if_fail (E_IS_TASK_WIDGET (task_widget)); -} - -void -e_task_wiget_unalert (ETaskWidget *task_widget) -{ - g_return_if_fail (task_widget != NULL); - g_return_if_fail (E_IS_TASK_WIDGET (task_widget)); -} - - -const char * -e_task_widget_get_component_id (ETaskWidget *task_widget) -{ - g_return_val_if_fail (task_widget != NULL, NULL); - g_return_val_if_fail (E_IS_TASK_WIDGET (task_widget), NULL); - - return task_widget->priv->component_id; -} - - -E_MAKE_TYPE (e_task_widget, "ETaskWidget", ETaskWidget, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-task-widget.h b/widgets/misc/e-task-widget.h deleted file mode 100644 index 6173623a80..0000000000 --- a/widgets/misc/e-task-widget.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-task-widget.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_TASK_WIDGET_H_ -#define _E_TASK_WIDGET_H_ - -#include <gtk/gtkeventbox.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_TASK_WIDGET (e_task_widget_get_type ()) -#define E_TASK_WIDGET(obj) (GTK_CHECK_CAST ((obj), E_TYPE_TASK_WIDGET, ETaskWidget)) -#define E_TASK_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_TASK_WIDGET, ETaskWidgetClass)) -#define E_IS_TASK_WIDGET(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_TASK_WIDGET)) -#define E_IS_TASK_WIDGET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_TASK_WIDGET)) - - -typedef struct _ETaskWidget ETaskWidget; -typedef struct _ETaskWidgetPrivate ETaskWidgetPrivate; -typedef struct _ETaskWidgetClass ETaskWidgetClass; - -struct _ETaskWidget { - GtkEventBox parent; - - ETaskWidgetPrivate *priv; -}; - -struct _ETaskWidgetClass { - GtkEventBoxClass parent_class; -}; - - -GtkType e_task_widget_get_type (void); -void e_task_widget_construct (ETaskWidget *task_widget, - GdkPixbuf *icon_pixbuf, - const char *component_id, - const char *information); -GtkWidget *e_task_widget_new (GdkPixbuf *icon_pixbuf, - const char *component_id, - const char *information); - -void e_task_widget_update (ETaskWidget *task_widget, - const char *information, - double completion); - -void e_task_wiget_alert (ETaskWidget *task_widget); -void e_task_wiget_unalert (ETaskWidget *task_widget); - -const char *e_task_widget_get_component_id (ETaskWidget *task_widget); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_TASK_WIDGET_H_ */ diff --git a/widgets/misc/e-title-bar.c b/widgets/misc/e-title-bar.c deleted file mode 100644 index 4d4e36e45b..0000000000 --- a/widgets/misc/e-title-bar.c +++ /dev/null @@ -1,404 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-title-bar.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkbox.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkpixmap.h> -#include <gtk/gtksignal.h> -#include <gtk/gtktypeutils.h> - -#include <gal/util/e-util.h> -#include "e-clipped-label.h" - -#include "e-title-bar.h" - - -enum { - LABEL_BUTTON_PRESS_EVENT, - BUTTON_CLICKED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - - -/* The pixmaps. */ - -static char *close_xpm[] = { - "16 16 2 1", - " c none", - ". c #000000000000", - " ", - " ", - " ", - " .. .. ", - " ... ... ", - " ... ... ", - " ...... ", - " .... ", - " .... ", - " ...... ", - " ... ... ", - " ... ... ", - " .. .. ", - " ", - " ", - " " -}; - -static char *pin_xpm[] = { - "16 16 33 1", - " c None", - ". c #000000", - "+ c #74744D", - "@ c #B2B279", - "# c #6C6C46", - "$ c #CACA9C", - "% c #F4F4AD", - "& c #85855A", - "* c #B1B175", - "= c #9A9A66", - "- c #A9A98A", - "; c #B0B07B", - "> c #535353", - ", c #818181", - "' c #B7B7B7", - ") c #D8D8D8", - "! c #FFFFFF", - "~ c #EBEBA1", - "{ c #8A8A75", - "] c #9F9F76", - "^ c #9E9E75", - "/ c #8A8A66", - "( c #979770", - "_ c #6B6B46", - ": c #28281A", - "< c #505034", - "[ c #666645", - "} c #61614D", - "| c #818155", - "1 c #4A4A31", - "2 c #4D4D34", - "3 c #6C6C48", - "4 c #5D5D3E", - " ", - " ", - " ", - " . . ", - " .. .+. ", - " .@...#$. ", - " ......%&*=-;. ", - ".>,')!.~{]^/(. ", - " ......_:<[}|. ", - " .1...23. ", - " .. .4. ", - " . . ", - " ", - " ", - " ", - " " -}; - - -#define PARENT_TYPE GTK_TYPE_FRAME -static GtkFrameClass *parent_class = NULL; - -struct _ETitleBarPrivate { - ETitleBarButtonMode button_mode; - GtkWidget *label; - GtkWidget *button; - GtkWidget *close_gtk_pixmap; - GtkWidget *pin_gtk_pixmap; -}; - - -/* Mode handling. We put both the close and pin GtkPixmaps into an hbox in the - button, and hide one of them according to the mode. */ - -static void -show_and_hide_pixmaps_according_to_mode (ETitleBar *title_bar) -{ - ETitleBarPrivate *priv; - - priv = title_bar->priv; - - if (priv->close_gtk_pixmap == NULL || priv->pin_gtk_pixmap == NULL) - return; - - switch (priv->button_mode) { - case E_TITLE_BAR_BUTTON_MODE_PIN: - gtk_widget_hide (priv->close_gtk_pixmap); - gtk_widget_show (priv->pin_gtk_pixmap); - break; - case E_TITLE_BAR_BUTTON_MODE_CLOSE: - gtk_widget_hide (priv->pin_gtk_pixmap); - gtk_widget_show (priv->close_gtk_pixmap); - break; - default: - g_assert_not_reached (); - } -} - - -/* Child signal callbacks. */ - -static void -button_realize_cb (GtkWidget *widget, - gpointer data) -{ - GdkPixmap *close_pixmap; - GdkBitmap *close_mask; - GdkPixmap *pin_pixmap; - GdkBitmap *pin_mask; - GtkWidget *hbox; - ETitleBar *title_bar; - ETitleBarPrivate *priv; - - title_bar = E_TITLE_BAR (data); - priv = title_bar->priv; - - if (priv->close_gtk_pixmap != NULL) - return; - - close_pixmap = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (priv->button)->window, - &close_mask, NULL, close_xpm); - priv->close_gtk_pixmap = gtk_pixmap_new (close_pixmap, close_mask); - - pin_pixmap = gdk_pixmap_create_from_xpm_d (GTK_WIDGET (priv->button)->window, - &pin_mask, NULL, pin_xpm); - priv->pin_gtk_pixmap = gtk_pixmap_new (pin_pixmap, pin_mask); - - hbox = gtk_hbox_new (TRUE, 0); - gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (hbox), priv->pin_gtk_pixmap, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->close_gtk_pixmap, TRUE, TRUE, 0); - - gtk_container_add (GTK_CONTAINER (priv->button), hbox); - - gdk_pixmap_unref (close_pixmap); - g_object_unref (close_mask); - gdk_pixmap_unref (pin_pixmap); - g_object_unref (pin_mask); - - show_and_hide_pixmaps_according_to_mode (title_bar); -} - -static void -button_clicked_cb (GtkButton *button, - gpointer data) -{ - ETitleBar *title_bar; - - title_bar = E_TITLE_BAR (data); - - gtk_signal_emit (GTK_OBJECT (title_bar), signals[BUTTON_CLICKED]); -} - -static void -label_button_press_event_cb (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - ETitleBar *title_bar; - - title_bar = E_TITLE_BAR (data); - - gtk_signal_emit (GTK_OBJECT (title_bar), signals[LABEL_BUTTON_PRESS_EVENT], event); -} - - -/* GObject methods. */ - -static void -impl_finalize (GObject *object) -{ - ETitleBar *title_bar; - ETitleBarPrivate *priv; - - title_bar = E_TITLE_BAR (object); - priv = title_bar->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -class_init (ETitleBarClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = impl_finalize; - - parent_class = g_type_class_ref(gtk_frame_get_type ()); - - signals[LABEL_BUTTON_PRESS_EVENT] = - gtk_signal_new ("label_button_press_event", - GTK_RUN_FIRST, - GTK_CLASS_TYPE (object_class), - G_STRUCT_OFFSET (ETitleBarClass, label_button_press_event), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - signals[BUTTON_CLICKED] = - gtk_signal_new ("button_clicked", - GTK_RUN_FIRST, - GTK_CLASS_TYPE (object_class), - G_STRUCT_OFFSET (ETitleBarClass, button_clicked), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); -} - -static void -init (ETitleBar *title_bar) -{ - ETitleBarPrivate *priv; - - priv = g_new (ETitleBarPrivate, 1); - - priv->button_mode = E_TITLE_BAR_BUTTON_MODE_CLOSE; - priv->label = NULL; - priv->button = NULL; - priv->close_gtk_pixmap = NULL; - priv->pin_gtk_pixmap = NULL; - - title_bar->priv = priv; -} - - -void -e_title_bar_construct (ETitleBar *title_bar, - const char *title) -{ - ETitleBarPrivate *priv; - GtkWidget *hbox; - - g_return_if_fail (title_bar != NULL); - g_return_if_fail (E_IS_TITLE_BAR (title_bar)); - - priv = title_bar->priv; - - priv->label = e_clipped_label_new (title, PANGO_WEIGHT_BOLD, 1.0); - gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5); - gtk_misc_set_padding (GTK_MISC (priv->label), 2, 0); - gtk_widget_show (priv->label); - - priv->button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (priv->button, GTK_CAN_FOCUS); - gtk_container_set_border_width (GTK_CONTAINER (priv->button), 1); - gtk_button_set_relief (GTK_BUTTON (priv->button), GTK_RELIEF_NONE); - gtk_widget_show (priv->button); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), priv->label, TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (hbox), priv->button, FALSE, TRUE, 1); - gtk_widget_show (hbox); - - gtk_container_add (GTK_CONTAINER (title_bar), hbox); - - g_signal_connect((priv->button), "realize", - G_CALLBACK (button_realize_cb), title_bar); - g_signal_connect((priv->button), "clicked", - G_CALLBACK (button_clicked_cb), title_bar); - g_signal_connect((priv->label), "button_press_event", - G_CALLBACK (label_button_press_event_cb), title_bar); -} - -GtkWidget * -e_title_bar_new (const char *title) -{ - ETitleBar *title_bar; - - title_bar = gtk_type_new (e_title_bar_get_type ()); - - e_title_bar_construct (title_bar, title); - - return GTK_WIDGET (title_bar); -} - - -void -e_title_bar_set_title (ETitleBar *title_bar, - const char *title) -{ - g_return_if_fail (title_bar != NULL); - g_return_if_fail (E_IS_TITLE_BAR (title_bar)); - - e_clipped_label_set_text (E_CLIPPED_LABEL (title_bar->priv->label), title); -} - -void -e_title_bar_show_button (ETitleBar *title_bar, - gboolean show) -{ - ETitleBarPrivate *priv; - - g_return_if_fail (title_bar != NULL); - g_return_if_fail (E_IS_TITLE_BAR (title_bar)); - - priv = title_bar->priv; - - if (show) - gtk_widget_show (priv->button); - else - gtk_widget_hide (priv->button); -} - -void -e_title_bar_set_button_mode (ETitleBar *title_bar, - ETitleBarButtonMode button_mode) -{ - ETitleBarPrivate *priv; - - g_return_if_fail (title_bar != NULL); - g_return_if_fail (E_IS_TITLE_BAR (title_bar)); - g_return_if_fail (button_mode == E_TITLE_BAR_BUTTON_MODE_CLOSE - || button_mode == E_TITLE_BAR_BUTTON_MODE_PIN); - - priv = title_bar->priv; - - if (priv->button_mode == button_mode) - return; - - priv->button_mode = button_mode; - show_and_hide_pixmaps_according_to_mode (title_bar); -} - -ETitleBarButtonMode -e_title_bar_get_button_mode (ETitleBar *title_bar) -{ - g_return_val_if_fail (title_bar != NULL, E_TITLE_BAR_BUTTON_MODE_CLOSE); - g_return_val_if_fail (E_IS_TITLE_BAR (title_bar), E_TITLE_BAR_BUTTON_MODE_CLOSE); - - return title_bar->priv->button_mode; -} - - -E_MAKE_TYPE (e_title_bar, "ETitleBar", ETitleBar, class_init, init, PARENT_TYPE) diff --git a/widgets/misc/e-title-bar.h b/widgets/misc/e-title-bar.h deleted file mode 100644 index 32c4f2b262..0000000000 --- a/widgets/misc/e-title-bar.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-title-bar.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -#ifndef __E_TITLE_BAR_H__ -#define __E_TITLE_BAR_H__ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkframe.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_TITLE_BAR (e_title_bar_get_type ()) -#define E_TITLE_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_TITLE_BAR, ETitleBar)) -#define E_TITLE_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_TITLE_BAR, ETitleBarClass)) -#define E_IS_TITLE_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_TITLE_BAR)) -#define E_IS_TITLE_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_TITLE_BAR)) - - -enum _ETitleBarButtonMode { - E_TITLE_BAR_BUTTON_MODE_PIN, - E_TITLE_BAR_BUTTON_MODE_CLOSE -}; -typedef enum _ETitleBarButtonMode ETitleBarButtonMode; - -typedef struct _ETitleBar ETitleBar; -typedef struct _ETitleBarPrivate ETitleBarPrivate; -typedef struct _ETitleBarClass ETitleBarClass; - -struct _ETitleBar { - GtkFrame parent; - - ETitleBarPrivate *priv; -}; - -struct _ETitleBarClass { - GtkFrameClass parent_class; - - /* Signals. */ - - void (* label_button_press_event) (ETitleBar *title_bar, GdkEventButton *event); - void (* button_clicked) (ETitleBar *title_bar); -}; - - -GtkType e_title_bar_get_type (void); -void e_title_bar_construct (ETitleBar *title_bar, - const char *title); -GtkWidget *e_title_bar_new (const char *title); -void e_title_bar_set_title (ETitleBar *title_bar, - const char *title); -void e_title_bar_show_button (ETitleBar *title_bar, - gboolean show); -void e_title_bar_set_button_mode (ETitleBar *title_bar, - ETitleBarButtonMode button_mode); -ETitleBarButtonMode e_title_bar_get_button_mode (ETitleBar *title_bar); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_TITLE_BAR_H__ */ diff --git a/widgets/misc/e-url-entry.c b/widgets/misc/e-url-entry.c deleted file mode 100644 index e2f15802f9..0000000000 --- a/widgets/misc/e-url-entry.c +++ /dev/null @@ -1,195 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-url-entry.c - * - * Copyright (C) 2002 JP Rosevear - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser 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: JP Rosevear - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> -#include <libgnome/gnome-url.h> -#include "e-url-entry.h" -#include <e-util/e-icon-factory.h> - -struct _EUrlEntryPrivate { - GtkWidget *entry; - GtkWidget *button; -}; - -static void class_init (EUrlEntryClass *klass); -static void init (EUrlEntry *url_entry); -static void destroy (GtkObject *obj); - -static void button_clicked_cb (GtkWidget *widget, gpointer data); -static void entry_changed_cb (GtkEditable *editable, gpointer data); - -static gboolean mnemonic_activate (GtkWidget *widget, gboolean group_cycling); - -static GtkHBoxClass *parent_class = NULL; - - -GtkType -e_url_entry_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) - { - static const GtkTypeInfo info = - { - "EUrlEntry", - sizeof (EUrlEntry), - sizeof (EUrlEntryClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (gtk_hbox_get_type (), &info); - } - - return type; -} - -static void -class_init (EUrlEntryClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - - parent_class = g_type_class_ref(gtk_hbox_get_type ()); - - object_class->destroy = destroy; - - widget_class->mnemonic_activate = mnemonic_activate; -} - - -static void -init (EUrlEntry *url_entry) -{ - EUrlEntryPrivate *priv; - GtkWidget *pixmap; - GdkPixbuf *pixbuf; - - priv = g_new0 (EUrlEntryPrivate, 1); - url_entry->priv = priv; - - priv->entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (url_entry), priv->entry, TRUE, TRUE, 0); - priv->button = gtk_button_new (); - gtk_widget_set_sensitive (priv->button, FALSE); - gtk_box_pack_start (GTK_BOX (url_entry), priv->button, FALSE, FALSE, 0); - pixbuf = e_icon_factory_get_icon ("stock_connect-to-url", E_ICON_SIZE_BUTTON); - pixmap = gtk_image_new_from_pixbuf (pixbuf); - g_object_unref (pixbuf); - gtk_container_add (GTK_CONTAINER (priv->button), pixmap); - gtk_widget_show (pixmap); - - gtk_widget_show (priv->button); - gtk_widget_show (priv->entry); - - g_signal_connect (priv->button, "clicked", - G_CALLBACK (button_clicked_cb), url_entry); - g_signal_connect (priv->entry, "changed", - G_CALLBACK (entry_changed_cb), url_entry); -} - -static void -destroy (GtkObject *obj) -{ - EUrlEntry *url_entry; - - url_entry = E_URL_ENTRY (obj); - if (url_entry->priv) { - g_free (url_entry->priv); - url_entry->priv = NULL; - } - - GTK_OBJECT_CLASS (parent_class)->destroy (obj); -} - -/* GtkWidget::mnemonic_activate() handler for the EUrlEntry */ -static gboolean -mnemonic_activate (GtkWidget *widget, gboolean group_cycling) -{ - EUrlEntry *url_entry; - EUrlEntryPrivate *priv; - - url_entry = E_URL_ENTRY (widget); - priv = url_entry->priv; - - return gtk_widget_mnemonic_activate (priv->entry, group_cycling); -} - - - -GtkWidget * -e_url_entry_new (void) -{ - return gtk_type_new (E_TYPE_URL_ENTRY); -} - - -GtkWidget * -e_url_entry_get_entry (EUrlEntry *url_entry) -{ - EUrlEntryPrivate *priv; - - g_return_val_if_fail (url_entry != NULL, NULL); - g_return_val_if_fail (E_IS_URL_ENTRY (url_entry), NULL); - - priv = url_entry->priv; - - return priv->entry; -} - -static void -button_clicked_cb (GtkWidget *widget, gpointer data) -{ - EUrlEntry *url_entry; - EUrlEntryPrivate *priv; - - url_entry = E_URL_ENTRY (data); - priv = url_entry->priv; - - gnome_url_show (gtk_entry_get_text (GTK_ENTRY (priv->entry)), NULL); -} - -static void -entry_changed_cb (GtkEditable *editable, gpointer data) -{ - EUrlEntry *url_entry; - EUrlEntryPrivate *priv; - const char *url; - - url_entry = E_URL_ENTRY (data); - priv = url_entry->priv; - - url = gtk_entry_get_text (GTK_ENTRY (priv->entry)); - gtk_widget_set_sensitive (priv->button, url != NULL && *url != '\0'); -} diff --git a/widgets/misc/e-url-entry.h b/widgets/misc/e-url-entry.h deleted file mode 100644 index 3cf98d7b8c..0000000000 --- a/widgets/misc/e-url-entry.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-url-entry.h - * - * Copyright (C) 2002 JP Rosevear - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser 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: JP Rosevear - */ - -#ifndef _E_URL_ENTRY_H_ -#define _E_URL_ENTRY_H_ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_URL_ENTRY (e_url_entry_get_type ()) -#define E_URL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_URL_ENTRY, EUrlEntry)) -#define E_URL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_URL_ENTRY, EUrlEntryClass)) -#define E_IS_URL_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_URL_ENTRY)) -#define E_IS_URL_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_URL_ENTRY)) - - -typedef struct _EUrlEntry EUrlEntry; -typedef struct _EUrlEntryPrivate EUrlEntryPrivate; -typedef struct _EUrlEntryClass EUrlEntryClass; - -struct _EUrlEntry { - GtkHBox parent; - - EUrlEntryPrivate *priv; -}; - -struct _EUrlEntryClass { - GtkHBoxClass parent_class; -}; - - - -GtkType e_url_entry_get_type (void); -GtkWidget *e_url_entry_new (void); -GtkWidget *e_url_entry_get_entry (EUrlEntry *url_entry); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_URL_ENTRY_H_ */ diff --git a/widgets/misc/e-util-marshal.list b/widgets/misc/e-util-marshal.list deleted file mode 100644 index 0cb9a24afe..0000000000 --- a/widgets/misc/e-util-marshal.list +++ /dev/null @@ -1,3 +0,0 @@ -NONE:NONE -NONE:INT -NONE:POINTER diff --git a/widgets/misc/test-calendar.c b/widgets/misc/test-calendar.c deleted file mode 100644 index f156e66599..0000000000 --- a/widgets/misc/test-calendar.c +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * test-calendar - tests the ECalendar widget. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkdnd.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkvbox.h> - -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-ui-init.h> - -#include "e-calendar.h" - -/* Drag and Drop stuff. */ -enum { - TARGET_SHORTCUT -}; -static GtkTargetEntry target_table[] = { - { "E-SHORTCUT", 0, TARGET_SHORTCUT } -}; -static guint n_targets = sizeof(target_table) / sizeof(target_table[0]); - - -static void on_date_range_changed (ECalendarItem *calitem); -static void on_selection_changed (ECalendarItem *calitem); -static void get_day_style (ECalendarItem *calitem, - gint year, - gint month, - gint day, - gint day_style, - gboolean today, - gboolean prev_or_next_month, - gboolean selected, - gboolean has_focus, - gboolean drop_target, - GdkColor **bg_color, - GdkColor **fg_color, - GdkColor **box_color, - gboolean *bold, - gpointer data); - -static void -delete_event_cb (GtkWidget *widget, - GdkEventAny *event, - gpointer data) -{ - gtk_main_quit (); -} - -int -main (int argc, char **argv) -{ - GtkWidget *app; - GtkWidget *cal; - GtkWidget *vbox; - ECalendarItem *calitem; - - gnome_init ("test-calendar", "0.0", argc, argv); - - app = gnome_app_new ("Test", "Test"); - gtk_window_set_default_size (GTK_WINDOW (app), 400, 400); - gtk_window_set_policy (GTK_WINDOW (app), FALSE, TRUE, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (app), 8); - - g_signal_connect((app), "delete_event", - G_CALLBACK (delete_event_cb), NULL); - - cal = e_calendar_new (); - e_calendar_set_minimum_size (E_CALENDAR (cal), 1, 1); - calitem = E_CALENDAR (cal)->calitem; - gtk_widget_show (cal); - e_calendar_item_set_style_callback (calitem, get_day_style, - NULL, NULL); - - g_signal_connect((calitem), "date_range_changed", - G_CALLBACK (on_date_range_changed), NULL); - g_signal_connect((calitem), "selection_changed", - G_CALLBACK (on_selection_changed), NULL); - - - gtk_drag_dest_set (cal, - GTK_DEST_DEFAULT_ALL, - target_table, n_targets, - GDK_ACTION_COPY | GDK_ACTION_MOVE); - - - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), cal, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - gnome_app_set_contents (GNOME_APP (app), vbox); - gtk_widget_show (app); - - gtk_main (); - - return 0; -} - - -static void -on_date_range_changed (ECalendarItem *calitem) -{ - gint start_year, start_month, start_day; - gint end_year, end_month, end_day; - - e_calendar_item_get_date_range (calitem, - &start_year, &start_month, &start_day, - &end_year, &end_month, &end_day); - - g_print ("Date range changed (D/M/Y): %i/%i/%i - %i/%i/%i\n", - start_day, start_month + 1, start_year, - end_day, end_month + 1, end_year); - - /* These days should appear bold. Remember month is 0 to 11. */ - e_calendar_item_mark_day (calitem, 2000, 7, 26, /* 26th Aug 2000. */ - E_CALENDAR_ITEM_MARK_BOLD); - e_calendar_item_mark_day (calitem, 2000, 8, 13, /* 13th Sep 2000. */ - E_CALENDAR_ITEM_MARK_BOLD); -} - - -static void -on_selection_changed (ECalendarItem *calitem) -{ - GDate start_date, end_date; - - e_calendar_item_get_selection (calitem, &start_date, &end_date); - - g_print ("Selection changed (D/M/Y): %i/%i/%i - %i/%i/%i\n", - g_date_get_day (&start_date), - g_date_get_month (&start_date), - g_date_get_year (&start_date), - g_date_get_day (&end_date), - g_date_get_month (&end_date), - g_date_get_year (&end_date)); -} - - -static void -get_day_style (ECalendarItem *calitem, - gint year, - gint month, - gint day, - gint day_style, - gboolean today, - gboolean prev_or_next_month, - gboolean selected, - gboolean has_focus, - gboolean drop_target, - GdkColor **bg_color, - GdkColor **fg_color, - GdkColor **box_color, - gboolean *bold, - gpointer data) -{ - *bg_color = NULL; - *fg_color = NULL; - *box_color = NULL; - *bold = FALSE; - -#if 1 - - if (day_style == 1) - *bold = TRUE; - - if (today) - *box_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX]; - - if (prev_or_next_month) - *fg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG]; - - if (selected) { - *fg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG]; - *bg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_BG]; - } - -#else - - if (day_style == 1) - *bold = TRUE; - - if (today) - *box_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG]; - - if (prev_or_next_month) - *fg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_TODAY_BOX]; - - if (selected) { - *fg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_SELECTION_FG]; - *bg_color = &calitem->colors[E_CALENDAR_ITEM_COLOR_PREV_OR_NEXT_MONTH_FG]; - } - -#endif -} diff --git a/widgets/misc/test-charset-picker.c b/widgets/misc/test-charset-picker.c deleted file mode 100644 index 889bba2600..0000000000 --- a/widgets/misc/test-charset-picker.c +++ /dev/null @@ -1,18 +0,0 @@ -#include <gnome.h> -#include "e-charset-picker.h" - -int -main (int argc, char **argv) -{ - char *charset; - - gnome_init ("test-charset-picker", "1.0", argc, argv); - - charset = e_charset_picker_dialog ("test-charset-picker", - "Pick a charset, any charset", - NULL, NULL); - if (charset) - printf ("You picked: %s\n", charset); - - return 0; -} diff --git a/widgets/misc/test-dateedit.c b/widgets/misc/test-dateedit.c deleted file mode 100644 index c96e881369..0000000000 --- a/widgets/misc/test-dateedit.c +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Damon Chaplin <damon@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* - * test-dateedit - tests the EDateEdit widget. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtkmain.h> -#include <gtk/gtktable.h> -#include <gtk/gtkwindow.h> -#include <libgnomeui/gnome-ui-init.h> -#include <libgnomeui/gnome-app.h> -#include "e-dateedit.h" - -static void delete_event_cb (GtkWidget *widget, - GdkEventAny *event, - GtkWidget *app); -static void on_get_date_clicked (GtkWidget *button, - EDateEdit *dedit); -static void on_toggle_24_hour_clicked (GtkWidget *button, - EDateEdit *dedit); -static void on_changed (EDateEdit *dedit, - gchar *name); -#if 0 -static void on_date_changed (EDateEdit *dedit, - gchar *name); -static void on_time_changed (EDateEdit *dedit, - gchar *name); -#endif - -int -main (int argc, char **argv) -{ - GtkWidget *app; - EDateEdit *dedit; - GtkWidget *table, *button; - - gnome_program_init ("test-dateedit", "0.0", LIBGNOMEUI_MODULE, argc, argv, NULL); - - puts ("here"); - - app = gnome_app_new ("Test", "Test"); - gtk_window_set_default_size (GTK_WINDOW (app), 300, 200); - gtk_window_set_policy (GTK_WINDOW (app), FALSE, TRUE, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (app), 8); - - g_signal_connect((app), "delete_event", - G_CALLBACK (delete_event_cb), app); - - table = gtk_table_new (3, 3, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 4); - gtk_widget_show (table); - gnome_app_set_contents (GNOME_APP (app), table); - - /* EDateEdit 1. */ - dedit = E_DATE_EDIT (e_date_edit_new ()); - gtk_table_attach (GTK_TABLE (table), (GtkWidget*) dedit, - 0, 1, 0, 1, GTK_FILL, GTK_EXPAND, 0, 0); - gtk_widget_show ((GtkWidget*) (dedit)); - -#if 0 - g_signal_connect((dedit), "date_changed", - G_CALLBACK (on_date_changed), "1"); - g_signal_connect((dedit), "time_changed", - G_CALLBACK (on_time_changed), "1"); -#else - g_signal_connect((dedit), "changed", - G_CALLBACK (on_changed), "1"); -#endif - - button = gtk_button_new_with_label ("Print Date"); - gtk_table_attach (GTK_TABLE (table), button, - 1, 2, 0, 1, 0, 0, 0, 0); - gtk_widget_show (button); - g_signal_connect((button), "clicked", - G_CALLBACK (on_get_date_clicked), dedit); - - /* EDateEdit 2. */ - dedit = E_DATE_EDIT (e_date_edit_new ()); - gtk_table_attach (GTK_TABLE (table), (GtkWidget*) dedit, - 0, 1, 1, 2, GTK_FILL, GTK_EXPAND, 0, 0); - gtk_widget_show ((GtkWidget*) (dedit)); - e_date_edit_set_week_start_day (dedit, 1); - e_date_edit_set_show_week_numbers (dedit, TRUE); - e_date_edit_set_use_24_hour_format (dedit, FALSE); - e_date_edit_set_time_popup_range (dedit, 8, 18); - e_date_edit_set_show_time (dedit, FALSE); - -#if 0 - g_signal_connect((dedit), "date_changed", - G_CALLBACK (on_date_changed), "2"); - g_signal_connect((dedit), "time_changed", - G_CALLBACK (on_time_changed), "2"); -#else - g_signal_connect((dedit), "changed", - G_CALLBACK (on_changed), "2"); -#endif - - button = gtk_button_new_with_label ("Print Date"); - gtk_table_attach (GTK_TABLE (table), button, - 1, 2, 1, 2, 0, 0, 0, 0); - gtk_widget_show (button); - g_signal_connect((button), "clicked", - G_CALLBACK (on_get_date_clicked), dedit); - - /* EDateEdit 3. */ - dedit = E_DATE_EDIT (e_date_edit_new ()); - gtk_table_attach (GTK_TABLE (table), (GtkWidget*) dedit, - 0, 1, 2, 3, GTK_FILL, GTK_EXPAND, 0, 0); - gtk_widget_show ((GtkWidget*) (dedit)); - e_date_edit_set_week_start_day (dedit, 1); - e_date_edit_set_show_week_numbers (dedit, TRUE); - e_date_edit_set_use_24_hour_format (dedit, FALSE); - e_date_edit_set_time_popup_range (dedit, 8, 18); - e_date_edit_set_allow_no_date_set (dedit, TRUE); - -#if 0 - g_signal_connect((dedit), "date_changed", - G_CALLBACK (on_date_changed), "3"); - g_signal_connect((dedit), "time_changed", - G_CALLBACK (on_time_changed), "3"); -#else - g_signal_connect((dedit), "changed", - G_CALLBACK (on_changed), "3"); -#endif - - button = gtk_button_new_with_label ("Print Date"); - gtk_table_attach (GTK_TABLE (table), button, - 1, 2, 2, 3, 0, 0, 0, 0); - gtk_widget_show (button); - g_signal_connect((button), "clicked", - G_CALLBACK (on_get_date_clicked), dedit); - - button = gtk_button_new_with_label ("Toggle 24-hour"); - gtk_table_attach (GTK_TABLE (table), button, - 2, 3, 2, 3, 0, 0, 0, 0); - gtk_widget_show (button); - g_signal_connect((button), "clicked", - G_CALLBACK (on_toggle_24_hour_clicked), - dedit); - - gtk_widget_show (app); - - gtk_main (); - - return 0; -} - - -static void -delete_event_cb (GtkWidget *widget, - GdkEventAny *event, - GtkWidget *app) -{ - gtk_widget_destroy (app); - - gtk_main_quit (); -} - - -static void -on_get_date_clicked (GtkWidget *button, - EDateEdit *dedit) -{ - time_t t; - - t = e_date_edit_get_time (dedit); - if (t == -1) - g_print ("Time: None\n"); - else - g_print ("Time: %s", ctime (&t)); - - if (!e_date_edit_date_is_valid (dedit)) - g_print (" Date invalid\n"); - - if (!e_date_edit_time_is_valid (dedit)) - g_print (" Time invalid\n"); -} - - -static void -on_toggle_24_hour_clicked (GtkWidget *button, - EDateEdit *dedit) -{ - e_date_edit_set_use_24_hour_format (dedit, !e_date_edit_get_use_24_hour_format (dedit)); -} - - -#if 0 -static void -on_date_changed (EDateEdit *dedit, - gchar *name) -{ - gint year, month, day; - - if (e_date_edit_date_is_valid (dedit)) { - if (e_date_edit_get_date (dedit, &year, &month, &day)) { - g_print ("Date %s changed to: %i/%i/%i (M/D/Y)\n", - name, month, day, year); - } else { - g_print ("Date %s changed to: None\n", name); - } - } else { - g_print ("Date %s changed to: Not Valid\n", name); - } -} - - -static void -on_time_changed (EDateEdit *dedit, - gchar *name) -{ - gint hour, minute; - - if (e_date_edit_time_is_valid (dedit)) { - if (e_date_edit_get_time_of_day (dedit, &hour, &minute)) { - g_print ("Time %s changed to: %02i:%02i\n", name, - hour, minute); - } else { - g_print ("Time %s changed to: None\n", name); - } - } else { - g_print ("Time %s changed to: Not Valid\n", name); - } -} -#endif - - -static void -on_changed (EDateEdit *dedit, - gchar *name) -{ - gint year, month, day, hour, minute; - - g_print ("Date %s changed ", name); - - if (e_date_edit_date_is_valid (dedit)) { - if (e_date_edit_get_date (dedit, &year, &month, &day)) { - g_print ("M/D/Y: %i/%i/%i", month, day, year); - } else { - g_print ("None"); - } - } else { - g_print ("Date Invalid"); - } - - if (e_date_edit_time_is_valid (dedit)) { - if (e_date_edit_get_time_of_day (dedit, &hour, &minute)) { - g_print (" %02i:%02i\n", hour, minute); - } else { - g_print (" None\n"); - } - } else { - g_print (" Time Invalid\n"); - } -} - - diff --git a/widgets/misc/test-dropdown-button.c b/widgets/misc/test-dropdown-button.c deleted file mode 100644 index 349176d05c..0000000000 --- a/widgets/misc/test-dropdown-button.c +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-dropdown-menu.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - * Damon Chaplin <damon@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <glib.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkwindow.h> -#include <gtk/gtkstock.h> - -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-app-helper.h> -#include <libgnomeui/gnome-ui-init.h> -#include <libgnomeui/gnome-stock-icons.h> - -#include "e-dropdown-button.h" - - -/* (The following is shameless stolen from `testgnome.c'. */ - -static void -item_activated (GtkWidget *widget, - void *data) -{ - printf ("%s activated.\n", (char *) data); -} - -static GnomeUIInfo ui_info[] = { - { GNOME_APP_UI_ITEM, "_New", "Create a new file", item_activated, "file/new", NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW, 'n', GDK_CONTROL_MASK, NULL }, - { GNOME_APP_UI_ITEM, "_Open...", "Open an existing file", item_activated, "file/open", NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN, 'o', GDK_CONTROL_MASK, NULL }, - { GNOME_APP_UI_ITEM, "_Save", "Save the current file", item_activated, "file/save", NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE, 's', GDK_CONTROL_MASK, NULL }, - { GNOME_APP_UI_ITEM, "Save _as...", "Save the current file with a new name", item_activated, "file/save as", NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE_AS, 0, 0, NULL }, - - GNOMEUIINFO_SEPARATOR, - - { GNOME_APP_UI_ITEM, "_Print...", "Print the current file", item_activated, "file/print", NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PRINT, 'p', GDK_CONTROL_MASK, NULL }, - - GNOMEUIINFO_SEPARATOR, - - { GNOME_APP_UI_ITEM, "_Close", "Close the current file", item_activated, "file/close", NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_CLOSE, 0, 0, NULL }, - { GNOME_APP_UI_ITEM, "E_xit", "Exit the program", item_activated, "file/exit", NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT, 'q', GDK_CONTROL_MASK, NULL }, - GNOMEUIINFO_END -}; - - -int -main (int argc, char **argv) -{ - GtkWidget *window; - GtkWidget *menu; - GtkWidget *dropdown_button; - - gnome_init ("test-dropdown-button", "0.0", argc, argv); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), 1, 1); - - menu = gtk_menu_new (); - - gnome_app_fill_menu (GTK_MENU_SHELL (menu), ui_info, NULL, TRUE, 0); - - dropdown_button = e_dropdown_button_new ("Me_nu", GTK_MENU (menu)); - gtk_container_add (GTK_CONTAINER (window), dropdown_button); - - gtk_widget_show (window); - gtk_widget_show (dropdown_button); - - gtk_main (); - - return 0; -} diff --git a/widgets/misc/test-error.c b/widgets/misc/test-error.c deleted file mode 100644 index 38b9bfb6b0..0000000000 --- a/widgets/misc/test-error.c +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - * - * test-error.c - * - * Copyright (C) 2004 Novell, Inc. - * - * Author: Michael Zucchi <notzed@ximian.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-ui-init.h> -#include "e-error.h" - -int -main (int argc, char **argv) -{ - gnome_init ("test-error", "0.0", argc, argv); - - argc--; - switch (argc) { - case 1: - e_error_run(NULL, argv[1], NULL); - break; - case 2: - e_error_run(NULL, argv[1], argv[2], NULL); - break; - case 3: - e_error_run(NULL, argv[1], argv[2], argv[3], NULL); - break; - case 4: - e_error_run(NULL, argv[1], argv[2], argv[3], argv[4], NULL); - break; - case 5: - e_error_run(NULL, argv[1], argv[2], argv[3], argv[4], argv[5], NULL); - break; - case 6: - e_error_run(NULL, argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], NULL); - break; - default: - printf("Error: too many or too few arguments\n"); - printf("Usage:\n %s domain:error-id [ args ... ]\n", argv[0]); - } - - return 0; -} diff --git a/widgets/misc/test-multi-config-dialog.c b/widgets/misc/test-multi-config-dialog.c deleted file mode 100644 index 1a56af9a30..0000000000 --- a/widgets/misc/test-multi-config-dialog.c +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* test-multi-config-dialog.c - * - * Copyright (C) 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - */ - -#include "e-multi-config-dialog.c" - -#include <gnome.h> - - -#define NUM_PAGES 10 - - -static void -add_pages (EMultiConfigDialog *multi_config_dialog) -{ - int i; - - for (i = 0; i < NUM_PAGES; i ++) { - GtkWidget *widget; - GtkWidget *page; - char *string; - char *title; - char *description; - - string = g_strdup_printf ("This is page %d", i); - description = g_strdup_printf ("Description of page %d", i); - title = g_strdup_printf ("Title of page %d", i); - - widget = gtk_label_new (string); - gtk_widget_show (widget); - - page = e_config_page_new (); - gtk_container_add (GTK_CONTAINER (page), widget); - - e_multi_config_dialog_add_page (multi_config_dialog, title, description, NULL, - E_CONFIG_PAGE (page)); - - g_free (string); - g_free (title); - g_free (description); - } -} - -static int -delete_event_callback (GtkWidget *widget, - GdkEventAny *event, - void *data) -{ - gtk_main_quit (); - - return TRUE; -} - - -int -main (int argc, char **argv) -{ - GtkWidget *dialog; - - gnome_init ("test-multi-config-dialog", "0.0", argc, argv); - - dialog = e_multi_config_dialog_new (); - - gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300); - g_signal_connect((dialog), "delete_event", - G_CALLBACK (delete_event_callback), NULL); - - add_pages (E_MULTI_CONFIG_DIALOG (dialog)); - - gtk_widget_show (dialog); - - gtk_main (); - - return 0; -} diff --git a/widgets/misc/test-source-option-menu.c b/widgets/misc/test-source-option-menu.c deleted file mode 100644 index a473c0f972..0000000000 --- a/widgets/misc/test-source-option-menu.c +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* test-source-option-menu.c - Test for ESourceOptionMenu. - * - * Copyright (C) 2003 Novell, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - - -#include "e-source-option-menu.h" - -#include <gtk/gtkwindow.h> -#include <gtk/gtkmain.h> - -#include <libgnomeui/gnome-ui-init.h> - - -static void -source_selected_callback (ESourceOptionMenu *menu, - ESource *source, - void *unused_data) -{ - g_print ("source selected: \"%s\"\n", e_source_peek_name (source)); -} - - -static int -on_idle_create_widget (const char *gconf_path) -{ - GtkWidget *window; - GtkWidget *option_menu; - ESourceList *source_list; - GConfClient *gconf_client; - - gconf_client = gconf_client_get_default (); - source_list = e_source_list_new_for_gconf (gconf_client, gconf_path); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - option_menu = e_source_option_menu_new (source_list); - g_signal_connect (option_menu, "source_selected", G_CALLBACK (source_selected_callback), NULL); - - gtk_container_add (GTK_CONTAINER (window), option_menu); - gtk_widget_show_all (window); - - g_object_unref (gconf_client); - g_object_unref (source_list); - - return FALSE; -} - - -int -main (int argc, char **argv) -{ - GnomeProgram *program; - const char *gconf_path; - - program = gnome_program_init ("test-source-list", "0.0", LIBGNOMEUI_MODULE, argc, argv, NULL); - - if (argc < 2) - gconf_path = "/apps/evolution/calendar/sources"; - else - gconf_path = argv [1]; - - g_idle_add ((GSourceFunc) on_idle_create_widget, (void *) gconf_path); - - gtk_main (); - - return 0; -} diff --git a/widgets/misc/test-source-selector.c b/widgets/misc/test-source-selector.c deleted file mode 100644 index 3120f0c948..0000000000 --- a/widgets/misc/test-source-selector.c +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* test-source-list-selector.c - Test program for the ESourceListSelector - * widget. - * - * Copyright (C) 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-source-selector.h" - -#include <gtk/gtkmain.h> -#include <gtk/gtkcheckbutton.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtkwindow.h> - -#include <libgnomeui/gnome-ui-init.h> - - -static void -dump_selection (ESourceSelector *selector) -{ - GSList *selection = e_source_selector_get_selection (selector); - - g_print ("Current selection:\n"); - if (selection == NULL) { - g_print ("\t(None)\n"); - } else { - GSList *p; - - for (p = selection; p != NULL; p = p->next) { - ESource *source = E_SOURCE (p->data); - - g_print ("\tSource %s (group %s)\n", - e_source_peek_name (source), - e_source_group_peek_name (e_source_peek_group (source))); - } - } - - e_source_selector_free_selection (selection); -} - -static void -selection_changed_callback (ESourceSelector *selector, - void *unused_data) -{ - g_print ("Selection changed!\n"); - dump_selection (selector); -} - -static void -check_toggled_callback (GtkToggleButton *button, - ESourceSelector *selector) -{ - e_source_selector_show_selection (selector, gtk_toggle_button_get_active (button)); -} - -static int -on_idle_create_widget (void *unused_data) -{ - GtkWidget *window; - GtkWidget *vbox; - GtkWidget *selector; - GtkWidget *scrolled_window; - GtkWidget *check; - ESourceList *list; - GConfClient *gconf_client; - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), 200, 300); - - vbox = gtk_vbox_new (FALSE, 3); - gtk_container_add (GTK_CONTAINER (window), vbox); - - gconf_client = gconf_client_get_default (); - list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/test/source_list"); - selector = e_source_selector_new (list); - g_signal_connect (selector, "selection_changed", G_CALLBACK (selection_changed_callback), NULL); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (scrolled_window), selector); - gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 3); - - check = gtk_check_button_new_with_label ("Show checkboxes"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), - e_source_selector_selection_shown (E_SOURCE_SELECTOR (selector))); - g_signal_connect (check, "toggled", G_CALLBACK (check_toggled_callback), selector); - gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 3); - - gtk_widget_show_all (window); - - g_object_unref (gconf_client); - return FALSE; -} - - -int -main (int argc, char **argv) -{ - GnomeProgram *program; - - program = gnome_program_init ("test-source-list", "0.0", - LIBGNOMEUI_MODULE, argc, argv, - NULL); - - g_idle_add (on_idle_create_widget, NULL); - gtk_main (); - - return 0; -} diff --git a/widgets/misc/test-title-bar.c b/widgets/misc/test-title-bar.c deleted file mode 100644 index 80944f5b01..0000000000 --- a/widgets/misc/test-title-bar.c +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-title-bar.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkbox.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtklabel.h> - -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-ui-init.h> -#include "e-title-bar.h" - -static void -delete_event_cb (GtkWidget *widget, - GdkEventAny *event, - gpointer data) -{ - gtk_main_quit (); -} - -int -main (int argc, char **argv) -{ - GtkWidget *app; - GtkWidget *title_bar; - GtkWidget *label; - GtkWidget *vbox; - - gnome_init ("test-title-bar", "0.0", argc, argv); - - app = gnome_app_new ("Test", "Test"); - gtk_window_set_default_size (GTK_WINDOW (app), 400, 400); - gtk_window_set_policy (GTK_WINDOW (app), FALSE, TRUE, FALSE); - - g_signal_connect((app), "delete_event", G_CALLBACK (delete_event_cb), NULL); - - title_bar = e_title_bar_new ("This is a very annoyingly long title bar"); - gtk_widget_show (title_bar); - - label = gtk_label_new ("boo"); - gtk_widget_show (label); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), title_bar, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0); - gtk_widget_show (vbox); - - gnome_app_set_contents (GNOME_APP (app), vbox); - gtk_widget_show (app); - - gtk_main (); - - return 0; -} diff --git a/widgets/table/e-table-example-1.c b/widgets/table/e-table-example-1.c deleted file mode 100644 index 37ac85770f..0000000000 --- a/widgets/table/e-table-example-1.c +++ /dev/null @@ -1,308 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-table-example-1.c - * Copyright 2000, 2001, Ximian, Inc. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License, version 2, as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -/* This code is GPL. */ -#include <stdio.h> -#include <string.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include "gal/e-util/e-cursors.h" -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cell-text.h" -#include "e-cell-checkbox.h" -#include "e-table.h" - -#include "table-test.h" - -/* - * One way in which we make it simpler to build an ETableModel is through - * the ETableSimple class. Instead of creating your own ETableModel - * class, you simply create a new object of the ETableSimple class. You - * give it a bunch of functions that act as callbacks. - * - * You also get to pass a void * to ETableSimple and it gets passed to - * your callbacks. This would be for having multiple models of the same - * type. This is just an example though, so we statically define all the - * data and ignore the void *data parameter. - * - * In our example we will be creating a table model with 6 columns and 10 - * rows. This corresponds to having 6 different types of information and - * 10 different sets of data in our database. - * - * The headers will be hard coded, as will be the example data. - * - */ - -/* - * There are two different meanings to the word "column". The first is - * the model column. A model column corresponds to a specific type of - * data. This is very much like the usage in a database table where a - * column is a field in the database. - * - * The second type of column is a view column. A view column - * corresponds to a visually displayed column. Each view column - * corresponds to a specific model column, though a model column may - * have any number of view columns associated with it, from zero to - * greater than one. - * - * Also, a view column doesn't necessarily depend on only one model - * column. In some cases, the view column renderer can be given a - * reference to another column to get extra information about its - * display. -*/ - -#define ROWS 10 -#define COLS 4 - -#define IMPORTANCE_COLUMN 4 -#define COLOR_COLUMN 5 - -/* - * Here we define the initial layout of the table. This is an xml - * format that allows you to change the initial ordering of the - * columns or to do sorting or grouping initially. This specification - * shows all 5 columns, but moves the importance column nearer to the - * front. It also sorts by the "Full Name" column (ascending.) - * Sorting and grouping take the model column as their arguments - * (sorting is specified by the "column" argument to the leaf elemnt. - */ - -#define INITIAL_SPEC "<ETableSpecification> \ - <columns-shown> \ - <column> 0 </column> \ - <column> 4 </column> \ - <column> 1 </column> \ - <column> 2 </column> \ - <column> 3 </column> \ - </columns-shown> \ - <grouping> <leaf column=\"1\" ascending=\"true\"/> </grouping> \ -</ETableSpecification>" - -char *headers [COLS] = { - "Email", - "Full Name", - "Address", - "Phone" -}; - -/* - * Virtual Column list: - * 0 Email - * 1 Full Name - * 2 Address - * 3 Phone - */ - -char *table_data [ROWS] [COLS]; - -/* - * ETableSimple callbacks - * These are the callbacks that define the behavior of our custom model. - */ - -/* - * Since our model is a constant size, we can just return its size in - * the column and row count fields. - */ - -/* This function returns the number of columns in our ETableModel. */ -static int -my_col_count (ETableModel *etc, void *data) -{ - return COLS; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -my_row_count (ETableModel *etc, void *data) -{ - return ROWS; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -my_value_at (ETableModel *etc, int col, int row, void *data) -{ - return (void *) table_data [row] [col]; -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -my_set_value_at (ETableModel *etc, int col, int row, const void *val, void *data) -{ - g_free (table_data [row] [col]); - table_data [row] [col] = g_strdup (val); -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -my_is_cell_editable (ETableModel *etc, int col, int row, void *data) -{ - return TRUE; -} - -/* This function duplicates the value passed to it. */ -static void * -my_duplicate_value (ETableModel *etc, int col, const void *value, void *data) -{ - return g_strdup (value); -} - -/* This function frees the value passed to it. */ -static void -my_free_value (ETableModel *etc, int col, void *value, void *data) -{ - g_free (value); -} - -/* This function creates an empty value. */ -static void * -my_initialize_value (ETableModel *etc, int col, void *data) -{ - return g_strdup (""); -} - -/* This function reports if a value is empty. */ -static gboolean -my_value_is_empty (ETableModel *etc, int col, const void *value, void *data) -{ - return !(value && *(char *)value); -} - -/* This function reports if a value is empty. */ -static char * -my_value_to_string (ETableModel *etc, int col, const void *value, void *data) -{ - return g_strdup(value); -} - -/* We create a window containing our new table. */ -static void -create_table (void) -{ - GtkWidget *e_table, *window, *frame; - ECell *cell_left_just; - ETableHeader *e_table_header; - int i, j; - ETableModel *e_table_model = NULL; - - /* First we fill in the simple data. */ - for (i = 0; i < ROWS; i++){ - for (j = 0; j < COLS; j++) - table_data [i] [j] = g_strdup (""); - } - /* Next we create our model. This uses the functions we defined - earlier. */ - e_table_model = e_table_simple_new ( - my_col_count, my_row_count, my_value_at, - my_set_value_at, my_is_cell_editable, - my_duplicate_value, my_free_value, - my_initialize_value, my_value_is_empty, - my_value_to_string, - NULL); - /* - * Next we create a header. The ETableHeader is used in two - * different way. The first is the full_header. This is the - * list of possible columns in the view. The second use is - * completely internal. Many of the ETableHeader functions are - * for that purpose. The only functions we really need are - * e_table_header_new and e_table_header_add_col. - * - * First we create the header. - */ - e_table_header = e_table_header_new (); - - /* - * Next we have to build renderers for all of the columns. - * Since all our columns are text columns, we can simply use - * the same renderer over and over again. If we had different - * types of columns, we could use a different renderer for - * each column. - */ - cell_left_just = e_cell_text_new (e_table_model, NULL, GTK_JUSTIFY_LEFT); - - /* - * Next we create a column object for each view column and add - * them to the header. We don't create a column object for - * the importance column since it will not be shown. - */ - for (i = 0; i < COLS; i++) { - /* Create the column. */ - ETableCol *ecol = e_table_col_new ( - i, headers [i], - 1.0, 20, cell_left_just, - g_str_compare, TRUE); - /* Add it to the header. */ - e_table_header_add_column (e_table_header, ecol, i); - } - - /* - * Here we create a window for our new table. This window - * will get shown and the person will be able to test their - * item. - */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - /* This frame is simply to get a bevel around our table. */ - frame = gtk_frame_new (NULL); - - /* - * Here we create the table. We give it the three pieces of - * the table we've created, the header, the model, and the - * initial layout. It does the rest. - */ - e_table = e_table_new (e_table_header, e_table_model, INITIAL_SPEC); - - /* Build the gtk widget hierarchy. */ - gtk_container_add (GTK_CONTAINER (frame), e_table); - gtk_container_add (GTK_CONTAINER (window), frame); - - /* Size the initial window. */ - gtk_widget_set_usize (window, 200, 200); - - /* Show it all. */ - gtk_widget_show_all (window); -} - -/* This is the main function which just initializes gnome and call our create_table function */ - -int -main (int argc, char *argv []) -{ - gnome_init ("TableExample", "TableExample", argc, argv); - e_cursors_init (); - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - create_table (); - - gtk_main (); - - e_cursors_shutdown (); - return 0; -} - |