forked from gnome-pomodoro/gnome-pomodoro
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6eb936d
commit c69fef3
Showing
12 changed files
with
805 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (c) 2013 gnome-pomodoro contributors | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Authors: Kamil Prusko <kamilprusko@gmail.com> | ||
* | ||
*/ | ||
|
||
using GLib; | ||
|
||
|
||
public class Pomodoro.Widgets.CalendarButton : Gtk.Button | ||
{ | ||
private static string DATE_TIME_FORMAT = "%a, %e %B %Y"; | ||
|
||
public int day { get; set; default = 0; } | ||
public int month { get; set; default = 0; } | ||
public int year { get; set; default = 0; } | ||
|
||
construct | ||
{ | ||
this.label = "24 July 2014"; | ||
// this.image = new Gtk.Image.from_icon_name ("x-office-calendar-symbolic", | ||
// Gtk.IconSize.MENU); | ||
// this.image_position = Gtk.PositionType.LEFT; | ||
// this.always_show_image = true; | ||
} | ||
|
||
private void show_popover () | ||
{ | ||
var calendar = new Gtk.Calendar (); | ||
calendar.halign = Gtk.Align.FILL; | ||
calendar.valign = Gtk.Align.FILL; | ||
calendar.margin = 4; | ||
calendar.show_week_numbers = false; | ||
calendar.show_heading = true; | ||
calendar.show_details = true; | ||
calendar.show_day_names = true; | ||
calendar.set_size_request (300, -1); | ||
|
||
if (this.day > 0) { | ||
calendar.day = this.day; | ||
calendar.mark_day (this.day); | ||
} | ||
|
||
if (this.month > 0) { | ||
calendar.month = this.month; | ||
} | ||
|
||
if (this.year > 0) { | ||
calendar.year = this.year; | ||
} | ||
|
||
var popover = new Gtk.Popover (this); | ||
popover.set_position (Gtk.PositionType.BOTTOM); | ||
popover.add (calendar); | ||
|
||
calendar.day_selected.connect (() => { | ||
// TODO: block notify event | ||
this.day = calendar.day; | ||
this.month = calendar.month; | ||
this.year = calendar.year; | ||
|
||
calendar.clear_marks (); | ||
calendar.mark_day (this.day); | ||
|
||
this.date_selected (); | ||
}); | ||
|
||
calendar.day_selected_double_click.connect (() => { | ||
popover.destroy (); | ||
}); | ||
|
||
popover.show_all (); | ||
} | ||
|
||
public override void clicked () | ||
{ | ||
this.show_popover (); | ||
} | ||
|
||
public virtual signal void date_selected () | ||
{ | ||
var datetime = new DateTime.local (this.year, | ||
this.month + 1, | ||
this.day, | ||
0, | ||
0, | ||
0.0); | ||
|
||
this.label = datetime.format (DATE_TIME_FORMAT); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright (c) 2013 gnome-pomodoro contributors | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Authors: Kamil Prusko <kamilprusko@gmail.com> | ||
* | ||
*/ | ||
|
||
using GLib; | ||
|
||
|
||
public class Pomodoro.Widgets.EnumComboBox : Gtk.ComboBox | ||
{ | ||
enum Column { | ||
VALUE, | ||
DISPLAY_NAME | ||
} | ||
|
||
construct { | ||
var model = new Gtk.ListStore (2, | ||
typeof (int), | ||
typeof (string)); | ||
this.model = model; | ||
|
||
var cell = new Gtk.CellRendererText (); | ||
cell.width = 120; /* TODO: make it adjustable */ | ||
|
||
this.pack_start (cell, false); | ||
this.set_attributes (cell, "text", Column.DISPLAY_NAME); | ||
|
||
this.changed.connect (() => { | ||
this.notify_property ("value"); | ||
}); | ||
} | ||
|
||
public int value { | ||
get { | ||
Gtk.TreeIter iter; | ||
int iter_value = 0; | ||
|
||
if (this.get_active_iter (out iter)) | ||
{ | ||
this.model.get (iter, | ||
Column.VALUE, out iter_value); | ||
} | ||
|
||
return iter_value; | ||
} | ||
set { | ||
Gtk.TreeIter iter; | ||
int iter_value = 0; | ||
|
||
if (this.model.get_iter_first (out iter)) | ||
{ | ||
do { | ||
this.model.get (iter, | ||
Column.VALUE, out iter_value); | ||
|
||
if (iter_value == value) { | ||
this.set_active_iter (iter); | ||
break; | ||
} | ||
} | ||
while (this.model.iter_next (ref iter)); | ||
} | ||
} | ||
} | ||
|
||
public void add_option (int value, string display_name) | ||
{ | ||
Gtk.TreeIter iter; | ||
|
||
var model = this.model as Gtk.ListStore; | ||
|
||
model.append (out iter); | ||
model.set (iter, | ||
Column.VALUE, value, | ||
Column.DISPLAY_NAME, display_name); | ||
} | ||
} |
Oops, something went wrong.