aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-week-view-titles-item.c
blob: 733bec9a819746d5e49567efd820c3adb5a19de2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129</* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-shortcuts.h
 *
 * Copyright (C) 2000, 2001 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
 */

#ifndef _E_SHORTCUTS_H_
#define _E_SHORTCUTS_H_

#include <gtk/gtkwidget.h>

#include "e-folder-type-registry.h"
#include "e-storage-set.h"

#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */

#define E_TYPE_SHORTCUTS            (e_shortcuts_get_type ())
#define E_SHORTCUTS(obj)            (GTK_CHECK_CAST ((obj), E_TYPE_SHORTCUTS, EShortcuts))
#define E_SHORTCUTS_CLASS(klass)        (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHORTCUTS, EShortcutsClass))
#define E_IS_SHORTCUTS(obj)         (GTK_CHECK_TYPE ((obj), E_TYPE_SHORTCUTS))
#define E_IS_SHORTCUTS_CLASS(klass)     (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHORTCUTS))


typedef struct _EShortcuts        EShortcuts;
typedef struct _EShortcutsPrivate EShortcutsPrivate;
typedef struct _EShortcutsClass   EShortcutsClass;

struct _EShortcutItem {
    char *uri;
    char *name;
    char *type;
    int unread_count;
};
typedef struct _EShortcutItem EShortcutItem;

struct _EShortcuts {
    GtkObject parent;

    EShortcutsPrivate *priv;
};

struct _EShortcutsClass {
    GtkObjectClass parent_class;

    /* Signals.  */

    void  (* new_group)        (EShortcuts *shortcuts, int group_num);
    void  (* remove_group)     (EShortcuts *shortcuts, int group_num);
    void  (* rename_group)     (EShortcuts *shortcuts, int group_num, const char *new_title);

    void  (* new_shortcut)     (EShortcuts *shortcuts, int group_num, int item_num);
    void  (* remove_shortcut)  (EShortcuts *shortcuts, int group_num, int item_num);
    void  (* update_shortcut)  (EShortcuts *shortcuts, int group_num, int item_num);
};



GtkType      e_shortcuts_get_type                (void);
void         e_shortcuts_construct               (EShortcuts          *shortcuts,
                          EStorageSet         *storage_set,
                          EFolderTypeRegistry *folder_type_registry);
EShortcuts  *e_shortcuts_new                     (EStorageSet         *storage_set,
                          EFolderTypeRegistry *folder_type_registry,
                          const char          *file_name);

int           e_shortcuts_get_num_groups          (EShortcuts *shortcuts);

GSList       *e_shortcuts_get_group_titles        (EShortcuts *shortcuts);
const char   *e_shortcuts_get_group_title         (EShortcuts *shortcuts,
                           int         group_num);
const GSList *e_shortcuts_get_shortcuts_in_group  (EShortcuts *shortcuts,
                           int         group_num);

const EShortcutItem *e_shortcuts_get_shortcut  (EShortcuts *shortcuts,
                        int         group_num,
                        int         num);

EStorageSet  *e_shortcuts_get_storage_set          (EShortcuts *shortcuts);
GtkWidget    *e_shortcuts_new_view                 (EShortcuts *shortcuts);

gboolean     e_shortcuts_load                    (EShortcuts          *shortcuts,
                          const char          *path);
gboolean     e_shortcuts_save                    (EShortcuts          *shortcuts,
                          const char          *path);

void  e_shortcuts_add_default_group  (EShortcuts *shortcuts);

void  e_shortcuts_remove_shortcut    (EShortcuts *shortcuts,
                      int         group_num,
                      int         num);
void  e_shortcuts_add_shortcut       (EShortcuts *shortcuts,
                      int         group_num,
                      int         num,
                      const char *uri,
                      const char *name,
                      int unread_count,
                      const char *type);
void  e_shortcuts_update_shortcut    (EShortcuts *shortcuts,
                      int         group_num,
                      int         num,
                      const char *uri,
                      const char *name,
                      int unread_count,
                      const char *type);

void  e_shortcuts_remove_group  (EShortcuts *shortcuts,
                 int         group_num);
void  e_shortcuts_add_group     (EShortcuts *shortcuts,
                 int         group_num,
                 const char *group_title);
void  e_shortcuts_rename_group  (EShortcuts *shortcuts,
                 int         group_name,
                 const char *new_title);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _E_SHORTCUTS_H_ */
