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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/*
* Authors: Rodney Dawes <dobey@gnome.org>
*
* Copyright 2008-2009 Rodney Dawes
*
* 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.
*/
#include <glib/gi18n.h>
#include <gtk/gtkaboutdialog.h>
#include <gtk/gtkcheckbutton.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkicontheme.h>
#include <gtk/gtkimagemenuitem.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenubar.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtkscrolledwindow.h>
#include <gtk/gtkstatusbar.h>
#include <gtk/gtkstock.h>
#include <gtk/gtktable.h>
#include <gtk/gtkvbox.h>
#include "main.h"
#include "sw-taskview.h"
struct _StopwatchWindowPrivate {
GtkIconTheme * theme;
GtkWidget * notebook;
};
enum {
LAST_SIGNAL
};
G_DEFINE_TYPE (StopwatchWindow, stopwatch_window, GTK_TYPE_WINDOW)
static void stopwatch_window_about_response (GtkDialog * dialog,
gint response_id,
StopwatchWindow * window) {
gtk_widget_hide (GTK_WIDGET (dialog));
}
static void stopwatch_window_about_callback (GtkMenuItem * menuitem,
StopwatchWindow * window) {
StopwatchWindowPrivate * priv = window->priv;
static GtkWidget * about;
if (about != NULL) {
gtk_window_present (GTK_WINDOW (about));
return;
}
about = gtk_about_dialog_new ();
gtk_window_set_resizable (GTK_WINDOW (about), TRUE);
gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (about), _("Stopwatch"));
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about), VERSION);
gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (about),
"Copyright 2008-2009 Rodney Dawes");
gtk_about_dialog_set_logo_icon_name (GTK_ABOUT_DIALOG (about), "stopwatch");
g_signal_connect (G_OBJECT (about), "response",
G_CALLBACK (stopwatch_window_about_response), window);
gtk_widget_show (about);
}
static gboolean stopwatch_window_delete_event (GtkWidget * widget,
GdkEventAny * event) {
stopwatch_main_quit (widget, STOPWATCH_WINDOW (widget));
return TRUE;
}
static void stopwatch_window_main_quit (GtkMenuItem * menuitem,
StopwatchWindow * window) {
StopwatchWindowPrivate * priv;
priv = window->priv;
stopwatch_main_quit (GTK_WIDGET (menuitem), window);
}
static void stopwatch_window_class_init (StopwatchWindowClass * klass) {
stopwatch_window_parent_class = g_type_class_peek (GTK_TYPE_WINDOW);
GTK_WIDGET_CLASS (klass)->delete_event = stopwatch_window_delete_event;
}
static void stopwatch_window_init (StopwatchWindow * window) {
StopwatchWindowPrivate * priv;
GtkWidget * vbox;
GtkWidget * menubar;
GtkWidget * scroll;
GtkWidget * mainitem;
GtkWidget * menu;
GtkWidget * menuitem;
priv = g_new0 (StopwatchWindowPrivate, 1);
window->priv = priv;
/* Get our icon theme */
priv->theme = gtk_icon_theme_get_default ();
gtk_window_set_title (GTK_WINDOW (window), _("Stopwatch"));
gtk_window_set_default_size (GTK_WINDOW (window), 200, 442);
gtk_window_set_default_icon_name ("stopwatch");
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (vbox);
/* Create the menu bar */
menubar = gtk_menu_bar_new ();
gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
gtk_widget_show (menubar);
/* Create the menus */
/* Timer menu */
mainitem = gtk_menu_item_new_with_mnemonic (_("_Tasks"));
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), mainitem);
gtk_widget_show (mainitem);
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mainitem), menu);
gtk_widget_show (menu);
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (G_OBJECT (menuitem), "activate",
G_CALLBACK (stopwatch_window_main_quit), window);
gtk_widget_show (menuitem);
/* Help menu */
mainitem = gtk_menu_item_new_with_mnemonic (_("_Help"));
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), mainitem);
gtk_widget_show (mainitem);
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mainitem), menu);
gtk_widget_show (menu);
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
g_signal_connect (G_OBJECT (menuitem), "activate",
G_CALLBACK (stopwatch_window_about_callback), window);
gtk_widget_show (menuitem);
/* Create the main view area */
priv->notebook = gtk_notebook_new ();
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0);
gtk_widget_show (priv->notebook);
/* Add the TaskView page */
scroll = sw_taskview_new ();
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
scroll, NULL);
gtk_widget_show (scroll);
}
GtkWidget * stopwatch_window_new (void) {
return g_object_new (STOPWATCH_TYPE_WINDOW, NULL);
}
|