Merge lp:~tintou/maya/3.10 into lp:~elementary-apps/maya/trunk

Proposed by Corentin Noël on 2013-12-17
Status: Merged
Approved by: Corentin Noël on 2014-01-18
Approved revision: 502
Merged at revision: 505
Proposed branch: lp:~tintou/maya/3.10
Merge into: lp:~elementary-apps/maya/trunk
Diff against target: 1852 lines (+662/-681)
19 files modified
CMakeLists.txt (+10/-8)
cmake/Translations.cmake (+13/-37)
cmake/ValaPrecompile.cmake (+13/-1)
plugins/CalDAV/CalDAV.vala (+1/-1)
plugins/CalDAV/CalDAVBackend.vala (+2/-2)
plugins/Google/GoogleBackend.vala (+2/-2)
src/Application.vala (+15/-99)
src/CMakeLists.txt (+7/-7)
src/Model/CalendarModel.vala (+1/-5)
src/Settings/LanguagesFormat.vala (+13/-17)
src/View/EventDialog.vala (+1/-2)
src/View/MayaMenu.vala (+0/-73)
src/View/MayaToolbar.vala (+134/-81)
src/View/SourceDialog.vala (+101/-109)
src/View/SourceItem.vala (+210/-0)
src/View/SourceSelector.vala (+130/-230)
src/View/Widgets/Postler/FlowBox.vala (+6/-5)
src/View/Widgets/Postler/GuestEntry.vala (+2/-2)
src/config.vala.cmake (+1/-0)
To merge this branch: bzr merge lp:~tintou/maya/3.10
Reviewer Review Type Date Requested Status
Daniel Fore Approve on 2014-01-18
Cody Garver 2013-12-17 Needs Fixing on 2013-12-17
Review via email: mp+199365@code.launchpad.net

Commit message

Now using Gtk HeaderBar, Popovers and multilib

Description of the change

Now uses Gtk HeaderBar
Fixed some icons to make more sense (for example add events and no calendar when it should)
Fixed CMake to take advantage of GNUInstallDirs

To post a comment you must log in.
Cody Garver (codygarver) wrote :

I can only go backwards in years using the arrows in the headerbar.

Codestyle diff lines 406 and 419: needs a space

review: Needs Fixing
Cody Garver (codygarver) wrote :

Need a space on diff line 28 too. It could/should also instead become:

install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/${CMAKE_PROJECT_NAME}-calendar.desktop DESTINATION "${DATADIR}/applications")

review: Needs Fixing
Daniel Fore (danrabbit) wrote :

I can confirm Cody's bug with the year selector.

I'm also not sure I agree with using the new event icon for managing calendars since you can do more than just adding more calendars from this view.

Additionally the whole headerbar is hidden with the "fullscreen" button in the gear menu.

review: Needs Fixing
Cody Garver (codygarver) wrote :

The reason it can only go backwards is because

year_switcher.right_clicked.connect (() => {change_year (-1);});

should really be

year_switcher.right_clicked.connect (() => {change_year (1);});

lp:~tintou/maya/3.10 updated on 2013-12-21
498. By Corentin Noël on 2013-12-21

Fixed the year switcher and the calendar icon

Daniel Fore (danrabbit) wrote :

I can confirm the year switcher and calendar icon are now okay.

I think we should comment out the "fullscreen" menu item until we have a discoverable method for un-fullscreen. It seems like such a rarely used feature to be blocking this branch from being merged

lp:~tintou/maya/3.10 updated on 2013-12-23
499. By Corentin Noël on 2013-12-23

New Source seletion popover

Daniel Fore (danrabbit) wrote :

I'm getting this error a lot:

Failed to set text from markup due to error parsing markup: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity - escape ampersand as &

Daniel Fore (danrabbit) wrote :

With the popover:

1. It seems the submenus must be the same width as the main menu in order to avoid a rendering error with the arrow
2. The "Add New Calendar" button should probably be full width to make it behave more like a menu item. And we may want to experiment with giving it the css class of ".menuitem"
3. The icons for edit and delete should be only 16px because right now they're being stretched out.
4. When deleting an item, the popover doesn't shrink vertically after the undo message is dismissed.
5. The Add New Calendar item only allows me to add a local calendar, not a google or caldav. The combobox for "type" seems to be missing.
6. If possible, I would like the separator item to be the full width of the popover like how separators are in menus

review: Needs Fixing
Corentin Noël (tintou) wrote :

1. I think It should not be fixed in Maya but in Granite
2. You're right, with that class, the button is also more discoverable
3. I can only set their size according to the Gtk.IconSize parameter (http://valadoc.org/#!api=gtk+-3.0/Gtk.IconSize) currently it's Gtk.IconSize.SMALL_TOOLBAR
4. You're right, I've added some changes to really remove the grid from the container.
5. This is also a bug with the Granite popover and Gtk3.10, combobox doesn't show (and triggers crash). bu it is still possible to scroll inside to see the other views.
6. By default, Granite's popover has 5 extra pixels of margin to the border, I think it shouldn't have them, they have to be set in the application side.

Daniel Fore (danrabbit) wrote :

1. I agree it should be fixed in granite, but I don't think it would hurt to make the other pages wider just to workaround the issue for now
3. Can we use Gtk.IconSize.MENU ?
5. Hrm, I think we'll have to still workaround this until the bug is fixed. Can we show instead the selection with buttons as another page? Like 3 buttons in a vertical list "Google" "CalDAV" "On This Device" ?
6. So is this something we can override in the app then or is this a granite bug?

lp:~tintou/maya/3.10 updated on 2014-01-18
500. By Corentin Noël on 2014-01-18

Fixed the popover

501. By Corentin Noël on 2014-01-18

Fixed some wrong behaviors

Daniel Fore (danrabbit) wrote :

Hrm, I'm getting this message a lot: [Gtk] Failed to set text from markup due to error parsing markup: Error on line 1: Entity did not end with a semicolon; most likely you used an ampersand character without intending to start an entity - escape ampersand as &

Popover seems to be working great now :)

The first time that I add a new calendar, events pop up in the calendar view but selecting them doesn't show any additional information on the right-side pane

Hitting "Cancel" after editing an event is giving me a segfault: http://snippi.com/s/z2q22nw

review: Needs Fixing
lp:~tintou/maya/3.10 updated on 2014-01-18
502. By Corentin Noël on 2014-01-18

Fixed the markup parsing

Daniel Fore (danrabbit) wrote :

Okay, it sounds like the big remaining issues are from what's in trunk and not being introduced by this branch. Anything else are paper cuts in the new UI that we can fix before release. I think it's worth merging the branch to get wider testing/interest on calendar syncing

review: Approve
Cody Garver (codygarver) wrote :

Review: Approve

Sent from my iPhone

On Jan 18, 2014, at 3:40 PM, Daniel Fore <email address hidden> wrote:

