1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
1 |
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
2 |
/*
|
|
3 |
* Diary
|
|
4 |
* Copyright (C) Philip Withnall 2008 <philip@tecnocode.co.uk>
|
|
5 |
*
|
|
23
by Philip Withnall
2008-04-03 Philip Withnall <philip@tecnocode.co.uk> |
6 |
* Diary is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
11 |
* Diary is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
23
by Philip Withnall
2008-04-03 Philip Withnall <philip@tecnocode.co.uk> |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
16 |
* You should have received a copy of the GNU General Public License
|
23
by Philip Withnall
2008-04-03 Philip Withnall <philip@tecnocode.co.uk> |
17 |
* along with Diary. If not, see <http://www.gnu.org/licenses/>.
|
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
18 |
*/
|
19 |
||
20 |
#include <gtk/gtk.h> |
|
21 |
#include <glib/gi18n.h> |
|
22 |
||
23 |
#include "config.h" |
|
24 |
#include "main.h" |
|
8
by Philip Withnall
Fixed test profiling in the Makefile. |
25 |
#include "main-window.h" |
6
by Philip Withnall
Fixed changing the UI in the "Add Link" dialogue when the link type was changed. |
26 |
#include "add-link-dialog.h" |
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
27 |
#include "interface.h" |
28 |
||
29 |
GtkWidget * |
|
30 |
diary_create_interface (void) |
|
31 |
{
|
|
32 |
GError *error = NULL; |
|
33 |
GtkBuilder *builder; |
|
34 |
||
35 |
builder = gtk_builder_new (); |
|
36 |
||
19
by Philip Withnall
2008-03-30 Philip Withnall <philip@tecnocode.co.uk> |
37 |
if (gtk_builder_add_from_file (builder, PACKAGE_DATA_DIR"/diary/diary.ui", &error) == FALSE && |
38 |
gtk_builder_add_from_file (builder, "./data/diary.ui", NULL) == FALSE) { |
|
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
39 |
/* Show an error */
|
40 |
GtkWidget *dialog = gtk_message_dialog_new (NULL, |
|
41 |
GTK_DIALOG_MODAL, |
|
42 |
GTK_MESSAGE_ERROR, |
|
43 |
GTK_BUTTONS_OK, |
|
8
by Philip Withnall
Fixed test profiling in the Makefile. |
44 |
_("UI file \"%s/diary/diary.ui\" could not be loaded. Error: %s"), PACKAGE_DATA_DIR, error->message); |
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
45 |
gtk_dialog_run (GTK_DIALOG (dialog)); |
46 |
gtk_widget_destroy (dialog); |
|
47 |
||
48 |
g_error_free (error); |
|
49 |
g_object_unref (builder); |
|
50 |
diary_quit (); |
|
51 |
||
52 |
return NULL; |
|
53 |
}
|
|
54 |
||
55 |
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); |
|
56 |
gtk_builder_connect_signals (builder, NULL); |
|
57 |
||
58 |
/* Set up the main window */
|
|
2
by Philip Withnall
Lots of work on entry links, with most of a working UI for adding |
59 |
/* TODO: This is horrible */
|
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
60 |
diary->main_window = GTK_WIDGET (gtk_builder_get_object (builder, "dry_main_window")); |
5
by Philip Withnall
Some more UI tweaks to make editing easier. |
61 |
diary->entry_view = GTK_TEXT_VIEW (gtk_builder_get_object (builder, "dry_mw_entry_view")); |
62 |
diary->entry_buffer = gtk_text_view_get_buffer (diary->entry_view); |
|
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
63 |
diary->calendar = GTK_CALENDAR (gtk_builder_get_object (builder, "dry_mw_calendar")); |
64 |
diary->date_label = GTK_LABEL (gtk_builder_get_object (builder, "dry_mw_date_label")); |
|
65 |
diary->add_button = GTK_BUTTON (gtk_builder_get_object (builder, "dry_mw_add_button")); |
|
66 |
diary->remove_button = GTK_BUTTON (gtk_builder_get_object (builder, "dry_mw_remove_button")); |
|
4
by Philip Withnall
A few small UI fixes and enhancements. |
67 |
diary->view_button = GTK_BUTTON (gtk_builder_get_object (builder, "dry_mw_view_button")); |
2
by Philip Withnall
Lots of work on entry links, with most of a working UI for adding |
68 |
diary->add_action = GTK_ACTION (gtk_builder_get_object (builder, "dry_ui_add_link")); |
69 |
diary->remove_action = GTK_ACTION (gtk_builder_get_object (builder, "dry_ui_remove_link")); |
|
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
70 |
diary->links_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "dry_mw_links_store")); |
71 |
diary->links_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (builder, "dry_mw_links_tree_view"))); |
|
2
by Philip Withnall
Lots of work on entry links, with most of a working UI for adding |
72 |
diary->link_value_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (builder, "dry_mw_link_value_column")); |
73 |
diary->link_value_renderer = GTK_CELL_RENDERER_TEXT (gtk_builder_get_object (builder, "dry_mw_link_value_renderer")); |
|
7
by Philip Withnall
Added file and picasa link types. |
74 |
diary_main_window_setup (builder); |
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
75 |
|
76 |
/* Set up the add link dialogue */
|
|
77 |
diary->add_link_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "dry_add_link_dialog")); |
|
2
by Philip Withnall
Lots of work on entry links, with most of a working UI for adding |
78 |
diary->ald_type_combo_box = GTK_COMBO_BOX (gtk_builder_get_object (builder, "dry_ald_type_combo_box")); |
3
by Philip Withnall
Rewrote the link handling and it's all working quite well now. More link types now need to be added. |
79 |
diary->ald_table = GTK_TABLE (gtk_builder_get_object (builder, "dry_ald_table")); |
2
by Philip Withnall
Lots of work on entry links, with most of a working UI for adding |
80 |
diary->ald_type_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "dry_ald_type_store")); |
6
by Philip Withnall
Fixed changing the UI in the "Add Link" dialogue when the link type was changed. |
81 |
diary_add_link_dialog_setup (builder); |
1
by Philip Withnall
Initial commit with all the functionality that the Vala version had, but written in an easier-to-use programming language. |
82 |
|
83 |
g_object_unref (builder); |
|
84 |
||
85 |
return diary->main_window; |
|
86 |
}
|
|
87 |
||
88 |
/**
|
|
89 |
* diary_interface_error:
|
|
90 |
* @message: Error message
|
|
91 |
* @parent_window: The error dialog's parent window
|
|
92 |
*
|
|
93 |
* Display an error message and print the message to
|
|
94 |
* the console.
|
|
95 |
**/
|
|
96 |
void
|
|
97 |
diary_interface_error (const gchar *message, GtkWidget *parent_window) |
|
98 |
{
|
|
99 |
GtkWidget *dialog; |
|
100 |
||
101 |
g_warning (message); |
|
102 |
||
103 |
dialog = gtk_message_dialog_new (GTK_WINDOW (parent_window), |
|
104 |
GTK_DIALOG_MODAL, |
|
105 |
GTK_MESSAGE_ERROR, |
|
106 |
GTK_BUTTONS_OK, |
|
107 |
message); |
|
108 |
gtk_dialog_run (GTK_DIALOG (dialog)); |
|
109 |
gtk_widget_destroy (dialog); |
|
110 |
}
|
|
111 |