2
* Authors: Rodney Dawes <dobey@gnome.org>
4
* Copyright 2008-2009 Rodney Dawes
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of version 2 of the GNU General Public License
8
* as published by the Free Software Foundation
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
#include <glib/gi18n.h>
16
#include <gtk/gtkaboutdialog.h>
17
#include <gtk/gtkcheckbutton.h>
18
#include <gtk/gtkentry.h>
19
#include <gtk/gtkhbox.h>
20
#include <gtk/gtkicontheme.h>
21
#include <gtk/gtkimagemenuitem.h>
22
#include <gtk/gtklabel.h>
23
#include <gtk/gtkmenu.h>
24
#include <gtk/gtkmenubar.h>
25
#include <gtk/gtkmenuitem.h>
26
#include <gtk/gtknotebook.h>
27
#include <gtk/gtkscrolledwindow.h>
28
#include <gtk/gtkstatusbar.h>
29
#include <gtk/gtkstock.h>
30
#include <gtk/gtktable.h>
31
#include <gtk/gtkvbox.h>
34
#include "sw-taskview.h"
36
struct _StopwatchWindowPrivate {
46
G_DEFINE_TYPE (StopwatchWindow, stopwatch_window, GTK_TYPE_WINDOW)
48
static void stopwatch_window_about_response (GtkDialog * dialog,
50
StopwatchWindow * window) {
51
gtk_widget_hide (GTK_WIDGET (dialog));
54
static void stopwatch_window_about_callback (GtkMenuItem * menuitem,
55
StopwatchWindow * window) {
56
StopwatchWindowPrivate * priv = window->priv;
57
static GtkWidget * about;
60
gtk_window_present (GTK_WINDOW (about));
64
about = gtk_about_dialog_new ();
65
gtk_window_set_resizable (GTK_WINDOW (about), TRUE);
66
gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (about), _("Stopwatch"));
67
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about), VERSION);
68
gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (about),
69
"Copyright 2008-2009 Rodney Dawes");
70
gtk_about_dialog_set_logo_icon_name (GTK_ABOUT_DIALOG (about), "stopwatch");
71
g_signal_connect (G_OBJECT (about), "response",
72
G_CALLBACK (stopwatch_window_about_response), window);
74
gtk_widget_show (about);
77
static gboolean stopwatch_window_delete_event (GtkWidget * widget,
78
GdkEventAny * event) {
79
stopwatch_main_quit (widget, STOPWATCH_WINDOW (widget));
84
static void stopwatch_window_main_quit (GtkMenuItem * menuitem,
85
StopwatchWindow * window) {
86
StopwatchWindowPrivate * priv;
90
stopwatch_main_quit (GTK_WIDGET (menuitem), window);
93
static void stopwatch_window_class_init (StopwatchWindowClass * klass) {
94
stopwatch_window_parent_class = g_type_class_peek (GTK_TYPE_WINDOW);
96
GTK_WIDGET_CLASS (klass)->delete_event = stopwatch_window_delete_event;
99
static void stopwatch_window_init (StopwatchWindow * window) {
100
StopwatchWindowPrivate * priv;
104
GtkWidget * mainitem;
106
GtkWidget * menuitem;
108
priv = g_new0 (StopwatchWindowPrivate, 1);
111
/* Get our icon theme */
112
priv->theme = gtk_icon_theme_get_default ();
114
gtk_window_set_title (GTK_WINDOW (window), _("Stopwatch"));
115
gtk_window_set_default_size (GTK_WINDOW (window), 200, 442);
116
gtk_window_set_default_icon_name ("stopwatch");
118
vbox = gtk_vbox_new (FALSE, 0);
119
gtk_container_add (GTK_CONTAINER (window), vbox);
120
gtk_widget_show (vbox);
122
/* Create the menu bar */
123
menubar = gtk_menu_bar_new ();
124
gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
125
gtk_widget_show (menubar);
127
/* Create the menus */
130
mainitem = gtk_menu_item_new_with_mnemonic (_("_Tasks"));
131
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), mainitem);
132
gtk_widget_show (mainitem);
134
menu = gtk_menu_new ();
135
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mainitem), menu);
136
gtk_widget_show (menu);
138
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
139
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
140
g_signal_connect (G_OBJECT (menuitem), "activate",
141
G_CALLBACK (stopwatch_window_main_quit), window);
142
gtk_widget_show (menuitem);
145
mainitem = gtk_menu_item_new_with_mnemonic (_("_Help"));
146
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), mainitem);
147
gtk_widget_show (mainitem);
149
menu = gtk_menu_new ();
150
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mainitem), menu);
151
gtk_widget_show (menu);
153
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
154
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
155
g_signal_connect (G_OBJECT (menuitem), "activate",
156
G_CALLBACK (stopwatch_window_about_callback), window);
157
gtk_widget_show (menuitem);
159
/* Create the main view area */
160
priv->notebook = gtk_notebook_new ();
161
gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE);
162
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE);
163
gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0);
164
gtk_widget_show (priv->notebook);
166
/* Add the TaskView page */
167
scroll = sw_taskview_new ();
168
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook),
170
gtk_widget_show (scroll);
173
GtkWidget * stopwatch_window_new (void) {
174
return g_object_new (STOPWATCH_TYPE_WINDOW, NULL);