a52a35">break; } } static void e_week_view_titles_item_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags) { if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags); /* The item covers the entire canvas area. */ item->x1 = 0; item->y1 = 0; item->x2 = INT_MAX; item->y2 = INT_MAX; } /* * DRAWING ROUTINES - functions to paint the canvas item. */ static void e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable, int x, int y, int width, int height) { EWeekViewTitlesItem *wvtitem; EWeekView *week_view; GtkStyle *style; GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc; gint canvas_width, canvas_height, col_width, col, date_width, date_x; gchar buffer[128], *date_format; GDate date; GdkRectangle clip_rect; gboolean long_format; gint weekday; PangoLayout *layout; #if 0 g_print ("In e_week_view_titles_item_draw %i,%i %ix%i\n", x, y, width, height); #endif wvtitem = E_WEEK_VIEW_TITLES_ITEM (canvas_item); week_view = wvtitem->week_view; g_return_if_fail (week_view != NULL); style = gtk_widget_get_style (GTK_WIDGET (week_view)); fg_gc = style->fg_gc[GTK_STATE_NORMAL]; bg_gc = style->bg_gc[GTK_STATE_NORMAL]; light_gc = style->light_gc[GTK_STATE_NORMAL]; dark_gc = style->dark_gc[GTK_STATE_NORMAL]; canvas_width = GTK_WIDGET (canvas_item->canvas)->allocation.width; canvas_height = GTK_WIDGET (canvas_item->canvas)->allocation.height; layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), NULL); /* Draw the shadow around the dates. */ gdk_draw_line (drawable, light_gc, 1 - x, 1 - y, canvas_width - 2 - x, 1 - y); gdk_draw_line (drawable, light_gc, 1 - x, 2 - y, 1 - x, canvas_height - 1 - y); gdk_draw_rectangle (drawable, dark_gc, FALSE, 0 - x, 0 - y, canvas_width - 1, canvas_height); /* Determine the format to use. */ col_width = canvas_width / week_view->columns; if (col_width > week_view->max_day_width + 2) { date_format = "%A"; long_format = TRUE; } else { date_format = "%a"; long_format = FALSE; } /* Shift right one pixel to account for the shadow around the main canvas. */ x--; /* Draw the date. Set a clipping rectangle so we don't draw over the next day. */ g_date_clear (&date, 1); /* Note that 20th March 2000 is a Monday. We only care about the weekday. */ weekday = week_view->display_start_day; g_date_set_dmy (&date, 20 + weekday, 3, 2000); for (col = 0; col < week_view->columns; col++) { if (weekday == 5 && week_view->compress_weekend) { g_date_strftime (buffer, 128, "%a/", &date); g_date_add_days (&date, 1); g_date_strftime (buffer + strlen (buffer), 100, "%a", &date); } else { g_date_strftime (buffer, 128, date_format, &date); } clip_rect.x = week_view->col_offsets[col] - x; clip_rect.y = 2 - y; clip_rect.width = week_view->col_widths[col]; clip_rect.height = canvas_height - 2; gdk_gc_set_clip_rectangle (fg_gc, &clip_rect); if (weekday == 5 && week_view->compress_weekend) date_width = week_view->abbr_day_widths[5] + week_view->slash_width + week_view->abbr_day_widths[6]; else if (long_format) date_width = week_view->day_widths[weekday]; else date_width = week_view->abbr_day_widths[weekday]; date_x = week_view->col_offsets[col] + (week_view->col_widths[col] - date_width) / 2; date_x = MAX (date_x, week_view->col_offsets[col]); pango_layout_set_text (layout, buffer, -1); gdk_draw_layout (drawable, fg_gc, date_x - x, 3 - y, layout); gdk_gc_set_clip_rectangle (fg_gc, NULL); /* Draw the lines down the left and right of the date cols. */ if (col != 0) { gdk_draw_line (drawable, light_gc, week_view->col_offsets[col] - x, 4 - y, week_view->col_offsets[col] - x, canvas_height - 4 - y); gdk_draw_line (drawable, dark_gc, week_view->col_offsets[col] - 1 - x, 4 - y, week_view->col_offsets[col] - 1 - x, canvas_height - 4 - y); } /* Draw the lines between each column. */ if (col != 0) { gdk_draw_line (drawable, style->black_gc, week_view->col_offsets[col] - x, canvas_height - y, week_view->col_offsets[col] - x, canvas_height - y); } if (weekday == 5 && week_view->compress_weekend) weekday += 2; else weekday++; weekday = weekday % 7; g_date_add_days (&date, 1); } g_object_unref (layout); } /* 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_week_view_titles_item_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item) { *actual_item = item; return 0.0; }