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

Proposed by Corentin Noël
Status: Merged
Approved by: Corentin Noël
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
Danielle Foré Approve
Cody Garver (community) Needs Fixing
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.
Revision history for this message
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
Revision history for this message
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
Revision history for this message
Danielle Foré (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
Revision history for this message
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
498. By Corentin Noël

Fixed the year switcher and the calendar icon

Revision history for this message
Danielle Foré (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
499. By Corentin Noël

New Source seletion popover

Revision history for this message
Danielle Foré (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 &

Revision history for this message
Danielle Foré (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
Revision history for this message
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.

Revision history for this message
Danielle Foré (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
500. By Corentin Noël

Fixed the popover

501. By Corentin Noël

Fixed some wrong behaviors

Revision history for this message
Danielle Foré (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
502. By Corentin Noël

Fixed the markup parsing

Revision history for this message
Danielle Foré (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
Revision history for this message
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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-12-09 11:43:54 +0000
+++ CMakeLists.txt 2014-01-18 21:06:28 +0000
@@ -7,14 +7,16 @@
7#7#
8# Base bits8# Base bits
9#9#
10set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")10include (GNUInstallDirs)
11set (PKGDATADIR "${DATADIR}/maya-calendar")11set (DATADIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}")
12set (SRC_TARGET ${CMAKE_PROJECT_NAME}-calendar)
13set (PKGDATADIR "${DATADIR}/${SRC_TARGET}")
12set (GETTEXT_PACKAGE "maya")14set (GETTEXT_PACKAGE "maya")
15set (APP_NAME "Maya")
13set (RELEASE_NAME "Fast and connected.")16set (RELEASE_NAME "Fast and connected.")
14set (VERSION "0.2.2")17set (VERSION "0.2.2")
15set (VERSION_INFO "Release")18set (VERSION_INFO "Release")
16set (SRC_TARGET ${CMAKE_PROJECT_NAME}-calendar)19set (PLUGIN_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_PROJECT_NAME}/plugins)
17set (PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_PROJECT_NAME}/plugins)
1820
19list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)21list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
20add_definitions ("-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\"")22add_definitions ("-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\"")
@@ -61,7 +63,7 @@
61file (GLOB _datafiles "${CMAKE_CURRENT_SOURCE_DIR}/data/style/*")63file (GLOB _datafiles "${CMAKE_CURRENT_SOURCE_DIR}/data/style/*")
62install (FILES ${_datafiles} DESTINATION ${PKGDATADIR}/style)64install (FILES ${_datafiles} DESTINATION ${PKGDATADIR}/style)
6365
64install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/maya-calendar.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications")66install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/${SRC_TARGET}.desktop DESTINATION "${DATADIR}/applications")
6567
66#68#
67# i18n69# i18n
@@ -92,7 +94,7 @@
92 glib-2.094 glib-2.0
93 gio-2.095 gio-2.0
94 gee-1.096 gee-1.0
95 gtk+-3.097 gtk+-3.0>=3.10
96 granite98 granite
97 libecal-1.2>=3.8.099 libecal-1.2>=3.8.0
98 libical100 libical
@@ -112,9 +114,9 @@
112114
113find_package (Vala REQUIRED)115find_package (Vala REQUIRED)
114include (ValaVersion)116include (ValaVersion)
115ensure_vala_version ("0.18.0" MINIMUM)117ensure_vala_version ("0.22.0" MINIMUM)
116include (ValaPrecompile)118include (ValaPrecompile)
117119
118add_subdirectory (src)120add_subdirectory (src)
119add_subdirectory (plugins)121add_subdirectory (plugins)
120add_subdirectory (schemas)122add_subdirectory (schemas)
121\ No newline at end of file123\ No newline at end of file
122124
=== modified file 'cmake/Translations.cmake' (properties changed: -x to +x)
--- cmake/Translations.cmake 2013-05-09 20:32:54 +0000
+++ cmake/Translations.cmake 2014-01-18 21:06:28 +0000
@@ -20,47 +20,23 @@
20 add_custom_target (pot COMMENT “Building translation catalog.”)20 add_custom_target (pot COMMENT “Building translation catalog.”)
21 find_program (XGETTEXT_EXECUTABLE xgettext)21 find_program (XGETTEXT_EXECUTABLE xgettext)
2222
23
23 set(C_SOURCE "")24 set(C_SOURCE "")
24 set(VALA_SOURCE "")
25 set(GLADE_SOURCE "")
2625
27 foreach(FILES_INPUT ${ARGN})26 foreach(FILES_INPUT ${ARGN})
28 set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT})27 file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.c)
2928 foreach(C_FILE ${SOURCE_FILES})
30 file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.c)29 set(C_SOURCE ${C_SOURCE} ${C_FILE})
31 foreach(C_FILE ${SOURCE_FILES})30 endforeach()
32 set(C_SOURCE ${C_SOURCE} ${C_FILE})31 file (GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}/*.vala)
33 endforeach()32 foreach(C_FILE ${SOURCE_FILES})
3433 set(C_SOURCE ${C_SOURCE} ${C_FILE})
35 file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.vala)
36 foreach(VALA_C_FILE ${SOURCE_FILES})
37 set(VALA_SOURCE ${VALA_SOURCE} ${VALA_C_FILE})
38 endforeach()
39
40 file (GLOB_RECURSE SOURCE_FILES ${BASE_DIRECTORY}/*.ui)
41 foreach(GLADE_C_FILE ${SOURCE_FILES})
42 set(GLADE_SOURCE ${GLADE_SOURCE} ${GLADE_C_FILE})
43 endforeach()34 endforeach()
44 endforeach()35 endforeach()
4536
46 set(BASE_XGETTEXT_COMMAND37 add_custom_command (TARGET pot COMMAND
47 ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE}38 ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
48 -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot39 ${VALA_SOURCE} ${C_SOURCE} --add-comments="/" --keyword="_" --keyword="N_" --keyword="C_:1c,2"
49 --keyword="_" --keyword="N_" --from-code=UTF-8)40 --keyword="NC_:1c,2" --keyword="ngettext:1,2" --keyword="N_" --keyword="Q_:1g" --from-code=UTF-8
5041 )
51 set(CONTINUE_FLAG "")
52
53 IF(NOT "${C_SOURCE}" STREQUAL "")
54 add_custom_command(TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE})
55 set(CONTINUE_FLAG "-j")
56 ENDIF()
57
58 IF(NOT "${VALA_SOURCE}" STREQUAL "")
59 add_custom_command(TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LC\# ${VALA_SOURCE})
60 set(CONTINUE_FLAG "-j")
61 ENDIF()
62
63 IF(NOT "${GLADE_SOURCE}" STREQUAL "")
64 add_custom_command (TARGET pot COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LGlade ${GLADE_SOURCE})
65 ENDIF()
66endmacro()42endmacro()
6743
=== modified file 'cmake/ValaPrecompile.cmake'
--- cmake/ValaPrecompile.cmake 2013-05-01 23:46:37 +0000
+++ cmake/ValaPrecompile.cmake 2014-01-18 21:06:28 +0000
@@ -185,10 +185,21 @@
185 endif(ARGS_GENERATE_HEADER)185 endif(ARGS_GENERATE_HEADER)
186186
187 set(gir_arguments "")187 set(gir_arguments "")
188 set(gircomp_command "")
188 if(ARGS_GENERATE_GIR)189 if(ARGS_GENERATE_GIR)
189 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir")190 list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir")
190 list(APPEND out_files_display "${ARGS_GENERATE_GIR}.gir")191 list(APPEND out_files_display "${ARGS_GENERATE_GIR}.gir")
191 set(gir_arguments "--gir=${ARGS_GENERATE_GIR}.gir")192 set(gir_arguments "--gir=${ARGS_GENERATE_GIR}.gir")
193
194 include (FindGirCompiler)
195 find_package(GirCompiler REQUIRED)
196
197 set(gircomp_command
198 COMMAND
199 ${G_IR_COMPILER_EXECUTABLE}
200 ARGS
201 "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir"
202 -o "${DIRECTORY}/${ARGS_GENERATE_GIR}.typelib")
192 endif(ARGS_GENERATE_GIR)203 endif(ARGS_GENERATE_GIR)
193204
194 set(symbols_arguments "")205 set(symbols_arguments "")
@@ -201,7 +212,7 @@
201 # Workaround for a bug that would make valac run twice. This file is written212 # Workaround for a bug that would make valac run twice. This file is written
202 # after the vala compiler generates C source code.213 # after the vala compiler generates C source code.
203 set(OUTPUT_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_valac.stamp)214 set(OUTPUT_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_valac.stamp)
204215
205 add_custom_command(216 add_custom_command(
206 OUTPUT217 OUTPUT
207 ${OUTPUT_STAMP}218 ${OUTPUT_STAMP}
@@ -228,6 +239,7 @@
228 ${ARGS_CUSTOM_VAPIS}239 ${ARGS_CUSTOM_VAPIS}
229 COMMENT240 COMMENT
230 "Generating ${out_files_display}"241 "Generating ${out_files_display}"
242 ${gircomp_command}
231 )243 )
232244
233 # This command will be run twice for some reason (pass a non-empty string to COMMENT245 # This command will be run twice for some reason (pass a non-empty string to COMMENT
234246
=== modified file 'plugins/CalDAV/CalDAV.vala'
--- plugins/CalDAV/CalDAV.vala 2013-11-14 18:20:10 +0000
+++ plugins/CalDAV/CalDAV.vala 2014-01-18 21:06:28 +0000
@@ -57,4 +57,4 @@
57 var objmodule = module as Peas.ObjectModule;57 var objmodule = module as Peas.ObjectModule;
58 objmodule.register_extension_type (typeof (Peas.Activatable),58 objmodule.register_extension_type (typeof (Peas.Activatable),
59 typeof (Maya.Plugins.CalDAVPlugin));59 typeof (Maya.Plugins.CalDAVPlugin));
60}60}
61\ No newline at end of file61\ No newline at end of file
6262
=== modified file 'plugins/CalDAV/CalDAVBackend.vala'
--- plugins/CalDAV/CalDAVBackend.vala 2013-11-14 18:20:10 +0000
+++ plugins/CalDAV/CalDAVBackend.vala 2014-01-18 21:06:28 +0000
@@ -148,7 +148,7 @@
148 var list = new List<E.Source> ();148 var list = new List<E.Source> ();
149 list.append (new_source);149 list.append (new_source);
150 registry.create_sources_sync (list);150 registry.create_sources_sync (list);
151 app.calmodel.add_source (new_source);151 ((Maya.Application)GLib.Application.get_default ()).calmodel.add_source (new_source);
152 if (set_default) {152 if (set_default) {
153 registry.default_calendar = new_source;153 registry.default_calendar = new_source;
154 }154 }
@@ -190,4 +190,4 @@
190 critical (error.message);190 critical (error.message);
191 }191 }
192 }192 }
193}193}
194\ No newline at end of file194\ No newline at end of file
195195
=== modified file 'plugins/Google/GoogleBackend.vala'
--- plugins/Google/GoogleBackend.vala 2013-11-14 18:20:10 +0000
+++ plugins/Google/GoogleBackend.vala 2014-01-18 21:06:28 +0000
@@ -89,7 +89,7 @@
89 var list = new List<E.Source> ();89 var list = new List<E.Source> ();
90 list.append (new_source);90 list.append (new_source);
91 registry.create_sources_sync (list);91 registry.create_sources_sync (list);
92 app.calmodel.add_source (new_source);92 ((Maya.Application)GLib.Application.get_default ()).calmodel.add_source (new_source);
93 if (set_default) {93 if (set_default) {
94 registry.default_calendar = new_source;94 registry.default_calendar = new_source;
95 }95 }
@@ -132,4 +132,4 @@
132 critical (error.message);132 critical (error.message);
133 }133 }
134 }134 }
135}135}
136\ No newline at end of file136\ No newline at end of file
137137
=== modified file 'src/Application.vala'
--- src/Application.vala 2013-12-09 09:03:14 +0000
+++ src/Application.vala 2014-01-18 21:06:28 +0000
@@ -24,10 +24,10 @@
24 private static bool PRINT_VERSION = false;24 private static bool PRINT_VERSION = false;
2525
26 }26 }
27 public Application app;
28 public Plugins.Manager plugins_manager;27 public Plugins.Manager plugins_manager;
29 public BackendsManager backends_manager;28 public BackendsManager backends_manager;
30 public Settings.MayaSettings global_settings;29 public Settings.MayaSettings global_settings;
30 public Settings.SavedState saved_state;
3131
32 public static int main (string[] args) {32 public static int main (string[] args) {
3333
@@ -48,7 +48,7 @@
48 }48 }
4949
50 Gtk.init (ref args);50 Gtk.init (ref args);
51 app = new Application ();51 var app = new Application ();
5252
53 return app.run (args);53 return app.run (args);
5454
@@ -71,7 +71,7 @@
71 build_version = Build.VERSION;71 build_version = Build.VERSION;
72 build_version_info = Build.VERSION_INFO;72 build_version_info = Build.VERSION_INFO;
7373
74 program_name = "Maya";74 program_name = Build.APP_NAME;
75 exec_name = "maya-calendar";75 exec_name = "maya-calendar";
7676
77 app_years = "2011-2013";77 app_years = "2011-2013";
@@ -109,8 +109,6 @@
109 { null }109 { null }
110 };110 };
111111
112 Settings.SavedState saved_state;
113
114 public Gtk.Window window;112 public Gtk.Window window;
115 View.MayaToolbar toolbar;113 View.MayaToolbar toolbar;
116 View.CalendarView calview;114 View.CalendarView calview;
@@ -213,8 +211,6 @@
213211
214 create_window ();212 create_window ();
215213
216 create_toolbar ();
217
218 calview = new View.CalendarView (calmodel, saved_state.show_weeks);214 calview = new View.CalendarView (calmodel, saved_state.show_weeks);
219 calview.on_event_add.connect ((date) => on_tb_add_clicked (date));215 calview.on_event_add.connect ((date) => on_tb_add_clicked (date));
220216
@@ -233,15 +229,14 @@
233229
234 gridcontainer = new Gtk.Grid ();230 gridcontainer = new Gtk.Grid ();
235 hpaned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);231 hpaned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
236 calview.set_vexpand(true);232 calview.vexpand = true;
237 hpaned.pack1 (calview, true, false);233 hpaned.pack1 (calview, true, false);
238 hpaned.pack2 (sidebar, true, false);234 hpaned.pack2 (sidebar, true, false);
239 hpaned.position = saved_state.hpaned_position;235 hpaned.position = saved_state.hpaned_position;
240 gridcontainer.attach (toolbar, 0, 0, 1, 1);
241 gridcontainer.attach (hpaned, 0, 2, 1, 1);236 gridcontainer.attach (hpaned, 0, 2, 1, 1);
242 window.add (gridcontainer);237 window.add (gridcontainer);
243238
244 add_window(window);239 add_window (window);
245240
246 if (saved_state.window_state == Settings.WindowState.MAXIMIZED)241 if (saved_state.window_state == Settings.WindowState.MAXIMIZED)
247 window.maximize ();242 window.maximize ();
@@ -296,33 +291,18 @@
296291
297 break;292 break;
298 case Gdk.Key.@F11:293 case Gdk.Key.@F11:
299 toolbar.menu.fullscreen.active = !toolbar.menu.fullscreen.active;294 toolbar.fullscreen.active = !toolbar.fullscreen.active;
300 break;295 break;
301 }296 }
302297
303 return false;298 return false;
304 });299 });
305 }300
306301 toolbar = new View.MayaToolbar (calmodel);
307 /**302 toolbar.add_calendar_clicked.connect (() => on_tb_add_clicked (calview.grid.selected_date));
308 * Creates the toolbar and its elements.303 toolbar.on_menu_today_toggled.connect (on_menu_today_toggled);
309 */304 toolbar.on_search.connect ((text) => on_search (text));
310 void create_toolbar () {305 window.set_titlebar (toolbar);
311 toolbar = new View.MayaToolbar (calmodel.month_start);
312 toolbar.button_add.clicked.connect (() => on_tb_add_clicked (calview.grid.selected_date));
313 toolbar.button_calendar_sources.clicked.connect (on_tb_sources_clicked);
314 toolbar.menu.today.activate.connect (on_menu_today_toggled);
315 toolbar.menu.fullscreen.toggled.connect (on_toggle_fullscreen);
316 toolbar.menu.weeknumbers.toggled.connect (on_menu_show_weeks_toggled);
317 toolbar.menu.fullscreen.active = (saved_state.window_state == Settings.WindowState.FULLSCREEN);
318 toolbar.menu.about.activate.connect (() => show_about(window));
319 toolbar.menu.weeknumbers.active = saved_state.show_weeks;
320 toolbar.search_bar.text_changed_pause.connect ((text) => on_search (text));
321
322 toolbar.month_switcher.left_clicked.connect (on_tb_month_switcher_left_clicked);
323 toolbar.month_switcher.right_clicked.connect (on_tb_month_switcher_right_clicked);
324 toolbar.year_switcher.left_clicked.connect (on_tb_year_switcher_left_clicked);
325 toolbar.year_switcher.right_clicked.connect (on_tb_year_switcher_right_clicked);
326 }306 }
327 307
328 void on_quit () {308 void on_quit () {
@@ -355,14 +335,6 @@
355335
356 //--- SIGNAL HANDLERS ---//336 //--- SIGNAL HANDLERS ---//
357337
358 void on_toggle_fullscreen () {
359
360 if (toolbar.menu.fullscreen.active)
361 window.fullscreen ();
362 else
363 window.unfullscreen ();
364 }
365
366 void on_event_dialog_response (View.EventDialog dialog, bool response_id, bool add_event) {338 void on_event_dialog_response (View.EventDialog dialog, bool response_id, bool add_event) {
367339
368 E.CalComponent event = dialog.ecal;340 E.CalComponent event = dialog.ecal;
@@ -413,30 +385,6 @@
413385
414 }386 }
415387
416 void on_tb_sources_clicked (Gtk.Widget widget) {
417 var source_selector = new View.SourceSelector ();
418 source_selector.move_to_widget (widget);
419 source_selector.show_all ();
420 source_selector.run ();
421 source_selector.destroy ();
422 }
423
424 void on_tb_month_switcher_left_clicked () {
425 calmodel.month_start = calmodel.month_start.add_months (-1);
426 }
427
428 void on_tb_month_switcher_right_clicked () {
429 calmodel.month_start = calmodel.month_start.add_months (1);
430 }
431
432 void on_tb_year_switcher_left_clicked () {
433 calmodel.month_start = calmodel.month_start.add_years (-1);
434 }
435
436 void on_tb_year_switcher_right_clicked () {
437 calmodel.month_start = calmodel.month_start.add_years (1);
438 }
439
440 /**388 /**
441 * Called when the search_bar is used.389 * Called when the search_bar is used.
442 */390 */
@@ -454,38 +402,6 @@
454 calview.today ();402 calview.today ();
455 }403 }
456404
457 void on_menu_show_weeks_toggled () {405 }
458 saved_state.show_weeks = toolbar.menu.weeknumbers.active;406
459 }407}
460
461 public void show_calendar_removed (string calendar_name) {
462 var info_bar = new Gtk.InfoBar ();
463 ((Gtk.Orientable)info_bar.get_action_area ()).orientation = Gtk.Orientation.HORIZONTAL;
464 //warning (info_bar.get_action_area ().name);
465 info_bar.set_message_type (Gtk.MessageType.INFO);
466 info_bar.add_button (Gtk.Stock.UNDO, 0);
467 info_bar.add_button (Gtk.Stock.CLOSE, 1);
468 var message_label = new Gtk.Label (_("Calendar \"%s\" removed.").printf (calendar_name));
469 info_bar.get_content_area ().add (message_label);
470 info_bar.response.connect ((id) => {
471 if (id == 0) {
472 calmodel.restore_calendar ();
473 info_bar.hide ();
474 } else {
475 info_bar.hide ();
476 }
477 });
478 gridcontainer.attach (info_bar, 0, 1, 1, 1);
479 info_bar.show_all ();
480 }
481
482 }
483
484 internal void desktop_translations () {
485 var comment = _("View and schedule events");
486 var generic_name = _("Calendar");
487 var add_event = _("_Add Event");
488 var keywords = _("Maya;Planner;Dates;Days;Events;");
489 }
490
491}
492\ No newline at end of file408\ No newline at end of file
493409
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2013-08-31 15:14:02 +0000
+++ src/CMakeLists.txt 2014-01-18 21:06:28 +0000
@@ -31,7 +31,7 @@
31 View/Grid/VAutoHider.vala31 View/Grid/VAutoHider.vala
32 View/EventDialog.vala32 View/EventDialog.vala
33 View/SourceDialog.vala33 View/SourceDialog.vala
34 View/MayaMenu.vala34 View/SourceItem.vala
35 View/MayaToolbar.vala35 View/MayaToolbar.vala
36 View/SourceSelector.vala36 View/SourceSelector.vala
37 View/Widgets/ContractorButtonWithMenu.vala37 View/Widgets/ContractorButtonWithMenu.vala
@@ -67,12 +67,12 @@
67target_link_libraries(${EXEC_NAME} ${DEPS_LIBRARIES})67target_link_libraries(${EXEC_NAME} ${DEPS_LIBRARIES})
6868
69if (BUILD_SHARED_LIBS)69if (BUILD_SHARED_LIBS)
70 install(TARGETS ${CLIENT_LIBRARY_NAME} DESTINATION lib)70 install(TARGETS ${CLIENT_LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
71 # Install lib stuffs71 # Install lib stuffs
72 install (FILES ${CMAKE_BINARY_DIR}/src/${CLIENT_VAPI}.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/)72 install (FILES ${CMAKE_BINARY_DIR}/src/${CLIENT_VAPI}.pc DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig/)
73 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_VAPI}.vapi DESTINATION share/vala/vapi/)73 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_VAPI}.vapi DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/vala/vapi/)
74 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_VAPI}.deps DESTINATION share/vala/vapi/)74 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_VAPI}.deps DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/vala/vapi/)
75 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_VAPI}.h DESTINATION include/${CLIENT_VAPI}/)75 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_VAPI}.h DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/${CLIENT_VAPI}/)
76endif ()76endif ()
7777
78install(TARGETS ${EXEC_NAME} RUNTIME DESTINATION bin)78install(TARGETS ${EXEC_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
79\ No newline at end of file79\ No newline at end of file
8080
=== modified file 'src/Model/CalendarModel.vala'
--- src/Model/CalendarModel.vala 2013-09-01 23:32:20 +0000
+++ src/Model/CalendarModel.vala 2014-01-18 21:06:28 +0000
@@ -532,11 +532,7 @@
532 532
533 public void do_real_deletion () {533 public void do_real_deletion () {
534 foreach (var source in calendar_trash) {534 foreach (var source in calendar_trash) {
535 try {535 source.remove.begin (null);
536 source.remove.begin (null);
537 } catch (Error error) {
538 critical (error.message);
539 }
540 }536 }
541 }537 }
542}538}
543539
=== modified file 'src/Settings/LanguagesFormat.vala'
--- src/Settings/LanguagesFormat.vala 2012-03-11 01:51:18 +0000
+++ src/Settings/LanguagesFormat.vala 2014-01-18 21:06:28 +0000
@@ -17,28 +17,24 @@
1717
18namespace Maya.Settings {18namespace Maya.Settings {
1919
20 public string DateFormat () {20 public string DateFormat () {
21 return (_("%B %e, %Y"));21 return _("%B %e, %Y");
22 }22 }
2323
24 public string DateFormat_Complete () {24 public string DateFormat_Complete () {
25 return (_("%A, %b %d"));25 return _("%A, %b %d");
26 }26 }
2727
28 public string TimeFormat () {28 public string TimeFormat () {
29
30 var setting = new GLib.Settings ("org.gnome.desktop.interface");29 var setting = new GLib.Settings ("org.gnome.desktop.interface");
31 string clockformat = setting.get_string ("clock-format");30 string clockformat = setting.get_string ("clock-format");
32 string outputformat;
3331
34 if (clockformat == "12h") {32 if (clockformat.contains ("12h")) {
35 outputformat = (_("%l:%M %p"));33 return _("%l:%M %p");
36 }34 }
37 else {35 else {
38 outputformat = (_("%H:%M"));36 return _("%H:%M");
39 }37 }
40 return outputformat;38 }
41 }
4239
43}40}
44
4541
=== modified file 'src/View/EventDialog.vala'
--- src/View/EventDialog.vala 2013-09-02 14:58:51 +0000
+++ src/View/EventDialog.vala 2014-01-18 21:06:28 +0000
@@ -443,7 +443,7 @@
443443
444 Granite.Widgets.TimePicker make_time_picker () {444 Granite.Widgets.TimePicker make_time_picker () {
445445
446 var time_picker = new Granite.Widgets.TimePicker.with_format (Maya.Settings.TimeFormat ());446 var time_picker = new Granite.Widgets.TimePicker ();
447 time_picker.width_request = 120;447 time_picker.width_request = 120;
448448
449 return time_picker;449 return time_picker;
@@ -559,4 +559,3 @@
559559
560560
561}561}
562
563562
=== removed file 'src/View/MayaMenu.vala'
--- src/View/MayaMenu.vala 2012-06-01 20:14:09 +0000
+++ src/View/MayaMenu.vala 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
1//
2// Copyright (C) 2011-2012 Maxwell Barvian
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17
18namespace Maya.View {
19
20 public class MayaMenu : Gtk.Menu {
21
22 public Gtk.MenuItem today { get; private set; }
23
24 public Gtk.MenuItem import { get; private set; }
25 public Gtk.MenuItem export { get; private set; }
26
27 public Gtk.CheckMenuItem fullscreen { get; private set; }
28 public Gtk.CheckMenuItem weeknumbers { get; private set; }
29
30 public Gtk.MenuItem sync { get; private set; }
31
32 public Gtk.MenuItem about { get; private set; }
33
34 public MayaMenu () {
35
36 // Create everything
37 today = new Gtk.MenuItem.with_label (_("Today"));
38
39 fullscreen = new Gtk.CheckMenuItem.with_label (_("Fullscreen"));
40
41 weeknumbers = new Gtk.CheckMenuItem.with_label (_("Show Week Numbers"));
42
43 import = new Gtk.MenuItem.with_label (_("Import..."));
44
45 sync = new Gtk.MenuItem.with_label (_("Sync..."));
46
47 about = new Gtk.MenuItem.with_label (_("About"));
48
49 // Append in correct order
50 append (today);
51
52 append (new Gtk.SeparatorMenuItem ());
53
54 append (fullscreen);
55 append (weeknumbers);
56
57 /*
58 * TODO : Will be done in Maya 0.2
59 append (new Gtk.SeparatorMenuItem ());
60
61 append (import);
62 append (sync);
63 */
64
65 append (new Gtk.SeparatorMenuItem ());
66
67 append (about);
68 }
69
70 }
71
72}
73
740
=== modified file 'src/View/MayaToolbar.vala'
--- src/View/MayaToolbar.vala 2013-07-17 11:57:59 +0000
+++ src/View/MayaToolbar.vala 2014-01-18 21:06:28 +0000
@@ -17,88 +17,107 @@
1717
18namespace Maya.View {18namespace Maya.View {
1919
20 public class MayaToolbar : Gtk.Toolbar {20 public class MayaToolbar : Gtk.HeaderBar {
2121
22 public Gtk.ToolButton button_add { get; private set; }22 // Signals
2323 public signal void on_search (string search);
24 public Widgets.DateSwitcher month_switcher { get; private set; }24 public signal void on_menu_today_toggled ();
25 public Widgets.DateSwitcher year_switcher { get; private set; }25 public signal void add_calendar_clicked ();
2626
27 public Granite.Widgets.SearchBar search_bar { get; private set; }27 Model.CalendarModel calmodel;
2828
29 public Gtk.ToolButton button_calendar_sources { get; private set; }29 // Toolbar items
3030 Widgets.DateSwitcher month_switcher;
31 public Granite.Widgets.AppMenu app_menu { get; private set; }31 Widgets.DateSwitcher year_switcher;
32 public MayaMenu menu { get; private set; }32 public Gtk.SearchEntry search_bar;
3333
34 public Widgets.ContractorButtonWithMenu contractor { get; private set; }34 // Menu items
3535 public Gtk.CheckMenuItem fullscreen;
36 public MayaToolbar (DateTime target) {36 Gtk.CheckMenuItem weeknumbers;
3737 View.SourceSelector source_selector;
38 // Toolbar properties38
39 get_style_context ().add_class ("primary-toolbar"); // compliant with elementary HIG39 public MayaToolbar (Model.CalendarModel calmodel) {
4040 this.calmodel = calmodel;
41 // Initialize everything41 show_close_button = true;
42 button_add = make_toolbutton (Gtk.IconTheme.get_default ().has_icon ("event-new") ? "event-new" : "list-add", _("Create a new event"));42
4343 var button_add = new Gtk.Button.from_icon_name ("appointment-new", Gtk.IconSize.LARGE_TOOLBAR);
44 button_calendar_sources = make_toolbutton ("gtk-index", _("Select calendars to display"), true);44 button_add.tooltip_text = _("Create a new event");
4545
46 var button_calendar_sources = new Gtk.Button.from_icon_name ("office-calendar", Gtk.IconSize.LARGE_TOOLBAR);
47 button_calendar_sources.tooltip_text = _("Manage Calendars");
48
46 month_switcher = new Widgets.DateSwitcher (10);49 month_switcher = new Widgets.DateSwitcher (10);
47 year_switcher = new Widgets.DateSwitcher (-1);50 year_switcher = new Widgets.DateSwitcher (-1);
48 set_switcher_date (target);51 set_switcher_date (calmodel.month_start);
4952
50 search_bar = new Granite.Widgets.SearchBar (_("Search Events"));53 search_bar = new Gtk.SearchEntry ();
54 search_bar.placeholder_text = _("Search Events");
51 search_bar.sensitive = false;55 search_bar.sensitive = false;
5256
53 contractor = new Widgets.ContractorButtonWithMenu (_("Export or Share the default Calendar"));57 var contractor = new Widgets.ContractorButtonWithMenu (_("Export or Share the default Calendar"));
5458
55 menu = new MayaMenu ();59 var menu = new Gtk.Menu ();
56 app_menu = new Granite.Widgets.AppMenu (menu);60 var menu_button = new Granite.Widgets.AppMenu (menu);
5761
58 // Insert into appropriate positions62 var title_grid = new Gtk.Grid ();
59 insert (button_add, -1);63 title_grid.column_spacing = 6;
6064
61 insert (make_spacer (), -1);65 title_grid.attach (year_switcher, 0, 0, 1, 1);
6266 title_grid.attach (month_switcher, 1, 0, 1, 1);
63 insert (make_toolitem_from_widget (Util.set_paddings (month_switcher, 5, 0, 5, 0)), -1);67 this.set_custom_title (title_grid);
64 insert (make_toolitem_from_widget (Util.set_paddings (year_switcher, 5, 0, 5, 10)), -1);68
6569 // Create the menu
66 insert (make_spacer (), -1);70
6771 var today = new Gtk.MenuItem.with_label (_("Today"));
68 insert (make_toolitem_from_widget (search_bar), -1);72 fullscreen = new Gtk.CheckMenuItem.with_label (_("Fullscreen"));
6973 weeknumbers = new Gtk.CheckMenuItem.with_label (_("Show Week Numbers"));
70 insert (button_calendar_sources, -1);74 //var import = new Gtk.MenuItem.with_label (_("Import…"));
7175 var about = new Gtk.MenuItem.with_label (_("About"));
72 insert (contractor, -1);76
7377 // Append in correct order
74 insert (app_menu, -1);78 menu.add (today);
75 }79 menu.add (new Gtk.SeparatorMenuItem ());
7680 menu.add (fullscreen);
77 private Gtk.ToolButton make_toolbutton (string icon_name, string tooltip_text, bool sensitive = true, bool can_focus = false) {81 menu.add (weeknumbers);
7882
79 var toolbutton = new Gtk.ToolButton (null, null);83 /* TODO : Will be done in Maya 0.2
80 toolbutton.icon_name = icon_name;84 menu.append (new Gtk.SeparatorMenuItem ());
81 toolbutton.sensitive = sensitive;85 menu.append (import);
82 toolbutton.can_focus = can_focus;86 menu.append (sync);
83 toolbutton.tooltip_text = tooltip_text;87 */
8488
85 return toolbutton;89 menu.append (new Gtk.SeparatorMenuItem ());
86 }90 menu.append (about);
8791
88 private Gtk.ToolItem make_spacer () {92 pack_start (button_calendar_sources);
8993 pack_start (button_add);
90 var spacer = new Gtk.ToolItem ();94
91 spacer.set_expand (true);95 pack_end (contractor);
9296 pack_end (search_bar);
93 return spacer;97 pack_end (menu_button);
94 }98
9599 // Connect to signals
96 private Gtk.ToolItem make_toolitem_from_widget (Gtk.Widget widget) {100
97101 button_add.clicked.connect (() => add_calendar_clicked ());
98 var toolitem = new Gtk.ToolItem ();102 button_calendar_sources.clicked.connect (on_tb_sources_clicked);
99 toolitem.add (widget);103 today.activate.connect (() => on_menu_today_toggled);
100104 fullscreen.toggled.connect (on_toggle_fullscreen);
101 return toolitem;105 weeknumbers.toggled.connect (on_menu_show_weeks_toggled);
106 about.activate.connect (() => {
107 var app = ((Maya.Application)GLib.Application.get_default ());
108 app.show_about (app.window);
109 });
110 search_bar.search_changed.connect (() => on_search (search_bar.text));
111
112 month_switcher.left_clicked.connect (() => {change_month (-1);});
113 month_switcher.right_clicked.connect (() => {change_month (1);});
114 year_switcher.left_clicked.connect (() => {change_year (-1);});
115 year_switcher.right_clicked.connect (() => {change_year (1);});
116
117 button_calendar_sources.size_allocate.connect (button_size_allocate);
118
119 fullscreen.active = (saved_state.window_state == Settings.WindowState.FULLSCREEN);
120 weeknumbers.active = saved_state.show_weeks;
102 }121 }
103122
104 public void set_switcher_date (DateTime date) {123 public void set_switcher_date (DateTime date) {
@@ -106,7 +125,41 @@
106 year_switcher.text = date.format ("%Y");125 year_switcher.text = date.format ("%Y");
107 }126 }
108127
128 void on_toggle_fullscreen () {
129 var window = ((Maya.Application)GLib.Application.get_default ()).window;
130
131 if (fullscreen.active)
132 window.fullscreen ();
133 else
134 window.unfullscreen ();
135 }
136
137 void on_menu_show_weeks_toggled () {
138 saved_state.show_weeks = weeknumbers.active;
139 }
140
141 void button_size_allocate (Gtk.Allocation allocation) {
142 month_switcher.height_request = allocation.height;
143 year_switcher.height_request = allocation.height;
144 }
145
146 void on_tb_sources_clicked (Gtk.Widget widget) {
147 if (source_selector == null) {
148 source_selector = new View.SourceSelector (calmodel);
149 }
150 source_selector.move_to_widget (widget);
151 source_selector.show ();
152 source_selector.run ();
153 }
154
155 void change_month (int relative) {
156 calmodel.month_start = calmodel.month_start.add_months (relative);
157 }
158
159 void change_year (int relative) {
160 calmodel.month_start = calmodel.month_start.add_years (relative);
161 }
162
109 }163 }
110164
111}165}
112
113\ No newline at end of file166\ No newline at end of file
114167
=== modified file 'src/View/SourceDialog.vala'
--- src/View/SourceDialog.vala 2013-09-01 23:22:22 +0000
+++ src/View/SourceDialog.vala 2014-01-18 21:06:28 +0000
@@ -15,100 +15,62 @@
15// along with this program. If not, see <http://www.gnu.org/licenses/>.15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//16//
1717
18#if USE_GRANITE_DECORATED_WINDOW18public class Maya.View.SourceDialog : Gtk.Grid {
19public class Maya.View.SourceDialog : Granite.Widgets.LightWindow {
20#else
21public class Maya.View.SourceDialog : Gtk.Window {
22#endif
23
24 public EventType event_type { get; private set; default=EventType.EDIT;}19 public EventType event_type { get; private set; default=EventType.EDIT;}
25 20
26 private Gtk.Entry name_entry;21 private Gtk.Entry name_entry;
27 private Gtk.ColorButton color_button;22 private Gtk.ColorButton color_button;
28 private bool set_as_default = false;23 private bool set_as_default = false;
29 private Backend current_backend;24 private Backend current_backend;
30 private Gee.Collection<PlacementWidget> backend_widgets;25 private Gee.Collection<PlacementWidget> backend_widgets;
31 private Gtk.Grid main_grid;26 private Gtk.Grid main_grid;
32 private Gtk.Grid general_grid;
33 private Gee.HashMap<string, bool> widgets_checked;27 private Gee.HashMap<string, bool> widgets_checked;
34 private Gtk.Button create_button;28 private Gtk.Button create_button;
35 private E.Source source;29 private Gtk.ComboBox type_combobox;
3630 private Gtk.ListStore list_store;
37 public SourceDialog (E.Source? source = null) {31 private E.Source source = null;
32
33 public signal void go_back ();
34
35 public SourceDialog () {
38 widgets_checked = new Gee.HashMap<string, bool> (null, null);36 widgets_checked = new Gee.HashMap<string, bool> (null, null);
39
40 if (source == null) {
41 title = _("Add Calendar");
42 event_type = EventType.ADD;
43 } else {
44 title = _("Edit Calendar");
45 this.source = source;
46 }
47
48 // Dialog properties
49 window_position = Gtk.WindowPosition.CENTER_ON_PARENT;
50 type_hint = Gdk.WindowTypeHint.DIALOG;
51 transient_for = app.window;
5237
53 main_grid = new Gtk.Grid ();38 main_grid = new Gtk.Grid ();
54 main_grid.set_row_spacing (6);39 main_grid.set_row_spacing (6);
55 main_grid.set_column_spacing (12);40 main_grid.set_column_spacing (12);
56 41
57 general_grid = new Gtk.Grid ();42 margin_left = 6;
58 general_grid.margin_left = 12;43 margin_right = 6;
59 general_grid.margin_right = 12;44 margin_top = 6;
60 general_grid.margin_top = 12;45 set_row_spacing (6);
61 general_grid.margin_bottom = 12;46 set_column_spacing (12);
62 general_grid.set_row_spacing (6);47 expand = true;
63 general_grid.set_column_spacing (12);48
64
65 // Buttons49 // Buttons
66 50
67 var buttonbox = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);51 var buttonbox = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
68 buttonbox.set_layout (Gtk.ButtonBoxStyle.END);52 buttonbox.set_layout (Gtk.ButtonBoxStyle.END);
69
7053
71 var cancel_button = new Gtk.Button.from_stock (Gtk.Stock.CANCEL);54 var cancel_button = new Gtk.Button.with_label (_("Cancel"));
72 if (event_type == EventType.ADD) {55 create_button = new Gtk.Button.with_label (_("Create"));
73 create_button = new Gtk.Button.with_label (_("Create Calendar"));
74 } else {
75 create_button = new Gtk.Button.from_stock (Gtk.Stock.SAVE);
76 }
7756
78 create_button.clicked.connect (save);57 create_button.clicked.connect (save);
79 cancel_button.clicked.connect (() => {this.destroy();});58 cancel_button.clicked.connect (() => go_back ());
8059
81 buttonbox.pack_end (cancel_button);60 buttonbox.pack_end (cancel_button);
82 buttonbox.pack_end (create_button);61 buttonbox.pack_end (create_button);
83 62
84 // Name63 // Name
85
86 var name_label = new Gtk.Label (_("Name:"));64 var name_label = new Gtk.Label (_("Name:"));
87 name_label.xalign = 1;65 name_label.xalign = 1;
88 name_entry = new Gtk.Entry ();66 name_entry = new Gtk.Entry ();
89 name_entry.placeholder_text = _("Calendar Name");67 name_entry.placeholder_text = _("Calendar Name");
90 name_entry.changed.connect (() => {check_can_validate ();});68 name_entry.changed.connect (() => {check_can_validate ();});
91 if (event_type == EventType.EDIT) {69
92 name_entry.text = source.display_name;
93 }
94
95 // Type Combobox70 // Type Combobox
96 Gtk.ListStore list_store = new Gtk.ListStore (2, typeof (string), typeof (Backend));71 list_store = new Gtk.ListStore (2, typeof (string), typeof (Backend));
97 Gtk.TreeIter iter;72
98 int number = 0;73 type_combobox = new Gtk.ComboBox.with_model (list_store);
99 int i =0;
100 foreach (var backend in backends_manager.backends) {
101 list_store.append (out iter);
102 list_store.set (iter, 0, backend.get_name (), 1, backend);
103 if (event_type == EventType.EDIT) {
104 if (backend.get_uid () == source.dup_parent ()) {
105 number = i;
106 }
107 }
108 i++;
109 }
110
111 var type_combobox = new Gtk.ComboBox.with_model (list_store);
11274
113 Gtk.CellRendererText renderer = new Gtk.CellRendererText ();75 Gtk.CellRendererText renderer = new Gtk.CellRendererText ();
114 type_combobox.pack_start (renderer, true);76 type_combobox.pack_start (renderer, true);
@@ -116,7 +78,6 @@
11678
117 type_combobox.changed.connect (() => {79 type_combobox.changed.connect (() => {
118 GLib.Value backend;80 GLib.Value backend;
119
120 Gtk.TreeIter b_iter;81 Gtk.TreeIter b_iter;
121 type_combobox.get_active_iter (out b_iter);82 type_combobox.get_active_iter (out b_iter);
122 list_store.get_value (b_iter, 1, out backend);83 list_store.get_value (b_iter, 1, out backend);
@@ -125,38 +86,33 @@
125 backend_widgets = ((Backend)backend).get_new_calendar_widget (source);86 backend_widgets = ((Backend)backend).get_new_calendar_widget (source);
126 add_backend_widgets ();87 add_backend_widgets ();
127 });88 });
128 89
129 type_combobox.set_active (number);
130
131 var type_label = new Gtk.Label (_("Type:"));90 var type_label = new Gtk.Label (_("Type:"));
132 type_label.expand = true;
133 type_label.xalign = 1;91 type_label.xalign = 1;
134 92
135 if (backends_manager.backends.size == 1) {93 Gtk.TreeIter iter;
94 foreach (var backend in backends_manager.backends) {
95 list_store.append (out iter);
96 list_store.set (iter, 0, backend.get_name (), 1, backend);
97 }
98
99 if (backends_manager.backends.size <= 1) {
136 type_combobox.no_show_all = true;100 type_combobox.no_show_all = true;
137 type_label.no_show_all = true;101 type_label.no_show_all = true;
138 }102 }
139 103
140 if (event_type == EventType.EDIT) {104 type_combobox.set_active (0);
141 type_combobox.sensitive = false;105
142 }
143
144 // Color106 // Color
145 var rgba = Gdk.RGBA ();107 var rgba = Gdk.RGBA ();
146 if (event_type == EventType.EDIT) {108 rgba.red = 0.13;
147 var cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);109 rgba.green = 0.42;
148 rgba.parse (cal.dup_color ());110 rgba.blue = 0.70;
149 } else {
150 rgba.red = 0.13;
151 rgba.green = 0.42;
152 rgba.blue = 0.70;
153 }
154 var color_label = new Gtk.Label (_("Color:"));111 var color_label = new Gtk.Label (_("Color:"));
155 color_label.xalign = 1;112 color_label.xalign = 1;
156 color_button = new Gtk.ColorButton.with_rgba (rgba);113 color_button = new Gtk.ColorButton.with_rgba (rgba);
157 color_button.use_alpha = false;114 color_button.use_alpha = false;
158 115
159
160 var check_button = new Gtk.CheckButton.with_label (_("Mark as default calendar"));116 var check_button = new Gtk.CheckButton.with_label (_("Mark as default calendar"));
161117
162 check_button.toggled.connect (() => {118 check_button.toggled.connect (() => {
@@ -170,25 +126,67 @@
170 main_grid.attach (color_label, 0, 2, 1, 1);126 main_grid.attach (color_label, 0, 2, 1, 1);
171 main_grid.attach (color_button, 1, 2, 1, 1);127 main_grid.attach (color_button, 1, 2, 1, 1);
172 main_grid.attach (check_button, 1, 3, 1, 1);128 main_grid.attach (check_button, 1, 3, 1, 1);
173 129
174 general_grid.attach (main_grid, 0, 0, 2, 1);130 attach (main_grid, 0, 0, 2, 1);
175 general_grid.attach (buttonbox, 0, 1, 2, 1);131
176 132 var fake_label = new Gtk.Grid ();
177 this.add (general_grid);133 fake_label.expand = true;
178 134 attach (fake_label, 0, 1, 2, 1);
135 attach (buttonbox, 0, 2, 2, 1);
136
179 show_all ();137 show_all ();
180 }138 }
181 139
140 public void set_source (E.Source? source = null) {
141 this.source = source;
142 if (source == null) {
143 event_type = EventType.ADD;
144 name_entry.text = "";
145 type_combobox.sensitive = true;
146 create_button.set_label (_("Create Calendar"));
147 var rgba = Gdk.RGBA ();
148 rgba.red = 0.13;
149 rgba.green = 0.42;
150 rgba.blue = 0.70;
151 color_button.set_rgba (rgba);
152 } else {
153 create_button.set_label (_("Save"));
154 name_entry.text = source.display_name;
155 type_combobox.sensitive = false;
156 var cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);
157 var rgba = Gdk.RGBA ();
158 rgba.parse (cal.dup_color ());
159 color_button.set_rgba (rgba);
160 list_store.foreach (tree_foreach);
161 }
162 }
163
164 private bool tree_foreach (Gtk.TreeModel model, Gtk.TreePath path, Gtk.TreeIter iter) {
165 GLib.Value backend;
166 list_store.get_value (iter, 1, out backend);
167 var current_backend = ((Backend)backend);
168 if (current_backend.get_uid () == source.dup_parent ()) {
169 type_combobox.set_active_iter (iter);
170 return true;
171 }
172
173 return false;
174 }
175
182 private void remove_backend_widgets () {176 private void remove_backend_widgets () {
183 if (backend_widgets == null)177 if (backend_widgets == null)
184 return;178 return;
179
185 foreach (var widget in backend_widgets) {180 foreach (var widget in backend_widgets) {
186 widget.widget.hide ();181 widget.widget.hide ();
182 widget.widget.destroy ();
187 }183 }
184
188 backend_widgets.clear ();185 backend_widgets.clear ();
189 }186 }
190 187
191 private void add_backend_widgets () {188 private void add_backend_widgets () {
189 widgets_checked.clear ();
192 foreach (var widget in backend_widgets) {190 foreach (var widget in backend_widgets) {
193 main_grid.attach (widget.widget, widget.column, 4 + widget.row, 1, 1);191 main_grid.attach (widget.widget, widget.column, 4 + widget.row, 1, 1);
194 if (widget.needed == true && widget.widget is Gtk.Entry) {192 if (widget.needed == true && widget.widget is Gtk.Entry) {
@@ -200,39 +198,33 @@
200 }198 }
201 check_can_validate ();199 check_can_validate ();
202 }200 }
203 201
204 private void entry_changed (PlacementWidget widget) {202 private void entry_changed (PlacementWidget widget) {
205 widgets_checked.unset (widget.ref_name);203 widgets_checked.unset (widget.ref_name);
206 widgets_checked.set (widget.ref_name, ((Gtk.Entry)widget.widget).text != "");204 widgets_checked.set (widget.ref_name, ((Gtk.Entry)widget.widget).text.chug ().char_count () > 0);
207 check_can_validate ();205 check_can_validate ();
208 }206 }
209 207
210 private void check_can_validate () {208 private void check_can_validate () {
211 bool result = true;
212 foreach (var valid in widgets_checked.values) {209 foreach (var valid in widgets_checked.values) {
213 if (valid == false) {210 if (valid == false) {
214 result = false;211 create_button.sensitive = false;
215 break;212 return;
216 }213 }
217 }214 }
218 if (result == true && name_entry.text != "") {215
216 if (name_entry.text != "") {
219 create_button.sensitive = true;217 create_button.sensitive = true;
220 } else {
221 create_button.sensitive = false;
222 }218 }
223 }219 }
224220
225 //--- Public Methods ---//
226
227
228 public void save () {221 public void save () {
229
230 if (event_type == EventType.ADD) {222 if (event_type == EventType.ADD) {
231 current_backend.add_new_calendar (name_entry.text, Util.get_hexa_color (color_button.rgba), set_as_default, backend_widgets);223 current_backend.add_new_calendar (name_entry.text, Util.get_hexa_color (color_button.rgba), set_as_default, backend_widgets);
232 this.destroy();224 go_back ();
233 } else {225 } else {
234 current_backend.modify_calendar (name_entry.text, Util.get_hexa_color (color_button.rgba), set_as_default, backend_widgets, source);226 current_backend.modify_calendar (name_entry.text, Util.get_hexa_color (color_button.rgba), set_as_default, backend_widgets, source);
235 this.destroy();227 go_back ();
236 }228 }
237 }229 }
238}230}
239\ No newline at end of file231\ No newline at end of file
240232
=== added file 'src/View/SourceItem.vala'
--- src/View/SourceItem.vala 1970-01-01 00:00:00 +0000
+++ src/View/SourceItem.vala 2014-01-18 21:06:28 +0000
@@ -0,0 +1,210 @@
1// This program is free software: you can redistribute it and/or modify
2// it under the terms of the GNU General Public License as published by
3// the Free Software Foundation, either version 3 of the License, or
4// (at your option) any later version.
5//
6// This program is distributed in the hope that it will be useful,
7// but WITHOUT ANY WARRANTY; without even the implied warranty of
8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9// GNU General Public License for more details.
10//
11// You should have received a copy of the GNU General Public License
12// along with this program. If not, see <http://www.gnu.org/licenses/>.
13//
14
15public class Maya.View.SourceItem : Gtk.EventBox {
16 private E.Source source;
17
18 private Gtk.Revealer revealer;
19 private Gtk.Revealer info_revealer;
20 private Model.CalendarModel calmodel;
21 private Gtk.Grid main_grid;
22
23 private Gtk.Button delete_button;
24 private Gtk.Button edit_button;
25
26 private Gtk.Label calendar_name_label;
27 private Gtk.Label backend_label;
28 private Gtk.Label calendar_color_label;
29 private Gtk.CheckButton visible_checkbutton;
30
31 public signal void remove_request (E.Source source);
32 public signal void edit_request (E.Source source);
33
34 public SourceItem (E.Source source, Model.CalendarModel calmodel) {
35 this.source = source;
36 this.calmodel = calmodel;
37
38 main_grid = new Gtk.Grid ();
39
40 // Source widget
41 E.SourceCalendar cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);
42 revealer = new Gtk.Revealer ();
43 revealer.set_reveal_child (true);
44
45 var revealer_grid = new Gtk.Grid ();
46 revealer_grid.column_spacing = 6;
47 revealer_grid.row_spacing = 12;
48
49 calendar_name_label = new Gtk.Label (source.dup_display_name ());
50 calendar_name_label.set_markup ("<b>%s</b>".printf (GLib.Markup.escape_text (source.dup_display_name ())));
51 calendar_name_label.xalign = 0;
52
53 Maya.Backend selected_backend = null;
54 foreach (var backend in backends_manager.backends) {
55 if (source.dup_parent () == backend.get_uid ()) {
56 selected_backend = backend;
57 break;
58 }
59 }
60
61 if (selected_backend == null) {
62 backend_label = new Gtk.Label ("");
63 } else {
64 backend_label = new Gtk.Label (selected_backend.get_name ());
65 }
66
67 backend_label.hexpand = true;
68 backend_label.xalign = 0;
69
70 calendar_color_label = new Gtk.Label (" ");
71 var color = Gdk.RGBA ();
72 color.parse (cal.dup_color());
73 calendar_color_label.override_background_color (Gtk.StateFlags.NORMAL, color);
74
75 visible_checkbutton = new Gtk.CheckButton ();
76 visible_checkbutton.active = cal.selected;
77 visible_checkbutton.toggled.connect (() => {
78 if (visible_checkbutton.active == true) {
79 calmodel.add_source (source);
80 } else {
81 calmodel.remove_source (source);
82 }
83
84 cal.set_selected (visible_checkbutton.active);
85 try {
86 source.write_sync ();
87 } catch (GLib.Error error) {
88 critical (error.message);
89 }
90 });
91
92 delete_button = new Gtk.Button.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.MENU);
93 delete_button.set_tooltip_text (_("Remove"));
94 delete_button.clicked.connect (() => {remove_request (source);});
95 delete_button.relief = Gtk.ReliefStyle.NONE;
96 delete_button.no_show_all = true;
97
98 edit_button = new Gtk.Button.from_icon_name ("document-properties-symbolic", Gtk.IconSize.MENU);
99 edit_button.set_tooltip_text (_("Edit…"));
100 edit_button.clicked.connect (() => {edit_request (source);});
101 edit_button.relief = Gtk.ReliefStyle.NONE;
102 edit_button.no_show_all = true;
103
104 revealer_grid.attach (visible_checkbutton, 0, 0, 1, 2);
105 revealer_grid.attach (calendar_color_label, 1, 0, 1, 2);
106 revealer_grid.attach (calendar_name_label, 2, 0, 1, 1);
107 revealer_grid.attach (backend_label, 3, 0, 1, 1);
108 revealer_grid.attach (delete_button, 4, 0, 1, 2);
109 revealer_grid.attach (edit_button, 5, 0, 1, 2);
110
111 revealer.add (revealer_grid);
112
113 // Info bar
114 info_revealer = new Gtk.Revealer ();
115 info_revealer.no_show_all = true;
116 var info_revealer_grid = new Gtk.Grid ();
117 info_revealer_grid.column_spacing = 6;
118 info_revealer_grid.row_spacing = 12;
119 info_revealer.add (info_revealer_grid);
120 var undo_button = new Gtk.Button.with_label (_("Undo"));
121 undo_button.clicked.connect (() => {
122 revealer.show ();
123 calmodel.restore_calendar ();
124 revealer.set_reveal_child (true);
125 info_revealer.set_reveal_child (false);
126 info_revealer.hide ();
127 });
128
129 var close_button = new Gtk.Button.from_icon_name ("window-close-symbolic", Gtk.IconSize.SMALL_TOOLBAR);
130 close_button.relief = Gtk.ReliefStyle.NONE;
131 close_button.clicked.connect (() => {
132 info_revealer.set_reveal_child (false);
133 info_revealer.hide ();
134 hide ();
135 destroy ();
136 });
137
138 var message_label = new Gtk.Label (_("Calendar \"%s\" removed.").printf (source.display_name));
139 message_label.hexpand = true;
140 message_label.xalign = 0;
141 info_revealer_grid.attach (message_label, 0, 0, 1, 1);
142 info_revealer_grid.attach (undo_button, 1, 0, 1, 1);
143 info_revealer_grid.attach (close_button, 2, 0, 1, 1);
144
145 main_grid.attach (info_revealer, 0, 0, 1, 1);
146 main_grid.attach (revealer, 0, 1, 1, 1);
147 add (main_grid);
148
149 add_events (Gdk.EventMask.ENTER_NOTIFY_MASK|Gdk.EventMask.LEAVE_NOTIFY_MASK);
150 enter_notify_event.connect ((event) => {
151 delete_button.visible = true;
152 edit_button.visible = true;
153 return false;
154 });
155
156 leave_notify_event.connect_after ((event) => {
157 delete_button.visible = false;
158 edit_button.visible = false;
159 return false;
160 });
161 }
162
163 // We need a custom one because the buttons are hidden if the calendar is not shown.
164 public override void get_preferred_width (out int minimum_width, out int natural_width) {
165 base.get_preferred_width (out minimum_width, out natural_width);
166 if (visible == false)
167 return;
168
169 int total_natural_width = 0;
170 int _minimum_width;
171 int _natural_width;
172 if (edit_button.visible == false && info_revealer.visible == false) {
173 edit_button.show ();
174 edit_button.get_preferred_width (out _minimum_width, out _natural_width);
175 edit_button.hide ();
176 // +6 because the grid has a 6px margin between every columns
177 total_natural_width = total_natural_width + _natural_width + 6;
178 }
179
180 if (delete_button.visible == false && info_revealer.visible == false) {
181 delete_button.show ();
182 delete_button.get_preferred_width (out _minimum_width, out _natural_width);
183 delete_button.hide ();
184 // +6 because the grid has a 6px margin between every columns
185 total_natural_width = total_natural_width + _natural_width + 6;
186 }
187
188 minimum_width = minimum_width + total_natural_width;
189 natural_width = natural_width + total_natural_width;
190 }
191
192 public void source_has_changed () {
193 calendar_name_label.set_markup ("<b>%s</b>".printf (GLib.Markup.escape_text (source.dup_display_name ())));
194 E.SourceCalendar cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);
195
196 var color = Gdk.RGBA ();
197 color.parse (cal.dup_color());
198 calendar_color_label.override_background_color (Gtk.StateFlags.NORMAL, color);
199
200 visible_checkbutton.active = cal.selected;
201 }
202
203 public void show_calendar_removed () {
204 info_revealer.no_show_all = false;
205 info_revealer.show_all ();
206 revealer.set_reveal_child (false);
207 revealer.hide ();
208 info_revealer.set_reveal_child (true);
209 }
210}
0\ No newline at end of file211\ No newline at end of file
1212
=== modified file 'src/View/SourceSelector.vala'
--- src/View/SourceSelector.vala 2013-09-01 23:22:22 +0000
+++ src/View/SourceSelector.vala 2014-01-18 21:06:28 +0000
@@ -14,131 +14,47 @@
1414
15public class Maya.View.SourceSelector : Granite.Widgets.PopOver {15public class Maya.View.SourceSelector : Granite.Widgets.PopOver {
16 16
17 private Gtk.TreeStore tree_store;17 private Gee.HashMap<string, SourceItem?> src_map;
18 private Gtk.TreeView tree_view;18
19 private Gee.HashMap<string, Gtk.TreeIter?> iter_map;19 private Model.CalendarModel calmodel;
20 private Gtk.TreeIter default_iter;20
21 21 private Gtk.Stack stack;
22 private Gtk.ToolButton remove_button;22 private SourceDialog src_dialog = null;
23 private Gtk.ToolButton edit_button;23
2424 private Gtk.Grid main_grid;
25 private enum Columns {25 private Gtk.Grid calendar_grid;
26 TOGGLE,26 private int calendar_index = 0;
27 TEXT,27 private Gtk.ScrolledWindow scroll;
28 COLOR,28 private E.SourceRegistry registry;
29 SOURCE,29
30 VISIBLE,30 public SourceSelector (Model.CalendarModel calmodel) {
31 N_COLUMNS31
32 }32 this.calmodel = calmodel;
33 33
34 public SourceSelector () {34 stack = new Gtk.Stack ();
35 35
36 var main_grid = new Gtk.Grid ();36 calendar_grid = new Gtk.Grid ();
37 37 calendar_grid.row_spacing = 12;
38 tree_store = new Gtk.TreeStore (Columns.N_COLUMNS, typeof (bool), typeof (string), typeof (string), typeof (E.Source), typeof (bool));38 calendar_grid.margin_left = 6;
39 tree_view = new Gtk.TreeView.with_model (tree_store);39 calendar_grid.margin_right = 6;
40 iter_map = new Gee.HashMap<string, Gtk.TreeIter?>();40
4141 scroll = new Gtk.ScrolledWindow (null, null);
42 var toggle = new Gtk.CellRendererToggle ();42 scroll.hscrollbar_policy = Gtk.PolicyType.NEVER;
43 toggle.toggled.connect ((toggle, path) => {43 scroll.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
44 var tree_path = new Gtk.TreePath.from_string (path);44 scroll.expand = true;
45 Gtk.TreeIter iter;45 scroll.add (calendar_grid);
46 tree_store.get_iter (out iter, tree_path);46
47 tree_store.set (iter, Columns.TOGGLE, !toggle.active);47 main_grid = new Gtk.Grid ();
48 GLib.Value src;48 main_grid.row_spacing = 6;
49 tree_store.get_value (iter, 3, out src);49 main_grid.margin_top = 6;
50 E.SourceCalendar cal = (E.SourceCalendar)((E.Source)src).get_extension (E.SOURCE_EXTENSION_CALENDAR);50
51 if (!cal.selected == true) {51 src_map = new Gee.HashMap<string, SourceItem?>();
52 app.calmodel.add_source ((E.Source)src);
53 } else {
54 app.calmodel.remove_source ((E.Source)src);
55 }
56 cal.set_selected (!cal.selected);
57 try {
58 ((E.Source)src).write_sync ();
59 } catch (GLib.Error error) {
60 critical (error.message);
61 }
62 });
63
64 var text = new Gtk.CellRendererText ();
65 var column = new Gtk.TreeViewColumn ();
66 column.pack_start (text, true);
67 column.add_attribute (text, "text", Columns.TEXT);
68 column.add_attribute (text, "cell_background", Columns.COLOR);
69 tree_view.append_column (column);
70
71 column = new Gtk.TreeViewColumn ();
72 column.pack_start (toggle, false);
73 column.add_attribute (toggle, "active", Columns.TOGGLE);
74 column.add_attribute (toggle, "cell_background", Columns.COLOR);
75 column.add_attribute (toggle, "visible", Columns.VISIBLE);
76 tree_view.append_column (column);
77
78 tree_view.set_headers_visible (false);
79
80 var backend_map = new Gee.HashMap<string, Gtk.TreeIter?>();
81 52
82 try {53 try {
83 var registry = new E.SourceRegistry.sync (null);54 registry = new E.SourceRegistry.sync (null);
84 var sources = registry.list_sources (E.SOURCE_EXTENSION_CALENDAR);55 var sources = registry.list_sources (E.SOURCE_EXTENSION_CALENDAR);
85 // Do not show sources that are on the trash
86 foreach (var source in app.calmodel.calendar_trash) {
87 foreach (var source2 in sources) {
88 if (source.dup_uid () == source2.dup_uid ()) {
89 sources.remove (source2);
90 break;
91 }
92 }
93 }
94
95 var selection = tree_view.get_selection ();
96 selection.mode = Gtk.SelectionMode.BROWSE;
97 selection.set_select_function (select_func);
98
99 foreach (var backend in backends_manager.backends) {
100 Gtk.TreeIter? b_iter = null;
101 foreach (var src in sources) {
102 Gtk.TreeIter iter;
103 if (src.parent == backend.get_uid ()) {
104 if (b_iter == null) {
105 tree_store.append (out b_iter, null);
106 tree_store.set (b_iter, Columns.TEXT, backend.get_name (), Columns.VISIBLE, false);
107 backend_map.set (backend.get_uid (), b_iter);
108 }
109 E.SourceCalendar cal = (E.SourceCalendar)src.get_extension (E.SOURCE_EXTENSION_CALENDAR);
110 tree_store.append (out iter, b_iter);
111 tree_store.set (iter, Columns.TOGGLE, cal.selected, Columns.TEXT, src.dup_display_name (),
112 Columns.COLOR, cal.dup_color(), Columns.SOURCE, src,
113 Columns.VISIBLE, true);
114 iter_map.set (src.dup_uid (), iter);
115 if (src.get_uid() == registry.default_calendar.uid) {
116 default_iter = iter;
117 selection.select_iter (iter);
118 }
119 }
120 }
121 }
122
123 Gtk.TreeIter? other = null;
124 foreach (var src in sources) {56 foreach (var src in sources) {
125 if (!backend_map.keys.contains (src.parent)) {57 source_added (src);
126 if (other == null) {
127 tree_store.append (out other, null);
128 tree_store.set (other, Columns.TEXT, _("Other"), Columns.VISIBLE, false);
129 }
130 Gtk.TreeIter iter;
131 E.SourceCalendar cal = (E.SourceCalendar)src.get_extension (E.SOURCE_EXTENSION_CALENDAR);
132 tree_store.append (out iter, other);
133 tree_store.set (iter, Columns.TOGGLE, cal.selected, Columns.TEXT, src.dup_display_name (),
134 Columns.COLOR, cal.dup_color(), Columns.SOURCE, src,
135 Columns.VISIBLE, true);
136 iter_map.set (src.dup_uid (), iter);
137 if (src.get_uid() == registry.default_calendar.uid) {
138 default_iter = iter;
139 selection.select_iter (iter);
140 }
141 }
142 }58 }
143 59
144 registry.source_removed.connect (source_removed);60 registry.source_removed.connect (source_removed);
@@ -150,132 +66,116 @@
150 critical (error.message);66 critical (error.message);
151 }67 }
152 68
153 tree_view.expand_all ();69 var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL);
154 70 separator.hexpand = true;
155 var scroll = new Gtk.ScrolledWindow (null, null);71
156 scroll.set_size_request (150, 150);72 var add_calendar_button = new Gtk.Button.with_label (_("Add New Calendar…"));
157 scroll.hscrollbar_policy = Gtk.PolicyType.NEVER;73 add_calendar_button.relief = Gtk.ReliefStyle.NONE;
158 scroll.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;74 add_calendar_button.hexpand = true;
159 scroll.shadow_type = Gtk.ShadowType.IN;75 add_calendar_button.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM);
160 scroll.expand = true;76 add_calendar_button.get_style_context ().remove_class (Gtk.STYLE_CLASS_BUTTON);
161 scroll.add (tree_view);77 add_calendar_button.clicked.connect (create_source);
16278
163 var toolbar = new Gtk.Toolbar();79 var add_calendar_grid = new Gtk.Grid ();
164 toolbar.set_style (Gtk.ToolbarStyle.ICONS);80 add_calendar_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_MENU);
165 toolbar.get_style_context ().add_class ("inline-toolbar");81 add_calendar_grid.attach (add_calendar_button, 0, 0, 1, 1);
166 toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);82
167 toolbar.set_show_arrow (false);83 main_grid.attach (scroll, 0, 0, 1, 1);
168 toolbar.hexpand = true;84 main_grid.attach (separator, 0, 1, 1, 1);
16985 main_grid.attach (add_calendar_grid, 0, 2, 1, 1);
170 scroll.get_style_context ().set_junction_sides (Gtk.JunctionSides.BOTTOM);86
171 toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);87 stack.add_named (main_grid, "main");
172 toolbar.get_style_context ().set_junction_sides (Gtk.JunctionSides.TOP);
173
174 var add_button = new Gtk.ToolButton (null, _("Add…"));
175 add_button.set_tooltip_text (_("Add…"));
176 add_button.set_icon_name ("list-add-symbolic");
177 add_button.clicked.connect (create_source);
178
179 remove_button = new Gtk.ToolButton (null, _("Remove"));
180 remove_button.set_tooltip_text (_("Remove"));
181 remove_button.set_icon_name ("list-remove-symbolic");
182 remove_button.clicked.connect (remove_source);
183 remove_button.sensitive = false;
184
185 edit_button = new Gtk.ToolButton (null, _("Edit…"));
186 edit_button.set_tooltip_text (_("Edit…"));
187 edit_button.set_icon_name ("document-properties-symbolic");
188 edit_button.clicked.connect (edit_source);
189 edit_button.sensitive = false;
190
191 toolbar.insert (add_button, -1);
192 toolbar.insert (remove_button, -1);
193 toolbar.insert (edit_button, -1);
194 88
195 var container = (Gtk.Container) get_content_area ();89 var container = (Gtk.Container) get_content_area ();
196 container.add (main_grid);90 container.margin_right = container.margin_right - 5;
197 main_grid.attach (scroll, 0, 0, 1, 1);91 container.margin_left = container.margin_left - 5;
198 main_grid.attach (toolbar, 0, 1, 1, 1);92 container.add (stack);
199 }93 main_grid.show_all ();
200
201 private bool select_func (Gtk.TreeSelection selection, Gtk.TreeModel model,
202 Gtk.TreePath path, bool path_currently_selected) {
203 bool selectable = true;
204 Gtk.TreeIter iter;
205 tree_store.get_iter (out iter, path);
206
207 if (tree_store.iter_has_child (iter)) {
208 selectable = false;
209 } else {
210 activate_buttons ();
211 }
212
213 return selectable;
214 }
215
216 private void activate_buttons () {
217 edit_button.sensitive = true;
218 remove_button.sensitive = true;
219 }94 }
220 95
221 private void source_removed (E.Source source) {96 private void source_removed (E.Source source) {
222 if (iter_map.has_key (source.dup_uid ())) {97 var source_item = src_map.get (source.dup_uid ());
223 var iter = iter_map.get (source.dup_uid ());98 source_item.hide ();
224 tree_store.remove (ref iter);99 src_map.unset (source.dup_uid ());
225 iter_map.unset (source.dup_uid (), null);100 source_item.destroy ();
226 }
227 }101 }
228 102
229 private void source_added (E.Source source) {103 private void source_added (E.Source source) {
230 Gtk.TreeIter iter;104 var source_item = new SourceItem (source, calmodel);
231 E.SourceCalendar cal = (E.SourceCalendar)source.get_extension (E.SOURCE_EXTENSION_CALENDAR);105 source_item.edit_request.connect (edit_source);
232 tree_store.append (out iter, null);106 source_item.remove_request.connect (remove_source);
233 tree_store.set (iter, Columns.TOGGLE, cal.selected, Columns.TEXT, source.dup_display_name ());107
234 iter_map.set (source.dup_uid (), iter);108 calendar_grid.attach (source_item, 0, calendar_index, 1, 1);
109 int minimum_height;
110 int natural_height;
111 calendar_index++;
112 calendar_grid.show_all ();
113 calendar_grid.get_preferred_height (out minimum_height, out natural_height);
114 if (natural_height > 150) {
115 scroll.set_size_request (-1, 150);
116 } else {
117 scroll.set_size_request (-1, natural_height);
118 }
119
120 src_map.set (source.dup_uid (), source_item);
121
235 }122 }
236 123
237 private void source_disabled (E.Source source) {124 private void source_disabled (E.Source source) {
238 125 var source_item = src_map.get (source.dup_uid ());
126 source_item.source_has_changed ();
239 }127 }
240 128
241 private void source_enabled (E.Source source) {129 private void source_enabled (E.Source source) {
242 130 var source_item = src_map.get (source.dup_uid ());
131 source_item.source_has_changed ();
243 }132 }
244 133
245 private void source_changed (E.Source source) {134 private void source_changed (E.Source source) {
246 135 var source_item = src_map.get (source.dup_uid ());
136 source_item.source_has_changed ();
247 }137 }
248 138
249 private void create_source () {139 private void create_source () {
250 var dialog = new SourceDialog ();140 if (src_dialog == null) {
251 this.hide ();141 src_dialog = new SourceDialog ();
252 dialog.present ();142 src_dialog.go_back.connect (() => {switch_to_main ();});
253 }143 stack.add_named (src_dialog, "source");
254 144 }
255 private void remove_source () {145 src_dialog.set_source (null);
256 var selection = tree_view.get_selection ();146 switch_to_source ();
257 Gtk.TreeModel model;147 }
258 Gtk.TreeIter iter;148
259 selection.get_selected (out model, out iter);149 private void remove_source (E.Source source) {
260 GLib.Value src;150 calmodel.delete_calendar (source);
261 tree_store.get_value (iter, 3, out src);151 var source_item = src_map.get (source.dup_uid ());
262 var source = src as E.Source;152 source_item.show_calendar_removed ();
263 app.calmodel.delete_calendar (source);153 }
264 app.show_calendar_removed (source.display_name);154
265 this.hide ();155 private void edit_source (E.Source source) {
266 }156 if (src_dialog == null) {
267 157 src_dialog = new SourceDialog ();
268 private void edit_source () {158 src_dialog.go_back.connect (() => {switch_to_main ();});
269 var selection = tree_view.get_selection ();159 stack.add_named (src_dialog, "source");
270 Gtk.TreeModel model;160 }
271 Gtk.TreeIter iter;161 src_dialog.set_source (source);
272 selection.get_selected (out model, out iter);162 switch_to_source ();
273 GLib.Value src;163 }
274 tree_store.get_value (iter, 3, out src);164
275 var source = src as E.Source;165 private void switch_to_main () {
276 var dialog = new SourceDialog (source);166 main_grid.no_show_all = false;
277 this.hide ();167 main_grid.show ();
278 dialog.present ();168 stack.set_visible_child_full ("main", Gtk.StackTransitionType.SLIDE_RIGHT);
279 }169 src_dialog.hide ();
280 170 src_dialog.no_show_all = true;
281}171 }
172
173 private void switch_to_source () {
174 src_dialog.no_show_all = false;
175 src_dialog.show ();
176 stack.set_visible_child_full ("source", Gtk.StackTransitionType.SLIDE_LEFT);
177 main_grid.hide ();
178 main_grid.no_show_all = true;
179 }
180
181}
282\ No newline at end of file182\ No newline at end of file
283183
=== modified file 'src/View/Widgets/Postler/FlowBox.vala'
--- src/View/Widgets/Postler/FlowBox.vala 2013-11-14 18:05:39 +0000
+++ src/View/Widgets/Postler/FlowBox.vala 2014-01-18 21:06:28 +0000
@@ -11,17 +11,18 @@
1111
12namespace Maya.View.Widgets {12namespace Maya.View.Widgets {
13 public class FlowBox : Gtk.Container {13 public class FlowBox : Gtk.Container {
14 List<Gtk.Widget> children;14 Gee.LinkedList<Gtk.Widget> children;
15 int last_row_count;15 int last_row_count;
16 int last_row_height;16 int last_row_height;
1717
18 public FlowBox () {18 public FlowBox () {
19 children = new Gee.LinkedList<Gtk.Widget> ();
19 set_has_window (false);20 set_has_window (false);
20 set_resize_mode (Gtk.ResizeMode.QUEUE);21 set_resize_mode (Gtk.ResizeMode.QUEUE);
21 }22 }
2223
23 public override void add (Gtk.Widget widget) {24 public override void add (Gtk.Widget widget) {
24 children.append (widget);25 children.add (widget);
25 widget.set_parent (this);26 widget.set_parent (this);
26 if (get_realized ())27 if (get_realized ())
27 widget.realize ();28 widget.realize ();
@@ -42,9 +43,9 @@
42 callback (child);43 callback (child);
43 }44 }
4445
45 public void reorder_child (Gtk.Widget widget, int position) {46 public void add_child (Gtk.Widget widget) {
46 children.remove (widget);47 children.remove (widget);
47 children.insert (widget, position);48 children.add (widget);
48 queue_resize ();49 queue_resize ();
49 }50 }
5051
@@ -115,4 +116,4 @@
115 }116 }
116117
117 }118 }
118}119}
119\ No newline at end of file120\ No newline at end of file
120121
=== modified file 'src/View/Widgets/Postler/GuestEntry.vala'
--- src/View/Widgets/Postler/GuestEntry.vala 2013-08-31 15:14:02 +0000
+++ src/View/Widgets/Postler/GuestEntry.vala 2014-01-18 21:06:28 +0000
@@ -139,7 +139,7 @@
139 });139 });
140 button.show_all ();140 button.show_all ();
141 add (button);141 add (button);
142 reorder_child (entry, -1);142 add_child (entry);
143 empty = false;143 empty = false;
144 }144 }
145145
@@ -188,4 +188,4 @@
188 }188 }
189 }189 }
190 }190 }
191}191}
192\ No newline at end of file192\ No newline at end of file
193193
=== modified file 'src/config.vala.cmake'
--- src/config.vala.cmake 2013-08-29 17:04:35 +0000
+++ src/config.vala.cmake 2014-01-18 21:06:28 +0000
@@ -6,4 +6,5 @@
6 public const string RELEASE_NAME = "@RELEASE_NAME@";6 public const string RELEASE_NAME = "@RELEASE_NAME@";
7 public const string VERSION = "@VERSION@";7 public const string VERSION = "@VERSION@";
8 public const string VERSION_INFO = "@VERSION_INFO@";8 public const string VERSION_INFO = "@VERSION_INFO@";
9 public const string APP_NAME = "@APP_NAME@";
9}10}

Subscribers

People subscribed via source and target branches