diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2003-11-24 18:13:24 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2003-11-24 18:13:24 +0800 |
commit | f8bb752e44d08b9975931fa7edb6d49da95df96f (patch) | |
tree | d6f9b7c12bc5eb492cccc8b17d6ff4361517a93d | |
parent | 1496e35c9cd57e31eb58a1fa6792d60b842bf941 (diff) | |
download | gsoc2013-evolution-f8bb752e44d08b9975931fa7edb6d49da95df96f.tar.gz gsoc2013-evolution-f8bb752e44d08b9975931fa7edb6d49da95df96f.tar.zst gsoc2013-evolution-f8bb752e44d08b9975931fa7edb6d49da95df96f.zip |
new files containing the implementation of the 'New Task List' dialog.
2003-11-24 Rodrigo Moya <rodrigo@ximian.com>
* gui/dialogs/new-task-list.glade:
* gui/dialogs/new-task-list.[ch]: new files containing the
implementation of the 'New Task List' dialog.
* gui/dialogs/Makefile.am: added new files.
* gui/dialogs/new-calendar.c (new_calendar_dialog): use G_STRLOC
for g_warning messages.
* gui/tasks-component.c (new_task_list_cb): implemented.
svn path=/trunk/; revision=23478
-rw-r--r-- | calendar/ChangeLog | 13 | ||||
-rw-r--r-- | calendar/gui/dialogs/Makefile.am | 3 | ||||
-rw-r--r-- | calendar/gui/dialogs/new-calendar.c | 4 | ||||
-rw-r--r-- | calendar/gui/dialogs/new-task-list.c | 145 | ||||
-rw-r--r-- | calendar/gui/dialogs/new-task-list.glade | 193 | ||||
-rw-r--r-- | calendar/gui/dialogs/new-task-list.h | 28 | ||||
-rw-r--r-- | calendar/gui/tasks-component.c | 2 |
7 files changed, 385 insertions, 3 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index a580641a17..b0de5f4a00 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,18 @@ 2003-11-24 Rodrigo Moya <rodrigo@ximian.com> + * gui/dialogs/new-task-list.glade: + * gui/dialogs/new-task-list.[ch]: new files containing the + implementation of the 'New Task List' dialog. + + * gui/dialogs/Makefile.am: added new files. + + * gui/dialogs/new-calendar.c (new_calendar_dialog): use G_STRLOC + for g_warning messages. + + * gui/tasks-component.c (new_task_list_cb): implemented. + +2003-11-24 Rodrigo Moya <rodrigo@ximian.com> + * gui/dialogs/copy-source-dialog.c (copy_source_dialog): actually add the source selector to the dialog's box. diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index bd81bb4229..7e3b76fd97 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -63,6 +63,8 @@ libcal_dialogs_la_SOURCES = \ meeting-page.h \ new-calendar.c \ new-calendar.h \ + new-task-list.c \ + new-task-list.h \ recurrence-page.c \ recurrence-page.h \ recur-comp.c \ @@ -88,6 +90,7 @@ glade_DATA = \ event-page.glade \ meeting-page.glade \ new-calendar.glade \ + new-task-list.glade \ recurrence-page.glade \ schedule-page.glade \ task-details-page.glade \ diff --git a/calendar/gui/dialogs/new-calendar.c b/calendar/gui/dialogs/new-calendar.c index 4010339a2a..5cbbd99516 100644 --- a/calendar/gui/dialogs/new-calendar.c +++ b/calendar/gui/dialogs/new-calendar.c @@ -201,7 +201,7 @@ new_calendar_dialog (GtkWindow *parent) /* load the Glade file */ xml = glade_xml_new (EVOLUTION_GLADEDIR "/new-calendar.glade", "new-calendar-dialog", NULL); if (!xml) { - g_warning ("new_calendar_dialog(): cannot load Glade file"); + g_warning (G_STRLOC ": cannot load Glade file"); return FALSE; } @@ -262,8 +262,6 @@ new_calendar_dialog (GtkWindow *parent) g_object_unref (gconf_client); g_object_unref (source_list); gtk_widget_destroy (dialog); - - /* free memory */ g_object_unref (xml); return result; diff --git a/calendar/gui/dialogs/new-task-list.c b/calendar/gui/dialogs/new-task-list.c new file mode 100644 index 0000000000..e77d35d4ad --- /dev/null +++ b/calendar/gui/dialogs/new-task-list.c @@ -0,0 +1,145 @@ +/* Evolution calendar - New task list dialog + * + * Copyright (C) 2003 Novell, Inc. + * + * Author: Rodrigo Moya <rodrigo@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 <bonobo/bonobo-i18n.h> +#include <gtk/gtkentry.h> +#include <gtk/gtkmenu.h> +#include <gtk/gtkmenuitem.h> +#include <gtk/gtkmessagedialog.h> +#include <gtk/gtkoptionmenu.h> +#include <glade/glade.h> +#include <e-util/e-dialog-utils.h> +#include <libedataserver/e-source-list.h> +#include "new-task-list.h" + +static gboolean +create_new_source_with_group (GtkWindow *parent, + ESourceGroup *group, + const char *source_name) +{ + ESource *source; + char *new_dir; + + if (e_source_group_peek_source_by_name (group, source_name)) { + e_notice (parent, GTK_MESSAGE_ERROR, + _("Source with name '%s' already exists in the selected group"), + source_name); + return FALSE; + } + + new_dir = g_build_filename (e_source_group_peek_base_uri (group), + source_name, NULL); + if (e_mkdir_hier (new_dir, 0700)) { + g_free (new_dir); + e_notice (parent, GTK_MESSAGE_ERROR, + _("Could not create directory for new task list")); + return FALSE; + } + + source = e_source_new (source_name, source_name); + g_free (new_dir); + + e_source_group_add_source (group, source, -1); + return TRUE; +} + +/** + * new_task_list_dialog + * + * Displays a dialog that allows the user to create a new task list. + */ +gboolean +new_task_list_dialog (GtkWindow *parent) +{ + GtkWidget *dialog, *task_group, *task_name; + GladeXML *xml; + ESourceList *source_list; + GConfClient *gconf_client; + GSList *groups, *sl; + gboolean result = FALSE, retry = TRUE; + + /* load the Glade file */ + xml = glade_xml_new (EVOLUTION_GLADEDIR "/new-task-list.glade", "new-task-list-dialog", NULL); + if (!xml) { + g_warning (G_STRLOC ": cannot load Glade file"); + return FALSE; + } + + dialog = glade_xml_get_widget (xml, "new-task-list-dialog"); + task_group = glade_xml_get_widget (xml, "task-list-group"); + task_name = glade_xml_get_widget (xml, "task-list-name"); + + /* set up widgets */ + gconf_client = gconf_client_get_default (); + source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/tasks/sources"); + + groups = e_source_list_peek_groups (source_list); + for (sl = groups; sl != NULL; sl = sl->next) { + GtkWidget *menu_item, *menu; + ESourceGroup *group = sl->data; + + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (task_group)); + if (!GTK_IS_MENU (menu)) { + menu = gtk_menu_new (); + gtk_option_menu_set_menu (GTK_OPTION_MENU (task_group), menu); + gtk_widget_show (menu); + } + + menu_item = gtk_menu_item_new_with_label (e_source_group_peek_name (group)); + gtk_widget_show (menu_item); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + } + + if (groups) + gtk_option_menu_set_history (GTK_OPTION_MENU (task_group), 0); + + /* run the dialog */ + do { + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { + const char *name; + + name = gtk_entry_get_text (GTK_ENTRY (task_name)); + sl = g_slist_nth (groups, gtk_option_menu_get_history (GTK_OPTION_MENU (task_group))); + if (sl) { + if (create_new_source_with_group (GTK_WINDOW (dialog), + sl->data, + name)) + retry = FALSE; + } else { + e_notice (dialog, GTK_MESSAGE_ERROR, + _("A group must be selected")); + continue; + } + } else + retry = FALSE; /* user pressed Cancel */ + } while (retry); + + /* free memory */ + g_object_unref (gconf_client); + g_object_unref (source_list); + gtk_widget_destroy (dialog); + g_object_unref (xml); + + return result; +} diff --git a/calendar/gui/dialogs/new-task-list.glade b/calendar/gui/dialogs/new-task-list.glade new file mode 100644 index 0000000000..ffc38582c8 --- /dev/null +++ b/calendar/gui/dialogs/new-task-list.glade @@ -0,0 +1,193 @@ +<?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="new-task-list-dialog"> + <property name="border_width">12</property> + <property name="visible">True</property> + <property name="title" translatable="yes">Add New Task List</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_CENTER</property> + <property name="modal">False</property> + <property name="resizable">False</property> + <property name="destroy_with_parent">False</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</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="cancelbutton1"> + <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="response_id">-6</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="okbutton1"> + <property name="visible">True</property> + <property name="can_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="response_id">-5</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="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="n_rows">3</property> + <property name="n_columns">3</property> + <property name="homogeneous">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">Task List Group</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="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_padding">6</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkOptionMenu" id="task-list-group"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="history">-1</property> + </widget> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_padding">6</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="task-list-name"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</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> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_padding">6</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Task List Options</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="left_attach">0</property> + <property name="right_attach">3</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_padding">6</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">Task List Name</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="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_padding">6</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + <packing> + <property name="padding">4</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/calendar/gui/dialogs/new-task-list.h b/calendar/gui/dialogs/new-task-list.h new file mode 100644 index 0000000000..3f529f39ad --- /dev/null +++ b/calendar/gui/dialogs/new-task-list.h @@ -0,0 +1,28 @@ +/* Evolution calendar - New task list dialog + * + * Copyright (C) 2003 Novell, Inc. + * + * Author: Rodrigo Moya <rodrigo@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 NEW_TASK_LIST_H +#define NEW_TASK_LIST_H + +#include <gtk/gtkwindow.h> + +gboolean new_task_list_dialog (GtkWindow *parent); + +#endif diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c index 5946bd2cfe..0045c66848 100644 --- a/calendar/gui/tasks-component.c +++ b/calendar/gui/tasks-component.c @@ -41,6 +41,7 @@ #include "calendar-config.h" #include "dialogs/comp-editor.h" #include "dialogs/copy-source-dialog.h" +#include "dialogs/new-task-list.h" #include "dialogs/task-editor.h" #include "widgets/misc/e-source-selector.h" @@ -351,6 +352,7 @@ delete_task_list_cb (GtkWidget *widget, TasksComponent *comp) static void new_task_list_cb (GtkWidget *widget, TasksComponent *component) { + new_task_list_dialog (GTK_WINDOW (gtk_widget_get_toplevel (widget))); } static void |