> Review: Approve
>
> Okay, it sounds like the big remaining issues are from what's in trunk and not being introduced by this branch. Anything else are paper cuts in the new UI that we can fix before release. I think it's worth merging the branch to get wider testing/interest on calendar syncing
> --
> https://code.launchpad.net/~tintou/maya/3.10/+merge/199365
> You are reviewing the proposed merge of lp:~tintou/maya/3.10 into lp:maya.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-12-09 11:43:54 +0000
3+++ CMakeLists.txt 2014-01-18 21:06:28 +0000
4@@ -7,14 +7,16 @@
5 #
6 # Base bits
7 #
8-set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")
9-set (PKGDATADIR "${DATADIR}/maya-calendar")
10+include (GNUInstallDirs)
11+set (DATADIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}")
12+set (SRC_TARGET ${CMAKE_PROJECT_NAME}-calendar)
13+set (PKGDATADIR "${DATADIR}/${SRC_TARGET}")
14 set (GETTEXT_PACKAGE "maya")
15+set (APP_NAME "Maya")
16 set (RELEASE_NAME "Fast and connected.")
17 set (VERSION "0.2.2")
18 set (VERSION_INFO "Release")
19-set (SRC_TARGET ${CMAKE_PROJECT_NAME}-calendar)
20-set (PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_PROJECT_NAME}/plugins)
21+set (PLUGIN_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}/plugins)
22
23 list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
24 add_definitions ("-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\"")
25@@ -61,7 +63,7 @@
26 file (GLOB _datafiles "${CMAKE_CURRENT_SOURCE_DIR}/data/style/*")
27 install (FILES ${_datafiles} DESTINATION ${PKGDATADIR}/style)
28
29-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/maya-calendar.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications")
30+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/${SRC_TARGET}.desktop DESTINATION "${DATADIR}/applications")
31
32 #
33 # i18n
34@@ -92,7 +94,7 @@
35 glib-2.0
36 gio-2.0
37 gee-1.0
38- gtk+-3.0
39+ gtk+-3.0>=3.10
40 granite
41 libecal-1.2>=3.8.0
42 libical
43@@ -112,9 +114,9 @@
44
45 find_package (Vala REQUIRED)
46 include (ValaVersion)
47-ensure_vala_version ("0.18.0" MINIMUM)
48+ensure_vala_version ("0.22.0" MINIMUM)
49 include (ValaPrecompile)
50
51 add_subdirectory (src)
52 add_subdirectory (plugins)
53-add_subdirectory (schemas)
54+add_subdirectory (schemas)
55\ No newline at end of file
56
57=== modified file 'cmake/Translations.cmake' (properties changed: -x to +x)
58--- cmake/Translations.cmake 2013-05-09 20:32:54 +0000
59+++ cmake/Translations.cmake 2014-01-18 21:06:28 +0000
60@@ -20,47 +20,23 @@
61 add_custom_target (pot COMMENT “Building translation catalog.”)
62 find_program (XGETTEXT_EXECUTABLE xgettext)
63
64+
65 set(C_SOURCE "")
66- set(VALA_SOURCE "")
67- set(GLADE_SOURCE "")
68
69 foreach(FILES_INPUT ${ARGN})
70- set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT})
71-
72- file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.c)
73- foreach(C_FILE ${SOURCE_FILES})
74- set(C_SOURCE ${C_SOURCE} ${C_FILE})
75- endforeach()
76-
77- file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.vala)
78- foreach(VALA_C_FILE ${SOURCE_FILES})
79- set(VALA_SOURCE ${VALA_SOURCE} ${VALA_C_FILE})
80- endforeach()
81-
82- file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.ui)
83- foreach(GLADE_C_FILE ${SOURCE_FILES})
84- set(GLADE_SOURCE ${GLADE_SOURCE} ${GLADE_C_FILE})
85+ file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.c)
86+ foreach(C_FILE ${SOURCE_FILES})
87+ set(C_SOURCE ${C_SOURCE} ${C_FILE})
88+ endforeach()
89+ file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.vala)
90+ foreach(C_FILE ${SOURCE_FILES})
91+ set(C_SOURCE ${C_SOURCE} ${C_FILE})
92 endforeach()
93 endforeach()
94
95- set(BASE_XGETTEXT_COMMAND
96- ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE}
97- -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
98- --keyword="_" --keyword="N_" --from-code=UTF-8)
99-
100- set(CONTINUE_FLAG "")
101-
102- IF(NOT "${C_SOURCE}" STREQUAL "")
103- add_custom_command(TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE})
104- set(CONTINUE_FLAG "-j")
105- ENDIF()
106-
107- IF(NOT "${VALA_SOURCE}" STREQUAL "")
108- add_custom_command(TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LC\# ${VALA_SOURCE})
109- set(CONTINUE_FLAG "-j")
110- ENDIF()
111-
112- IF(NOT "${GLADE_SOURCE}" STREQUAL "")
113- add_custom_command (TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LGlade ${GLADE_SOURCE})
114- ENDIF()
115+ add_custom_command (TARGET pot COMMAND
116+ ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
117+ ${VALA_SOURCE} ${C_SOURCE} --add-comments="/" --keyword="_" --keyword="N_" --keyword="C_:1c,2"
118+ --keyword="NC_:1c,2" --keyword="ngettext:1,2" --keyword="N_" --keyword="Q_:1g" --from-code=UTF-8
119+ )
120 endmacro()
121
122=== modified file 'cmake/ValaPrecompile.cmake'
123--- cmake/ValaPrecompile.cmake 2013-05-01 23:46:37 +0000
124+++ cmake/ValaPrecompile.cmake 2014-01-18 21:06:28 +0000
125@@ -185,10 +185,21 @@
126 endif(ARGS_GENERATE_HEADER)
127
128 set(gir_arguments "")
129+ set(gircomp_command "")
130 if(ARGS_GENERATE_GIR)
131 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir")
132 list(APPEND out_files_display "${ARGS_GENERATE_GIR}.gir")
133 set(gir_arguments "--gir=${ARGS_GENERATE_GIR}.gir")
134+
135+ include (FindGirCompiler)
136+ find_package(GirCompiler REQUIRED)
137+
138+ set(gircomp_command
139+ COMMAND
140+ ${G_IR_COMPILER_EXECUTABLE}
141+ ARGS
142+ "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir"
143+ -o "${DIRECTORY}/${ARGS_GENERATE_GIR}.typelib")
144 endif(ARGS_GENERATE_GIR)
145
146 set(symbols_arguments "")
147@@ -201,7 +212,7 @@
148 # Workaround for a bug that would make valac run twice. This file is written
149 # after the vala compiler generates C source code.
150 set(OUTPUT_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_valac.stamp)
151-
152+
153 add_custom_command(
154 OUTPUT
155 ${OUTPUT_STAMP}
156@@ -228,6 +239,7 @@
157 ${ARGS_CUSTOM_VAPIS}
158 COMMENT
159 "Generating ${out_files_display}"
160+ ${gircomp_command}
161 )
162
163 # This command will be run twice for some reason (pass a non-empty string to COMMENT
164
165=== modified file 'plugins/CalDAV/CalDAV.vala'
166--- plugins/CalDAV/CalDAV.vala 2013-11-14 18:20:10 +0000
167+++ plugins/CalDAV/CalDAV.vala 2014-01-18 21:06:28 +0000
168@@ -57,4 +57,4 @@
169 var objmodule = module as Peas.ObjectModule;
170 objmodule.register_extension_type (typeof (Peas.Activatable),
171 typeof (Maya.Plugins.CalDAVPlugin));
172-}
173+}
174\ No newline at end of file
175
176=== modified file 'plugins/CalDAV/CalDAVBackend.vala'
177--- plugins/CalDAV/CalDAVBackend.vala 2013-11-14 18:20:10 +0000
178+++ plugins/CalDAV/CalDAVBackend.vala 2014-01-18 21:06:28 +0000
179@@ -148,7 +148,7 @@
180 var list = new List<E.Source> ();
181 list.append (new_source);
182 registry.create_sources_sync (list);
183- app.calmodel.add_source (new_source);
184+ ((Maya.Application)GLib.Application.get_default ()).calmodel.add_source (new_source);
185 if (set_default) {
186 registry.default_calendar = new_source;
187 }
188@@ -190,4 +190,4 @@
189 critical (error.message);
190 }
191 }
192-}
193+}
194\ No newline at end of file
195
196=== modified file 'plugins/Google/GoogleBackend.vala'
197--- plugins/Google/GoogleBackend.vala 2013-11-14 18:20:10 +0000
198+++ plugins/Google/GoogleBackend.vala 2014-01-18 21:06:28 +0000
199@@ -89,7 +89,7 @@
200 var list = new List<E.Source> ();
201 list.append (new_source);
202 registry.create_sources_sync (list);
203- app.calmodel.add_source (new_source);
204+ ((Maya.Application)GLib.Application.get_default ()).calmodel.add_source (new_source);
205 if (set_default) {
206 registry.default_calendar = new_source;
207 }
208@@ -132,4 +132,4 @@
209 critical (error.message);
210 }
211 }
212-}
213+}
214\ No newline at end of file
215
216=== modified file 'src/Application.vala'
217--- src/Application.vala 2013-12-09 09:03:14 +0000
218+++ src/Application.vala 2014-01-18 21:06:28 +0000
219@@ -24,10 +24,10 @@
220 private static bool PRINT_VERSION = false;
221
222 }
223- public Application app;
224 public Plugins.Manager plugins_manager;
225 public BackendsManager backends_manager;
226 public Settings.MayaSettings global_settings;
227+ public Settings.SavedState saved_state;
228
229 public static int main (string[] args) {
230
231@@ -48,7 +48,7 @@
232 }
233
234 Gtk.init (ref args);
235- app = new Application ();
236+ var app = new Application ();
237
238 return app.run (args);
239
240@@ -71,7 +71,7 @@
241 build_version = Build.VERSION;
242 build_version_info = Build.VERSION_INFO;
243
244- program_name = "Maya";
245+ program_name = Build.APP_NAME;
246 exec_name = "maya-calendar";
247
248 app_years = "2011-2013";
249@@ -109,8 +109,6 @@
250 { null }
251 };
252
253- Settings.SavedState saved_state;
254-
255 public Gtk.Window window;
256 View.MayaToolbar toolbar;
257 View.CalendarView calview;
258@@ -213,8 +211,6 @@
259
260 create_window ();
261
262- create_toolbar ();
263-
264 calview = new View.CalendarView (calmodel, saved_state.show_weeks);
265 calview.on_event_add.connect ((date) => on_tb_add_clicked (date));
266
267@@ -233,15 +229,14 @@
268
269 gridcontainer = new Gtk.Grid ();
270 hpaned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
271- calview.set_vexpand(true);
272+ calview.vexpand = true;
273 hpaned.pack1 (calview, true, false);
274 hpaned.pack2 (sidebar, true, false);
275 hpaned.position = saved_state.hpaned_position;
276- gridcontainer.attach (toolbar, 0, 0, 1, 1);
277 gridcontainer.attach (hpaned, 0, 2, 1, 1);
278 window.add (gridcontainer);
279
280- add_window(window);
281+ add_window (window);
282
283 if (saved_state.window_state == Settings.WindowState.MAXIMIZED)
284 window.maximize ();
285@@ -296,33 +291,18 @@
286
287 break;
288 case Gdk.Key.@F11:
289- toolbar.menu.fullscreen.active = !toolbar.menu.fullscreen.active;
290+ toolbar.fullscreen.active = !toolbar.fullscreen.active;
291 break;
292 }
293
294 return false;
295 });
296- }
297-
298- /**
299- * Creates the toolbar and its elements.
300- */
301- void create_toolbar () {
302- toolbar = new View.MayaToolbar (calmodel.month_start);
303- toolbar.button_add.clicked.connect (() => on_tb_add_clicked (calview.grid.selected_date));
304- toolbar.button_calendar_sources.clicked.connect (on_tb_sources_clicked);
305- toolbar.menu.today.activate.connect (on_menu_today_toggled);
306- toolbar.menu.fullscreen.toggled.connect (on_toggle_fullscreen);
307- toolbar.menu.weeknumbers.toggled.connect (on_menu_show_weeks_toggled);
308- toolbar.menu.fullscreen.active = (saved_state.window_state == Settings.WindowState.FULLSCREEN);
309- toolbar.menu.about.activate.connect (() => show_about(window));
310- toolbar.menu.weeknumbers.active = saved_state.show_weeks;
311- toolbar.search_bar.text_changed_pause.connect ((text) => on_search (text));
312-
313- toolbar.month_switcher.left_clicked.connect (on_tb_month_switcher_left_clicked);
314- toolbar.month_switcher.right_clicked.connect (on_tb_month_switcher_right_clicked);
315- toolbar.year_switcher.left_clicked.connect (on_tb_year_switcher_left_clicked);
316- toolbar.year_switcher.right_clicked.connect (on_tb_year_switcher_right_clicked);
317+
318+ toolbar = new View.MayaToolbar (calmodel);
319+ toolbar.add_calendar_clicked.connect (() => on_tb_add_clicked (calview.grid.selected_date));
320+ toolbar.on_menu_today_toggled.connect (on_menu_today_toggled);
321+ toolbar.on_search.connect ((text) => on_search (text));
322+ window.set_titlebar (toolbar);
323 }
324
325 void on_quit () {
326@@ -355,14 +335,6 @@
327
328 //--- SIGNAL HANDLERS ---//
329
330- void on_toggle_fullscreen () {
331-
332- if (toolbar.menu.fullscreen.active)
333- window.fullscreen ();
334- else
335- window.unfullscreen ();
336- }
337-
338 void on_event_dialog_response (View.EventDialog dialog, bool response_id, bool add_event) {
339
340 E.CalComponent event = dialog.ecal;
341@@ -413,30 +385,6 @@
342
343 }
344
345- void on_tb_sources_clicked (Gtk.Widget widget) {
346- var source_selector = new View.SourceSelector ();
347- source_selector.move_to_widget (widget);
348- source_selector.show_all ();
349- source_selector.run ();
350- source_selector.destroy ();
351- }
352-
353- void on_tb_month_switcher_left_clicked () {
354- calmodel.month_start = calmodel.month_start.add_months (-1);
355- }
356-
357- void on_tb_month_switcher_right_clicked () {
358- calmodel.month_start = calmodel.month_start.add_months (1);
359- }
360-
361- void on_tb_year_switcher_left_clicked () {
362- calmodel.month_start = calmodel.month_start.add_years (-1);
363- }
364-
365- void on_tb_year_switcher_right_clicked () {
366- calmodel.month_start = calmodel.month_start.add_years (1);
367- }
368-
369 /**
370 * Called when the search_bar is used.
371 */
372@@ -454,38 +402,6 @@
373 calview.today ();
374 }
375
376- void on_menu_show_weeks_toggled () {
377- saved_state.show_weeks = toolbar.menu.weeknumbers.active;
378- }
379-
380- public void show_calendar_removed (string calendar_name) {
381- var info_bar = new Gtk.InfoBar ();
382- ((Gtk.Orientable)info_bar.get_action_area ()).orientation = Gtk.Orientation.HORIZONTAL;
383- //warning (info_bar.get_action_area ().name);
384- info_bar.set_message_type (Gtk.MessageType.INFO);
385- info_bar.add_button (Gtk.Stock.UNDO, 0);
386- info_bar.add_button (Gtk.Stock.CLOSE, 1);
387- var message_label = new Gtk.Label (_("Calendar \"%s\" removed.").printf (calendar_name));
388- info_bar.get_content_area ().add (message_label);
389- info_bar.response.connect ((id) => {
390- if (id == 0) {
391- calmodel.restore_calendar ();
392- info_bar.hide ();
393- } else {
394- info_bar.hide ();
395- }
396- });
397- gridcontainer.attach (info_bar, 0, 1, 1, 1);
398- info_bar.show_all ();
399- }
400-
401- }
402-
403- internal void desktop_translations () {
404- var comment = _("View and schedule events");
405- var generic_name = _("Calendar");
406- var add_event = _("_Add Event");
407- var keywords = _("Maya;Planner;Dates;Days;Events;");
408- }
409-
410-}
411+ }
412+
413+}
414\ No newline at end of file
415
416=== modified file 'src/CMakeLists.txt'
417--- src/CMakeLists.txt 2013-08-31 15:14:02 +0000
418+++ src/CMakeLists.txt 2014-01-18 21:06:28 +0000
419@@ -31,7 +31,7 @@
420 View/Grid/VAutoHider.vala
421 View/EventDialog.vala
422 View/SourceDialog.vala
423- View/MayaMenu.vala
424+ View/SourceItem.vala
425 View/MayaToolbar.vala
426 View/SourceSelector.vala
427 View/Widgets/ContractorButtonWithMenu.vala
428@@ -67,12 +67,12 @@
429 target_link_libraries(${EXEC_NAME} ${DEPS_LIBRARIES})
430
431 if (BUILD_SHARED_LIBS)
432- install(TARGETS ${CLIENT_LIBRARY_NAME} DESTINATION lib)
433+ install(TARGETS ${CLIENT_LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
434 # Install lib stuffs
435- install (FILES ${CMAKE_BINARY_DIR}/src/${CLIENT_VAPI}.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/)
436- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_VAPI}.vapi DESTINATION share/vala/vapi/)
437- install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_VAPI}.deps DESTINATION share/vala/vapi/)
438- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_VAPI}.h DESTINATION include/${CLIENT_VAPI}/)
439+ install (FILES ${CMAKE_BINARY_DIR}/src/${CLIENT_VAPI}.pc DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig/)
440+ install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_VAPI}.vapi DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/vala/vapi/)
441+ install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_VAPI}.deps DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/vala/vapi/)
442+ install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_VAPI}.h DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/${CLIENT_VAPI}/)
443 endif ()
444
445-install(TARGETS ${EXEC_NAME} RUNTIME DESTINATION bin)
446+install(TARGETS ${EXEC_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
447\ No newline at end of file
448
449=== modified file 'src/Model/CalendarModel.vala'
450--- src/Model/CalendarModel.vala 2013-09-01 23:32:20 +0000
451+++ src/Model/CalendarModel.vala 2014-01-18 21:06:28 +0000
452@@ -532,11 +532,7 @@
453
454 public void do_real_deletion () {
455 foreach (var source in calendar_trash) {
456- try {
457- source.remove.begin (null);
458- } catch (Error error) {
459- critical (error.message);
460- }
461+ source.remove.begin (null);
462 }
463 }
464 }
465
466=== modified file 'src/Settings/LanguagesFormat.vala'
467--- src/Settings/LanguagesFormat.vala 2012-03-11 01:51:18 +0000
468+++ src/Settings/LanguagesFormat.vala 2014-01-18 21:06:28 +0000
469@@ -17,28 +17,24 @@
470
471 namespace Maya.Settings {
472
473- public string DateFormat () {
474- return (_("%B %e, %Y"));
475- }
476-
477- public string DateFormat_Complete () {
478- return (_("%A, %b %d"));
479- }
480-
481- public string TimeFormat () {
482-
483+ public string DateFormat () {
484+ return _("%B %e, %Y");
485+ }
486+
487+ public string DateFormat_Complete () {
488+ return _("%A, %b %d");
489+ }
490+
491+ public string TimeFormat () {
492 var setting = new GLib.Settings ("org.gnome.desktop.interface");
493 string clockformat = setting.get_string ("clock-format");
494- string outputformat;
495
496- if (clockformat == "12h") {
497- outputformat = (_("%l:%M %p"));
498+ if (clockformat.contains ("12h")) {
499+ return _("%l:%M %p");
500 }
501 else {
502- outputformat = (_("%H:%M"));
503+ return _("%H:%M");
504 }
505- return outputformat;
506- }
507+ }
508
509 }
510-
511
512=== modified file 'src/View/EventDialog.vala'
513--- src/View/EventDialog.vala 2013-09-02 14:58:51 +0000
514+++ src/View/EventDialog.vala 2014-01-18 21:06:28 +0000
515@@ -443,7 +443,7 @@
516
517 Granite.Widgets.TimePicker make_time_picker () {
518
519- var time_picker = new Granite.Widgets.TimePicker.with_format (Maya.Settings.TimeFormat ());
520+ var time_picker = new Granite.Widgets.TimePicker ();
521 time_picker.width_request = 120;
522
523 return time_picker;
524@@ -559,4 +559,3 @@
525
526
527 }
528-
529
530=== removed file 'src/View/MayaMenu.vala'
531--- src/View/MayaMenu.vala 2012-06-01 20:14:09 +0000
532+++ src/View/MayaMenu.vala 1970-01-01 00:00:00 +0000
533@@ -1,73 +0,0 @@
534-//
535-// Copyright (C) 2011-2012 Maxwell Barvian
536-//
537-// This program is free software: you can redistribute it and/or modify
538-// it under the terms of the GNU General Public License as published by
539-// the Free Software Foundation, either version 3 of the License, or
540-// (at your option) any later version.
541-//
542-// This program is distributed in the hope that it will be useful,
543-// but WITHOUT ANY WARRANTY; without even the implied warranty of
544-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
545-// GNU General Public License for more details.
546-//
547-// You should have received a copy of the GNU General Public License
548-// along with this program. If not, see <http://www.gnu.org/licenses/>.
549-//
550-
551-namespace Maya.View {
552-
553- public class MayaMenu : Gtk.Menu {
554-
555- public Gtk.MenuItem today { get; private set; }
556-
557- public Gtk.MenuItem import { get; private set; }
558- public Gtk.MenuItem export { get; private set; }
559-
560- public Gtk.CheckMenuItem fullscreen { get; private set; }
561- public Gtk.CheckMenuItem weeknumbers { get; private set; }
562-
563- public Gtk.MenuItem sync { get; private set; }
564-
565- public Gtk.MenuItem about { get; private set; }
566-
567- public MayaMenu () {
568-
569- // Create everything
570- today = new Gtk.MenuItem.with_label (_("Today"));
571-
572- fullscreen = new Gtk.CheckMenuItem.with_label (_("Fullscreen"));
573-
574- weeknumbers = new Gtk.CheckMenuItem.with_label (_("Show Week Numbers"));
575-
576- import = new Gtk.MenuItem.with_label (_("Import..."));
577-
578- sync = new Gtk.MenuItem.with_label (_("Sync..."));
579-
580- about = new Gtk.MenuItem.with_label (_("About"));
581-
582- // Append in correct order
583- append (today);
584-
585- append (new Gtk.SeparatorMenuItem ());
586-
587- append (fullscreen);
588- append (weeknumbers);
589-
590- /*
591- * TODO : Will be done in Maya 0.2
592- append (new Gtk.SeparatorMenuItem ());
593-
594- append (import);
595- append (sync);
596- */
597-
598- append (new Gtk.SeparatorMenuItem ());
599-
600- append (about);
601- }
602-
603- }
604-
605-}
606-
607
608=== modified file 'src/View/MayaToolbar.vala'
609--- src/View/MayaToolbar.vala 2013-07-17 11:57:59 +0000
610+++ src/View/MayaToolbar.vala 2014-01-18 21:06:28 +0000
611@@ -17,88 +17,107 @@
612
613 namespace Maya.View {
614
615- public class MayaToolbar : Gtk.Toolbar {
616-
617- public Gtk.ToolButton button_add { get; private set; }
618-
619- public Widgets.DateSwitcher month_switcher { get; private set; }
620- public Widgets.DateSwitcher year_switcher { get; private set; }
621-
622- public Granite.Widgets.SearchBar search_bar { get; private set; }
623-
624- public Gtk.ToolButton button_calendar_sources { get; private set; }
625-
626- public Granite.Widgets.AppMenu app_menu { get; private set; }
627- public MayaMenu menu { get; private set; }
628-
629- public Widgets.ContractorButtonWithMenu contractor { get; private set; }
630-
631- public MayaToolbar (DateTime target) {
632-
633- // Toolbar properties
634- get_style_context ().add_class ("primary-toolbar"); // compliant with elementary HIG
635-
636- // Initialize everything
637- button_add = make_toolbutton (Gtk.IconTheme.get_default ().has_icon ("event-new") ? "event-new" : "list-add", _("Create a new event"));
638-
639- button_calendar_sources = make_toolbutton ("gtk-index", _("Select calendars to display"), true);
640-
641+ public class MayaToolbar : Gtk.HeaderBar {
642+
643+ // Signals
644+ public signal void on_search (string search);
645+ public signal void on_menu_today_toggled ();
646+ public signal void add_calendar_clicked ();
647+
648+ Model.CalendarModel calmodel;
649+
650+ // Toolbar items
651+ Widgets.DateSwitcher month_switcher;
652+ Widgets.DateSwitcher year_switcher;
653+ public Gtk.SearchEntry search_bar;
654+
655+ // Menu items
656+ public Gtk.CheckMenuItem fullscreen;
657+ Gtk.CheckMenuItem weeknumbers;
658+ View.SourceSelector source_selector;
659+
660+ public MayaToolbar (Model.CalendarModel calmodel) {
661+ this.calmodel = calmodel;
662+ show_close_button = true;
663+
664+ var button_add = new Gtk.Button.from_icon_name ("appointment-new", Gtk.IconSize.LARGE_TOOLBAR);
665+ button_add.tooltip_text = _("Create a new event");
666+
667+ var button_calendar_sources = new Gtk.Button.from_icon_name ("office-calendar", Gtk.IconSize.LARGE_TOOLBAR);
668+ button_calendar_sources.tooltip_text = _("Manage Calendars");
669+
670 month_switcher = new Widgets.DateSwitcher (10);
671 year_switcher = new Widgets.DateSwitcher (-1);
672- set_switcher_date (target);
673-
674- search_bar = new Granite.Widgets.SearchBar (_("Search Events"));
675+ set_switcher_date (calmodel.month_start);
676+
677+ search_bar = new Gtk.SearchEntry ();
678+ search_bar.placeholder_text = _("Search Events");
679 search_bar.sensitive = false;
680-
681- contractor = new Widgets.ContractorButtonWithMenu (_("Export or Share the default Calendar"));
682-
683- menu = new MayaMenu ();
684- app_menu = new Granite.Widgets.AppMenu (menu);
685-
686- // Insert into appropriate positions
687- insert (button_add, -1);
688-
689- insert (make_spacer (), -1);
690-
691- insert (make_toolitem_from_widget (Util.set_paddings (month_switcher, 5, 0, 5, 0)), -1);
692- insert (make_toolitem_from_widget (Util.set_paddings (year_switcher, 5, 0, 5, 10)), -1);
693-
694- insert (make_spacer (), -1);
695-
696- insert (make_toolitem_from_widget (search_bar), -1);
697-
698- insert (button_calendar_sources, -1);
699-
700- insert (contractor, -1);
701-
702- insert (app_menu, -1);
703- }
704-
705- private Gtk.ToolButton make_toolbutton (string icon_name, string tooltip_text, bool sensitive = true, bool can_focus = false) {
706-
707- var toolbutton = new Gtk.ToolButton (null, null);
708- toolbutton.icon_name = icon_name;
709- toolbutton.sensitive = sensitive;
710- toolbutton.can_focus = can_focus;
711- toolbutton.tooltip_text = tooltip_text;
712-
713- return toolbutton;
714- }
715-
716- private Gtk.ToolItem make_spacer () {
717-
718- var spacer = new Gtk.ToolItem ();
719- spacer.set_expand (true);
720-
721- return spacer;
722- }
723-
724- private Gtk.ToolItem make_toolitem_from_widget (Gtk.Widget widget) {
725-
726- var toolitem = new Gtk.ToolItem ();
727- toolitem.add (widget);
728-
729- return toolitem;
730+
731+ var contractor = new Widgets.ContractorButtonWithMenu (_("Export or Share the default Calendar"));
732+
733+ var menu = new Gtk.Menu ();
734+ var menu_button = new Granite.Widgets.AppMenu (menu);
735+
736+ var title_grid = new Gtk.Grid ();
737+ title_grid.column_spacing = 6;
738+
739+ title_grid.attach (year_switcher, 0, 0, 1, 1);
740+ title_grid.attach (month_switcher, 1, 0, 1, 1);
741+ this.set_custom_title (title_grid);
742+
743+ // Create the menu
744+
745+ var today = new Gtk.MenuItem.with_label (_("Today"));
746+ fullscreen = new Gtk.CheckMenuItem.with_label (_("Fullscreen"));
747+ weeknumbers = new Gtk.CheckMenuItem.with_label (_("Show Week Numbers"));
748+ //var import = new Gtk.MenuItem.with_label (_("Import…"));
749+ var about = new Gtk.MenuItem.with_label (_("About"));
750+
751+ // Append in correct order
752+ menu.add (today);
753+ menu.add (new Gtk.SeparatorMenuItem ());
754+ menu.add (fullscreen);
755+ menu.add (weeknumbers);
756+
757+ /* TODO : Will be done in Maya 0.2
758+ menu.append (new Gtk.SeparatorMenuItem ());
759+ menu.append (import);
760+ menu.append (sync);
761+ */
762+
763+ menu.append (new Gtk.SeparatorMenuItem ());
764+ menu.append (about);
765+
766+ pack_start (button_calendar_sources);
767+ pack_start (button_add);
768+
769+ pack_end (contractor);
770+ pack_end (search_bar);
771+ pack_end (menu_button);
772+
773+ // Connect to signals
774+
775+ button_add.clicked.connect (() => add_calendar_clicked ());
776+ button_calendar_sources.clicked.connect (on_tb_sources_clicked);
777+ today.activate.connect (() => on_menu_today_toggled);
778+ fullscreen.toggled.connect (on_toggle_fullscreen);
779+ weeknumbers.toggled.connect (on_menu_show_weeks_toggled);
780+ about.activate.connect (() => {
781+ var app = ((Maya.Application)GLib.Application.get_default ());
782+ app.show_about (app.window);
783+ });
784+ search_bar.search_changed.connect (() => on_search (search_bar.text));
785+
786+ month_switcher.left_clicked.connect (() => {change_month (-1);});
787+ month_switcher.right_clicked.connect (() => {change_month (1);});
788+ year_switcher.left_clicked.connect (() => {change_year (-1);});
789+ year_switcher.right_clicked.connect (() => {change_year (1);});
790+
791+ button_calendar_sources.size_allocate.connect (button_size_allocate);
792+
793+ fullscreen.active = (saved_state.window_state == Settings.WindowState.FULLSCREEN);
794+ weeknumbers.active = saved_state.show_weeks;
795 }
796
797 public void set_switcher_date (DateTime date) {
798@@ -106,7 +125,41 @@
799 year_switcher.text = date.format ("%Y");
800 }
801
802+ void on_toggle_fullscreen () {
803+ var window = ((Maya.Application)GLib.Application.get_default ()).window;
804+
805+ if (fullscreen.active)
806+ window.fullscreen ();
807+ else
808+ window.unfullscreen ();
809+ }
810+
811+ void on_menu_show_weeks_toggled () {
812+ saved_state.show_weeks = weeknumbers.active;
813+ }
814+
815+ void button_size_allocate (Gtk.Allocation allocation) {
816+ month_switcher.height_request = allocation.height;
817+ year_switcher.height_request = allocation.height;
818+ }
819+
820+ void on_tb_sources_clicked (Gtk.Widget widget) {
821+ if (source_selector == null) {
822+ source_selector = new View.SourceSelector (calmodel);
823+ }
824+ source_selector.move_to_widget (widget);
825+ source_selector.show ();
826+ source_selector.run ();
827+ }
828+
829+ void change_month (int relative) {
830+ calmodel.month_start = calmodel.month_start.add_months (relative);
831+ }
832+
833+ void change_year (int relative) {
834+ calmodel.month_start = calmodel.month_start.add_years (relative);
835+ }
836+
837 }
838
839-}
840-
841+}
842\ No newline at end of file
843
844=== modified file 'src/View/SourceDialog.vala'
845--- src/View/SourceDialog.vala 2013-09-01 23:22:22 +0000
846+++ src/View/SourceDialog.vala 2014-01-18 21:06:28 +0000
847@@ -15,100 +15,62 @@
848 // along with this program. If not, see <http://www.gnu.org/licenses/>.
849 //
850
851-#if USE_GRANITE_DECORATED_WINDOW
852-public class Maya.View.SourceDialog : Granite.Widgets.LightWindow {
853-#else
854-public class Maya.View.SourceDialog : Gtk.Window {
855-#endif
856-
857+public class Maya.View.SourceDialog : Gtk.Grid {
858 public EventType event_type { get; private set; default=EventType.EDIT;}
859-
860+
861 private Gtk.Entry name_entry;
862 private Gtk.ColorButton color_button;
863 private bool set_as_default = false;
864 private Backend current_backend;
865 private Gee.Collection<PlacementWidget> backend_widgets;
866 private Gtk.Grid main_grid;
867- private Gtk.Grid general_grid;
868 private Gee.HashMap<string, bool> widgets_checked;
869 private Gtk.Button create_button;
870- private E.Source source;
871-
872- public SourceDialog (E.Source? source = null) {
873+ private Gtk.ComboBox type_combobox;
874+ private Gtk.ListStore list_store;
875+ private E.Source source = null;
876+
877+ public signal void go_back ();
878+
879+ public SourceDialog () {
880 widgets_checked = new Gee.HashMap<string, bool> (null, null);
881-
882- if (source == null) {
883- title = _("Add Calendar");
884- event_type = EventType.ADD;
885- } else {
886- title = _("Edit Calendar");
887- this.source = source;
888- }
889-
890- // Dialog properties
891- window_position = Gtk.WindowPosition.CENTER_ON_PARENT;
892- type_hint = Gdk.WindowTypeHint.DIALOG;
893- transient_for = app.window;
894
895 main_grid = new Gtk.Grid ();
896 main_grid.set_row_spacing (6);
897 main_grid.set_column_spacing (12);
898-
899- general_grid = new Gtk.Grid ();
900- general_grid.margin_left = 12;
901- general_grid.margin_right = 12;
902- general_grid.margin_top = 12;
903- general_grid.margin_bottom = 12;
904- general_grid.set_row_spacing (6);
905- general_grid.set_column_spacing (12);
906-
907+
908+ margin_left = 6;
909+ margin_right = 6;
910+ margin_top = 6;
911+ set_row_spacing (6);
912+ set_column_spacing (12);
913+ expand = true;
914+
915 // Buttons
916-
917+
918 var buttonbox = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
919 buttonbox.set_layout (Gtk.ButtonBoxStyle.END);
920-
921
922- var cancel_button = new Gtk.Button.from_stock (Gtk.Stock.CANCEL);
923- if (event_type == EventType.ADD) {
924- create_button = new Gtk.Button.with_label (_("Create Calendar"));
925- } else {
926- create_button = new Gtk.Button.from_stock (Gtk.Stock.SAVE);
927- }
928+ var cancel_button = new Gtk.Button.with_label (_("Cancel"));
929+ create_button = new Gtk.Button.with_label (_("Create"));
930
931 create_button.clicked.connect (save);
932- cancel_button.clicked.connect (() => {this.destroy();});
933+ cancel_button.clicked.connect (() => go_back ());
934
935 buttonbox.pack_end (cancel_button);
936 buttonbox.pack_end (create_button);
937-
938+
939 // Name
940-
941 var name_label = new Gtk.Label (_("Name:"));
942 name_label.xalign = 1;
943 name_entry = new Gtk.Entry ();
944 name_entry.placeholder_text = _("Calendar Name");
945 name_entry.changed.connect (() => {check_can_validate ();});
946- if (event_type == EventType.EDIT) {
947- name_entry.text = source.display_name;
948- }
949-
950+
951 // Type Combobox
952- Gtk.ListStore list_store = new Gtk.ListStore (2, typeof (string), typeof (Backend));
953- Gtk.TreeIter iter;
954- int number = 0;
955- int i =0;
956- foreach (var backend in backends_manager.backends) {
957- list_store.append (out iter);
958- list_store.set (iter, 0, backend.get_name (), 1, backend);
959- if (event_type == EventType.EDIT) {
960- if (backend.get_uid () == source.dup_parent ()) {
961- number = i;
962- }
963- }
964- i++;
965- }
966-
967- var type_combobox = new Gtk.ComboBox.with_model (list_store);
968+ list_store = new Gtk.ListStore (2, typeof (string), typeof (Backend));
969+
970+ type_combobox = new Gtk.ComboBox.with_model (list_store);
971
972 Gtk.CellRendererText renderer = new Gtk.CellRendererText ();
973 type_combobox.pack_start (renderer, true);
974@@ -116,7 +78,6 @@
975
976 type_combobox.changed.connect (() => {
977 GLib.Value backend;
978-
979 Gtk.TreeIter b_iter;
980 type_combobox.get_active_iter (out b_iter);
981 list_store.get_value (b_iter, 1, out backend);
982@@ -125,38 +86,33 @@
983 backend_widgets = ((Backend)backend).get_new_calendar_widget (source);
984 add_backend_widgets ();
985 });
986-
987- type_combobox.set_active (number);
988-
989+
990 var type_label = new Gtk.Label (_("Type:"));
991- type_label.expand = true;
992 type_label.xalign = 1;
993-
994- if (backends_manager.backends.size == 1) {
995+
996+ Gtk.TreeIter iter;
997+ foreach (var backend in backends_manager.backends) {
998+ list_store.append (out iter);
999+ list_store.set (iter, 0, backend.get_name (), 1, backend);
1000+ }
1001+
1002+ if (backends_manager.backends.size <= 1) {
1003 type_combobox.no_show_all = true;
1004 type_label.no_show_all = true;
1005 }
1006-
1007- if (event_type == EventType.EDIT) {
1008- type_combobox.sensitive = false;
1009- }
1010-
1011+
1012+ type_combobox.set_active (0);
1013+
1014 // Color
1015 var rgba = Gdk.RGBA ();
1016- if (event_type == EventType.EDIT) {
1017- var cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);
1018- rgba.parse (cal.dup_color ());
1019- } else {
1020- rgba.red = 0.13;
1021- rgba.green = 0.42;
1022- rgba.blue = 0.70;
1023- }
1024+ rgba.red = 0.13;
1025+ rgba.green = 0.42;
1026+ rgba.blue = 0.70;
1027 var color_label = new Gtk.Label (_("Color:"));
1028 color_label.xalign = 1;
1029 color_button = new Gtk.ColorButton.with_rgba (rgba);
1030 color_button.use_alpha = false;
1031-
1032-
1033+
1034 var check_button = new Gtk.CheckButton.with_label (_("Mark as default calendar"));
1035
1036 check_button.toggled.connect (() => {
1037@@ -170,25 +126,67 @@
1038 main_grid.attach (color_label, 0, 2, 1, 1);
1039 main_grid.attach (color_button, 1, 2, 1, 1);
1040 main_grid.attach (check_button, 1, 3, 1, 1);
1041-
1042- general_grid.attach (main_grid, 0, 0, 2, 1);
1043- general_grid.attach (buttonbox, 0, 1, 2, 1);
1044-
1045- this.add (general_grid);
1046-
1047+
1048+ attach (main_grid, 0, 0, 2, 1);
1049+
1050+ var fake_label = new Gtk.Grid ();
1051+ fake_label.expand = true;
1052+ attach (fake_label, 0, 1, 2, 1);
1053+ attach (buttonbox, 0, 2, 2, 1);
1054+
1055 show_all ();
1056 }
1057
1058+ public void set_source (E.Source? source = null) {
1059+ this.source = source;
1060+ if (source == null) {
1061+ event_type = EventType.ADD;
1062+ name_entry.text = "";
1063+ type_combobox.sensitive = true;
1064+ create_button.set_label (_("Create Calendar"));
1065+ var rgba = Gdk.RGBA ();
1066+ rgba.red = 0.13;
1067+ rgba.green = 0.42;
1068+ rgba.blue = 0.70;
1069+ color_button.set_rgba (rgba);
1070+ } else {
1071+ create_button.set_label (_("Save"));
1072+ name_entry.text = source.display_name;
1073+ type_combobox.sensitive = false;
1074+ var cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);
1075+ var rgba = Gdk.RGBA ();
1076+ rgba.parse (cal.dup_color ());
1077+ color_button.set_rgba (rgba);
1078+ list_store.foreach (tree_foreach);
1079+ }
1080+ }
1081+
1082+ private bool tree_foreach (Gtk.TreeModel model, Gtk.TreePath path, Gtk.TreeIter iter) {
1083+ GLib.Value backend;
1084+ list_store.get_value (iter, 1, out backend);
1085+ var current_backend = ((Backend)backend);
1086+ if (current_backend.get_uid () == source.dup_parent ()) {
1087+ type_combobox.set_active_iter (iter);
1088+ return true;
1089+ }
1090+
1091+ return false;
1092+ }
1093+
1094 private void remove_backend_widgets () {
1095 if (backend_widgets == null)
1096 return;
1097+
1098 foreach (var widget in backend_widgets) {
1099 widget.widget.hide ();
1100+ widget.widget.destroy ();
1101 }
1102+
1103 backend_widgets.clear ();
1104 }
1105-
1106+
1107 private void add_backend_widgets () {
1108+ widgets_checked.clear ();
1109 foreach (var widget in backend_widgets) {
1110 main_grid.attach (widget.widget, widget.column, 4 + widget.row, 1, 1);
1111 if (widget.needed == true && widget.widget is Gtk.Entry) {
1112@@ -200,39 +198,33 @@
1113 }
1114 check_can_validate ();
1115 }
1116-
1117+
1118 private void entry_changed (PlacementWidget widget) {
1119 widgets_checked.unset (widget.ref_name);
1120- widgets_checked.set (widget.ref_name, ((Gtk.Entry)widget.widget).text != "");
1121+ widgets_checked.set (widget.ref_name, ((Gtk.Entry)widget.widget).text.chug ().char_count () > 0);
1122 check_can_validate ();
1123 }
1124-
1125+
1126 private void check_can_validate () {
1127- bool result = true;
1128 foreach (var valid in widgets_checked.values) {
1129 if (valid == false) {
1130- result = false;
1131- break;
1132+ create_button.sensitive = false;
1133+ return;
1134 }
1135 }
1136- if (result == true && name_entry.text != "") {
1137+
1138+ if (name_entry.text != "") {
1139 create_button.sensitive = true;
1140- } else {
1141- create_button.sensitive = false;
1142 }
1143 }
1144
1145- //--- Public Methods ---//
1146-
1147-
1148 public void save () {
1149-
1150 if (event_type == EventType.ADD) {
1151 current_backend.add_new_calendar (name_entry.text, Util.get_hexa_color (color_button.rgba), set_as_default, backend_widgets);
1152- this.destroy();
1153+ go_back ();
1154 } else {
1155 current_backend.modify_calendar (name_entry.text, Util.get_hexa_color (color_button.rgba), set_as_default, backend_widgets, source);
1156- this.destroy();
1157+ go_back ();
1158 }
1159 }
1160-}
1161+}
1162\ No newline at end of file
1163
1164=== added file 'src/View/SourceItem.vala'
1165--- src/View/SourceItem.vala 1970-01-01 00:00:00 +0000
1166+++ src/View/SourceItem.vala 2014-01-18 21:06:28 +0000
1167@@ -0,0 +1,210 @@
1168+// This program is free software: you can redistribute it and/or modify
1169+// it under the terms of the GNU General Public License as published by
1170+// the Free Software Foundation, either version 3 of the License, or
1171+// (at your option) any later version.
1172+//
1173+// This program is distributed in the hope that it will be useful,
1174+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1175+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1176+// GNU General Public License for more details.
1177+//
1178+// You should have received a copy of the GNU General Public License
1179+// along with this program. If not, see <http://www.gnu.org/licenses/>.
1180+//
1181+
1182+public class Maya.View.SourceItem : Gtk.EventBox {
1183+ private E.Source source;
1184+
1185+ private Gtk.Revealer revealer;
1186+ private Gtk.Revealer info_revealer;
1187+ private Model.CalendarModel calmodel;
1188+ private Gtk.Grid main_grid;
1189+
1190+ private Gtk.Button delete_button;
1191+ private Gtk.Button edit_button;
1192+
1193+ private Gtk.Label calendar_name_label;
1194+ private Gtk.Label backend_label;
1195+ private Gtk.Label calendar_color_label;
1196+ private Gtk.CheckButton visible_checkbutton;
1197+
1198+ public signal void remove_request (E.Source source);
1199+ public signal void edit_request (E.Source source);
1200+
1201+ public SourceItem (E.Source source, Model.CalendarModel calmodel) {
1202+ this.source = source;
1203+ this.calmodel = calmodel;
1204+
1205+ main_grid = new Gtk.Grid ();
1206+
1207+ // Source widget
1208+ E.SourceCalendar cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);
1209+ revealer = new Gtk.Revealer ();
1210+ revealer.set_reveal_child (true);
1211+
1212+ var revealer_grid = new Gtk.Grid ();
1213+ revealer_grid.column_spacing = 6;
1214+ revealer_grid.row_spacing = 12;
1215+
1216+ calendar_name_label = new Gtk.Label (source.dup_display_name ());
1217+ calendar_name_label.set_markup ("<b>%s</b>".printf (GLib.Markup.escape_text (source.dup_display_name ())));
1218+ calendar_name_label.xalign = 0;
1219+
1220+ Maya.Backend selected_backend = null;
1221+ foreach (var backend in backends_manager.backends) {
1222+ if (source.dup_parent () == backend.get_uid ()) {
1223+ selected_backend = backend;
1224+ break;
1225+ }
1226+ }
1227+
1228+ if (selected_backend == null) {
1229+ backend_label = new Gtk.Label ("");
1230+ } else {
1231+ backend_label = new Gtk.Label (selected_backend.get_name ());
1232+ }
1233+
1234+ backend_label.hexpand = true;
1235+ backend_label.xalign = 0;
1236+
1237+ calendar_color_label = new Gtk.Label (" ");
1238+ var color = Gdk.RGBA ();
1239+ color.parse (cal.dup_color());
1240+ calendar_color_label.override_background_color (Gtk.StateFlags.NORMAL, color);
1241+
1242+ visible_checkbutton = new Gtk.CheckButton ();
1243+ visible_checkbutton.active = cal.selected;
1244+ visible_checkbutton.toggled.connect (() => {
1245+ if (visible_checkbutton.active == true) {
1246+ calmodel.add_source (source);
1247+ } else {
1248+ calmodel.remove_source (source);
1249+ }
1250+
1251+ cal.set_selected (visible_checkbutton.active);
1252+ try {
1253+ source.write_sync ();
1254+ } catch (GLib.Error error) {
1255+ critical (error.message);
1256+ }
1257+ });
1258+
1259+ delete_button = new Gtk.Button.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.MENU);
1260+ delete_button.set_tooltip_text (_("Remove"));
1261+ delete_button.clicked.connect (() => {remove_request (source);});
1262+ delete_button.relief = Gtk.ReliefStyle.NONE;
1263+ delete_button.no_show_all = true;
1264+
1265+ edit_button = new Gtk.Button.from_icon_name ("document-properties-symbolic", Gtk.IconSize.MENU);
1266+ edit_button.set_tooltip_text (_("Edit…"));
1267+ edit_button.clicked.connect (() => {edit_request (source);});
1268+ edit_button.relief = Gtk.ReliefStyle.NONE;
1269+ edit_button.no_show_all = true;
1270+
1271+ revealer_grid.attach (visible_checkbutton, 0, 0, 1, 2);
1272+ revealer_grid.attach (calendar_color_label, 1, 0, 1, 2);
1273+ revealer_grid.attach (calendar_name_label, 2, 0, 1, 1);
1274+ revealer_grid.attach (backend_label, 3, 0, 1, 1);
1275+ revealer_grid.attach (delete_button, 4, 0, 1, 2);
1276+ revealer_grid.attach (edit_button, 5, 0, 1, 2);
1277+
1278+ revealer.add (revealer_grid);
1279+
1280+ // Info bar
1281+ info_revealer = new Gtk.Revealer ();
1282+ info_revealer.no_show_all = true;
1283+ var info_revealer_grid = new Gtk.Grid ();
1284+ info_revealer_grid.column_spacing = 6;
1285+ info_revealer_grid.row_spacing = 12;
1286+ info_revealer.add (info_revealer_grid);
1287+ var undo_button = new Gtk.Button.with_label (_("Undo"));
1288+ undo_button.clicked.connect (() => {
1289+ revealer.show ();
1290+ calmodel.restore_calendar ();
1291+ revealer.set_reveal_child (true);
1292+ info_revealer.set_reveal_child (false);
1293+ info_revealer.hide ();
1294+ });
1295+
1296+ var close_button = new Gtk.Button.from_icon_name ("window-close-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
1297+ close_button.relief = Gtk.ReliefStyle.NONE;
1298+ close_button.clicked.connect (() => {
1299+ info_revealer.set_reveal_child (false);
1300+ info_revealer.hide ();
1301+ hide ();
1302+ destroy ();
1303+ });
1304+
1305+ var message_label = new Gtk.Label (_("Calendar \"%s\" removed.").printf (source.display_name));
1306+ message_label.hexpand = true;
1307+ message_label.xalign = 0;
1308+ info_revealer_grid.attach (message_label, 0, 0, 1, 1);
1309+ info_revealer_grid.attach (undo_button, 1, 0, 1, 1);
1310+ info_revealer_grid.attach (close_button, 2, 0, 1, 1);
1311+
1312+ main_grid.attach (info_revealer, 0, 0, 1, 1);
1313+ main_grid.attach (revealer, 0, 1, 1, 1);
1314+ add (main_grid);
1315+
1316+ add_events (Gdk.EventMask.ENTER_NOTIFY_MASK|Gdk.EventMask.LEAVE_NOTIFY_MASK);
1317+ enter_notify_event.connect ((event) => {
1318+ delete_button.visible = true;
1319+ edit_button.visible = true;
1320+ return false;
1321+ });
1322+
1323+ leave_notify_event.connect_after ((event) => {
1324+ delete_button.visible = false;
1325+ edit_button.visible = false;
1326+ return false;
1327+ });
1328+ }
1329+
1330+ // We need a custom one because the buttons are hidden if the calendar is not shown.
1331+ public override void get_preferred_width (out int minimum_width, out int natural_width) {
1332+ base.get_preferred_width (out minimum_width, out natural_width);
1333+ if (visible == false)
1334+ return;
1335+
1336+ int total_natural_width = 0;
1337+ int _minimum_width;
1338+ int _natural_width;
1339+ if (edit_button.visible == false && info_revealer.visible == false) {
1340+ edit_button.show ();
1341+ edit_button.get_preferred_width (out _minimum_width, out _natural_width);
1342+ edit_button.hide ();
1343+ // +6 because the grid has a 6px margin between every columns
1344+ total_natural_width = total_natural_width + _natural_width + 6;
1345+ }
1346+
1347+ if (delete_button.visible == false && info_revealer.visible == false) {
1348+ delete_button.show ();
1349+ delete_button.get_preferred_width (out _minimum_width, out _natural_width);
1350+ delete_button.hide ();
1351+ // +6 because the grid has a 6px margin between every columns
1352+ total_natural_width = total_natural_width + _natural_width + 6;
1353+ }
1354+
1355+ minimum_width = minimum_width + total_natural_width;
1356+ natural_width = natural_width + total_natural_width;
1357+ }
1358+
1359+ public void source_has_changed () {
1360+ calendar_name_label.set_markup ("<b>%s</b>".printf (GLib.Markup.escape_text (source.dup_display_name ())));
1361+ E.SourceCalendar cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);
1362+
1363+ var color = Gdk.RGBA ();
1364+ color.parse (cal.dup_color());
1365+ calendar_color_label.override_background_color (Gtk.StateFlags.NORMAL, color);
1366+
1367+ visible_checkbutton.active = cal.selected;
1368+ }
1369+
1370+ public void show_calendar_removed () {
1371+ info_revealer.no_show_all = false;
1372+ info_revealer.show_all ();
1373+ revealer.set_reveal_child (false);
1374+ revealer.hide ();
1375+ info_revealer.set_reveal_child (true);
1376+ }
1377+}
1378\ No newline at end of file
1379
1380=== modified file 'src/View/SourceSelector.vala'
1381--- src/View/SourceSelector.vala 2013-09-01 23:22:22 +0000
1382+++ src/View/SourceSelector.vala 2014-01-18 21:06:28 +0000
1383@@ -14,131 +14,47 @@
1384
1385 public class Maya.View.SourceSelector : Granite.Widgets.PopOver {
1386
1387- private Gtk.TreeStore tree_store;
1388- private Gtk.TreeView tree_view;
1389- private Gee.HashMap<string, Gtk.TreeIter?> iter_map;
1390- private Gtk.TreeIter default_iter;
1391-
1392- private Gtk.ToolButton remove_button;
1393- private Gtk.ToolButton edit_button;
1394-
1395- private enum Columns {
1396- TOGGLE,
1397- TEXT,
1398- COLOR,
1399- SOURCE,
1400- VISIBLE,
1401- N_COLUMNS
1402- }
1403-
1404- public SourceSelector () {
1405-
1406- var main_grid = new Gtk.Grid ();
1407-
1408- tree_store = new Gtk.TreeStore (Columns.N_COLUMNS, typeof (bool), typeof (string), typeof (string), typeof (E.Source), typeof (bool));
1409- tree_view = new Gtk.TreeView.with_model (tree_store);
1410- iter_map = new Gee.HashMap<string, Gtk.TreeIter?>();
1411-
1412- var toggle = new Gtk.CellRendererToggle ();
1413- toggle.toggled.connect ((toggle, path) => {
1414- var tree_path = new Gtk.TreePath.from_string (path);
1415- Gtk.TreeIter iter;
1416- tree_store.get_iter (out iter, tree_path);
1417- tree_store.set (iter, Columns.TOGGLE, !toggle.active);
1418- GLib.Value src;
1419- tree_store.get_value (iter, 3, out src);
1420- E.SourceCalendar cal = (E.SourceCalendar)((E.Source)src).get_extension (E.SOURCE_EXTENSION_CALENDAR);
1421- if (!cal.selected == true) {
1422- app.calmodel.add_source ((E.Source)src);
1423- } else {
1424- app.calmodel.remove_source ((E.Source)src);
1425- }
1426- cal.set_selected (!cal.selected);
1427- try {
1428- ((E.Source)src).write_sync ();
1429- } catch (GLib.Error error) {
1430- critical (error.message);
1431- }
1432- });
1433-
1434- var text = new Gtk.CellRendererText ();
1435- var column = new Gtk.TreeViewColumn ();
1436- column.pack_start (text, true);
1437- column.add_attribute (text, "text", Columns.TEXT);
1438- column.add_attribute (text, "cell_background", Columns.COLOR);
1439- tree_view.append_column (column);
1440-
1441- column = new Gtk.TreeViewColumn ();
1442- column.pack_start (toggle, false);
1443- column.add_attribute (toggle, "active", Columns.TOGGLE);
1444- column.add_attribute (toggle, "cell_background", Columns.COLOR);
1445- column.add_attribute (toggle, "visible", Columns.VISIBLE);
1446- tree_view.append_column (column);
1447-
1448- tree_view.set_headers_visible (false);
1449-
1450- var backend_map = new Gee.HashMap<string, Gtk.TreeIter?>();
1451+ private Gee.HashMap<string, SourceItem?> src_map;
1452+
1453+ private Model.CalendarModel calmodel;
1454+
1455+ private Gtk.Stack stack;
1456+ private SourceDialog src_dialog = null;
1457+
1458+ private Gtk.Grid main_grid;
1459+ private Gtk.Grid calendar_grid;
1460+ private int calendar_index = 0;
1461+ private Gtk.ScrolledWindow scroll;
1462+ private E.SourceRegistry registry;
1463+
1464+ public SourceSelector (Model.CalendarModel calmodel) {
1465+
1466+ this.calmodel = calmodel;
1467+
1468+ stack = new Gtk.Stack ();
1469+
1470+ calendar_grid = new Gtk.Grid ();
1471+ calendar_grid.row_spacing = 12;
1472+ calendar_grid.margin_left = 6;
1473+ calendar_grid.margin_right = 6;
1474+
1475+ scroll = new Gtk.ScrolledWindow (null, null);
1476+ scroll.hscrollbar_policy = Gtk.PolicyType.NEVER;
1477+ scroll.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
1478+ scroll.expand = true;
1479+ scroll.add (calendar_grid);
1480+
1481+ main_grid = new Gtk.Grid ();
1482+ main_grid.row_spacing = 6;
1483+ main_grid.margin_top = 6;
1484+
1485+ src_map = new Gee.HashMap<string, SourceItem?>();
1486
1487 try {
1488- var registry = new E.SourceRegistry.sync (null);
1489+ registry = new E.SourceRegistry.sync (null);
1490 var sources = registry.list_sources (E.SOURCE_EXTENSION_CALENDAR);
1491- // Do not show sources that are on the trash
1492- foreach (var source in app.calmodel.calendar_trash) {
1493- foreach (var source2 in sources) {
1494- if (source.dup_uid () == source2.dup_uid ()) {
1495- sources.remove (source2);
1496- break;
1497- }
1498- }
1499- }
1500-
1501- var selection = tree_view.get_selection ();
1502- selection.mode = Gtk.SelectionMode.BROWSE;
1503- selection.set_select_function (select_func);
1504-
1505- foreach (var backend in backends_manager.backends) {
1506- Gtk.TreeIter? b_iter = null;
1507- foreach (var src in sources) {
1508- Gtk.TreeIter iter;
1509- if (src.parent == backend.get_uid ()) {
1510- if (b_iter == null) {
1511- tree_store.append (out b_iter, null);
1512- tree_store.set (b_iter, Columns.TEXT, backend.get_name (), Columns.VISIBLE, false);
1513- backend_map.set (backend.get_uid (), b_iter);
1514- }
1515- E.SourceCalendar cal = (E.SourceCalendar)src.get_extension (E.SOURCE_EXTENSION_CALENDAR);
1516- tree_store.append (out iter, b_iter);
1517- tree_store.set (iter, Columns.TOGGLE, cal.selected, Columns.TEXT, src.dup_display_name (),
1518- Columns.COLOR, cal.dup_color(), Columns.SOURCE, src,
1519- Columns.VISIBLE, true);
1520- iter_map.set (src.dup_uid (), iter);
1521- if (src.get_uid() == registry.default_calendar.uid) {
1522- default_iter = iter;
1523- selection.select_iter (iter);
1524- }
1525- }
1526- }
1527- }
1528-
1529- Gtk.TreeIter? other = null;
1530 foreach (var src in sources) {
1531- if (!backend_map.keys.contains (src.parent)) {
1532- if (other == null) {
1533- tree_store.append (out other, null);
1534- tree_store.set (other, Columns.TEXT, _("Other"), Columns.VISIBLE, false);
1535- }
1536- Gtk.TreeIter iter;
1537- E.SourceCalendar cal = (E.SourceCalendar)src.get_extension (E.SOURCE_EXTENSION_CALENDAR);
1538- tree_store.append (out iter, other);
1539- tree_store.set (iter, Columns.TOGGLE, cal.selected, Columns.TEXT, src.dup_display_name (),
1540- Columns.COLOR, cal.dup_color(), Columns.SOURCE, src,
1541- Columns.VISIBLE, true);
1542- iter_map.set (src.dup_uid (), iter);
1543- if (src.get_uid() == registry.default_calendar.uid) {
1544- default_iter = iter;
1545- selection.select_iter (iter);
1546- }
1547- }
1548+ source_added (src);
1549 }
1550
1551 registry.source_removed.connect (source_removed);
1552@@ -150,132 +66,116 @@
1553 critical (error.message);
1554 }
1555
1556- tree_view.expand_all ();
1557-
1558- var scroll = new Gtk.ScrolledWindow (null, null);
1559- scroll.set_size_request (150, 150);
1560- scroll.hscrollbar_policy = Gtk.PolicyType.NEVER;
1561- scroll.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
1562- scroll.shadow_type = Gtk.ShadowType.IN;
1563- scroll.expand = true;
1564- scroll.add (tree_view);
1565-
1566- var toolbar = new Gtk.Toolbar();
1567- toolbar.set_style (Gtk.ToolbarStyle.ICONS);
1568- toolbar.get_style_context ().add_class ("inline-toolbar");
1569- toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);
1570- toolbar.set_show_arrow (false);
1571- toolbar.hexpand = true;
1572-
1573- scroll.get_style_context ().set_junction_sides (Gtk.JunctionSides.BOTTOM);
1574- toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);
1575- toolbar.get_style_context ().set_junction_sides (Gtk.JunctionSides.TOP);
1576-
1577- var add_button = new Gtk.ToolButton (null, _("Add…"));
1578- add_button.set_tooltip_text (_("Add…"));
1579- add_button.set_icon_name ("list-add-symbolic");
1580- add_button.clicked.connect (create_source);
1581-
1582- remove_button = new Gtk.ToolButton (null, _("Remove"));
1583- remove_button.set_tooltip_text (_("Remove"));
1584- remove_button.set_icon_name ("list-remove-symbolic");
1585- remove_button.clicked.connect (remove_source);
1586- remove_button.sensitive = false;
1587-
1588- edit_button = new Gtk.ToolButton (null, _("Edit…"));
1589- edit_button.set_tooltip_text (_("Edit…"));
1590- edit_button.set_icon_name ("document-properties-symbolic");
1591- edit_button.clicked.connect (edit_source);
1592- edit_button.sensitive = false;
1593-
1594- toolbar.insert (add_button, -1);
1595- toolbar.insert (remove_button, -1);
1596- toolbar.insert (edit_button, -1);
1597+ var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
1598+ separator.hexpand = true;
1599+
1600+ var add_calendar_button = new Gtk.Button.with_label (_("Add New Calendar…"));
1601+ add_calendar_button.relief = Gtk.ReliefStyle.NONE;
1602+ add_calendar_button.hexpand = true;
1603+ add_calendar_button.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM);
1604+ add_calendar_button.get_style_context ().remove_class (Gtk.STYLE_CLASS_BUTTON);
1605+ add_calendar_button.clicked.connect (create_source);
1606+
1607+ var add_calendar_grid = new Gtk.Grid ();
1608+ add_calendar_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_MENU);
1609+ add_calendar_grid.attach (add_calendar_button, 0, 0, 1, 1);
1610+
1611+ main_grid.attach (scroll, 0, 0, 1, 1);
1612+ main_grid.attach (separator, 0, 1, 1, 1);
1613+ main_grid.attach (add_calendar_grid, 0, 2, 1, 1);
1614+
1615+ stack.add_named (main_grid, "main");
1616
1617 var container = (Gtk.Container) get_content_area ();
1618- container.add (main_grid);
1619- main_grid.attach (scroll, 0, 0, 1, 1);
1620- main_grid.attach (toolbar, 0, 1, 1, 1);
1621- }
1622-
1623- private bool select_func (Gtk.TreeSelection selection, Gtk.TreeModel model,
1624- Gtk.TreePath path, bool path_currently_selected) {
1625- bool selectable = true;
1626- Gtk.TreeIter iter;
1627- tree_store.get_iter (out iter, path);
1628-
1629- if (tree_store.iter_has_child (iter)) {
1630- selectable = false;
1631- } else {
1632- activate_buttons ();
1633- }
1634-
1635- return selectable;
1636- }
1637-
1638- private void activate_buttons () {
1639- edit_button.sensitive = true;
1640- remove_button.sensitive = true;
1641+ container.margin_right = container.margin_right - 5;
1642+ container.margin_left = container.margin_left - 5;
1643+ container.add (stack);
1644+ main_grid.show_all ();
1645 }
1646
1647 private void source_removed (E.Source source) {
1648- if (iter_map.has_key (source.dup_uid ())) {
1649- var iter = iter_map.get (source.dup_uid ());
1650- tree_store.remove (ref iter);
1651- iter_map.unset (source.dup_uid (), null);
1652- }
1653+ var source_item = src_map.get (source.dup_uid ());
1654+ source_item.hide ();
1655+ src_map.unset (source.dup_uid ());
1656+ source_item.destroy ();
1657 }
1658
1659 private void source_added (E.Source source) {
1660- Gtk.TreeIter iter;
1661- E.SourceCalendar cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);
1662- tree_store.append (out iter, null);
1663- tree_store.set (iter, Columns.TOGGLE, cal.selected, Columns.TEXT, source.dup_display_name ());
1664- iter_map.set (source.dup_uid (), iter);
1665+ var source_item = new SourceItem (source, calmodel);
1666+ source_item.edit_request.connect (edit_source);
1667+ source_item.remove_request.connect (remove_source);
1668+
1669+ calendar_grid.attach (source_item, 0, calendar_index, 1, 1);
1670+ int minimum_height;
1671+ int natural_height;
1672+ calendar_index++;
1673+ calendar_grid.show_all ();
1674+ calendar_grid.get_preferred_height (out minimum_height, out natural_height);
1675+ if (natural_height > 150) {
1676+ scroll.set_size_request (-1, 150);
1677+ } else {
1678+ scroll.set_size_request (-1, natural_height);
1679+ }
1680+
1681+ src_map.set (source.dup_uid (), source_item);
1682+
1683 }
1684
1685 private void source_disabled (E.Source source) {
1686-
1687+ var source_item = src_map.get (source.dup_uid ());
1688+ source_item.source_has_changed ();
1689 }
1690
1691 private void source_enabled (E.Source source) {
1692-
1693+ var source_item = src_map.get (source.dup_uid ());
1694+ source_item.source_has_changed ();
1695 }
1696
1697 private void source_changed (E.Source source) {
1698-
1699+ var source_item = src_map.get (source.dup_uid ());
1700+ source_item.source_has_changed ();
1701 }
1702
1703 private void create_source () {
1704- var dialog = new SourceDialog ();
1705- this.hide ();
1706- dialog.present ();
1707- }
1708-
1709- private void remove_source () {
1710- var selection = tree_view.get_selection ();
1711- Gtk.TreeModel model;
1712- Gtk.TreeIter iter;
1713- selection.get_selected (out model, out iter);
1714- GLib.Value src;
1715- tree_store.get_value (iter, 3, out src);
1716- var source = src as E.Source;
1717- app.calmodel.delete_calendar (source);
1718- app.show_calendar_removed (source.display_name);
1719- this.hide ();
1720- }
1721-
1722- private void edit_source () {
1723- var selection = tree_view.get_selection ();
1724- Gtk.TreeModel model;
1725- Gtk.TreeIter iter;
1726- selection.get_selected (out model, out iter);
1727- GLib.Value src;
1728- tree_store.get_value (iter, 3, out src);
1729- var source = src as E.Source;
1730- var dialog = new SourceDialog (source);
1731- this.hide ();
1732- dialog.present ();
1733- }
1734-
1735-}
1736+ if (src_dialog == null) {
1737+ src_dialog = new SourceDialog ();
1738+ src_dialog.go_back.connect (() => {switch_to_main ();});
1739+ stack.add_named (src_dialog, "source");
1740+ }
1741+ src_dialog.set_source (null);
1742+ switch_to_source ();
1743+ }
1744+
1745+ private void remove_source (E.Source source) {
1746+ calmodel.delete_calendar (source);
1747+ var source_item = src_map.get (source.dup_uid ());
1748+ source_item.show_calendar_removed ();
1749+ }
1750+
1751+ private void edit_source (E.Source source) {
1752+ if (src_dialog == null) {
1753+ src_dialog = new SourceDialog ();
1754+ src_dialog.go_back.connect (() => {switch_to_main ();});
1755+ stack.add_named (src_dialog, "source");
1756+ }
1757+ src_dialog.set_source (source);
1758+ switch_to_source ();
1759+ }
1760+
1761+ private void switch_to_main () {
1762+ main_grid.no_show_all = false;
1763+ main_grid.show ();
1764+ stack.set_visible_child_full ("main", Gtk.StackTransitionType.SLIDE_RIGHT);
1765+ src_dialog.hide ();
1766+ src_dialog.no_show_all = true;
1767+ }
1768+
1769+ private void switch_to_source () {
1770+ src_dialog.no_show_all = false;
1771+ src_dialog.show ();
1772+ stack.set_visible_child_full ("source", Gtk.StackTransitionType.SLIDE_LEFT);
1773+ main_grid.hide ();
1774+ main_grid.no_show_all = true;
1775+ }
1776+
1777+}
1778\ No newline at end of file
1779
1780=== modified file 'src/View/Widgets/Postler/FlowBox.vala'
1781--- src/View/Widgets/Postler/FlowBox.vala 2013-11-14 18:05:39 +0000
1782+++ src/View/Widgets/Postler/FlowBox.vala 2014-01-18 21:06:28 +0000
1783@@ -11,17 +11,18 @@
1784
1785 namespace Maya.View.Widgets {
1786 public class FlowBox : Gtk.Container {
1787- List<Gtk.Widget> children;
1788+ Gee.LinkedList<Gtk.Widget> children;
1789 int last_row_count;
1790 int last_row_height;
1791
1792 public FlowBox () {
1793+ children = new Gee.LinkedList<Gtk.Widget> ();
1794 set_has_window (false);
1795 set_resize_mode (Gtk.ResizeMode.QUEUE);
1796 }
1797
1798 public override void add (Gtk.Widget widget) {
1799- children.append (widget);
1800+ children.add (widget);
1801 widget.set_parent (this);
1802 if (get_realized ())
1803 widget.realize ();
1804@@ -42,9 +43,9 @@
1805 callback (child);
1806 }
1807
1808- public void reorder_child (Gtk.Widget widget, int position) {
1809+ public void add_child (Gtk.Widget widget) {
1810 children.remove (widget);
1811- children.insert (widget, position);
1812+ children.add (widget);
1813 queue_resize ();
1814 }
1815
1816@@ -115,4 +116,4 @@
1817 }
1818
1819 }
1820-}
1821+}
1822\ No newline at end of file
1823
1824=== modified file 'src/View/Widgets/Postler/GuestEntry.vala'
1825--- src/View/Widgets/Postler/GuestEntry.vala 2013-08-31 15:14:02 +0000
1826+++ src/View/Widgets/Postler/GuestEntry.vala 2014-01-18 21:06:28 +0000
1827@@ -139,7 +139,7 @@
1828 });
1829 button.show_all ();
1830 add (button);
1831- reorder_child (entry, -1);
1832+ add_child (entry);
1833 empty = false;
1834 }
1835
1836@@ -188,4 +188,4 @@
1837 }
1838 }
1839 }
1840-}
1841+}
1842\ No newline at end of file
1843
1844=== modified file 'src/config.vala.cmake'
1845--- src/config.vala.cmake 2013-08-29 17:04:35 +0000
1846+++ src/config.vala.cmake 2014-01-18 21:06:28 +0000
1847@@ -6,4 +6,5 @@
1848 public const string RELEASE_NAME = "@RELEASE_NAME@";
1849 public const string VERSION = "@VERSION@";
1850 public const string VERSION_INFO = "@VERSION_INFO@";
1851+ public const string APP_NAME = "@APP_NAME@";
1852 }

Subscribers

People subscribed via source and target branches