summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-06-03 02:57:19 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-06-03 02:57:19 +0200
commit39e513b0f0d03e0886ef2f201fc3d9e1e6186f8b (patch)
tree3ac1584af061f9f8bf489a9ebc7ead51678d2cbc
parent0230508fb3cc88a8801a35d4b13947bcd10c86ae (diff)
downloaddclock-39e513b0f0d03e0886ef2f201fc3d9e1e6186f8b.tar
dclock-39e513b0f0d03e0886ef2f201fc3d9e1e6186f8b.zip
Fixed intentation
-rw-r--r--DClock.vala389
-rw-r--r--DDate.vala176
2 files changed, 282 insertions, 283 deletions
diff --git a/DClock.vala b/DClock.vala
index 14abcc1..f59b4f9 100644
--- a/DClock.vala
+++ b/DClock.vala
@@ -4,233 +4,232 @@ using Pango;
using Panel;
public class DClock : Panel.Applet {
- private Gtk.ToggleButton button = null;
- private Gtk.Label label = null;
- private Panel.AppletOrient orient = (Panel.AppletOrient)(-1);
- private BonoboUI.Verb[] verbs = null;
- private time_t current_time;
- private uint timeout = 0;
+ private Gtk.ToggleButton button = null;
+ private Gtk.Label label = null;
+ private Panel.AppletOrient orient = (Panel.AppletOrient)(-1);
+ private BonoboUI.Verb[] verbs = null;
+ private time_t current_time;
+ private uint timeout = 0;
- private int size;
- private int fixed_width = -1;
- private int fixed_height = -1;
- private Gtk.Allocation old_allocation;
-
- public DClock() {
- }
-
- static construct {
- Gtk.rc_parse_string("\n" +
- " style \"dclock-applet-button-style\"\n" +
- " {\n" +
- " GtkWidget::focus-line-width=0\n" +
- " GtkWidget::focus-padding=0\n" +
- " }\n" +
- "\n" +
- " widget \"*.dclock-applet-button\" style \"dclock-applet-button-style\"\n" +
- "\n");
- }
-
- private void create() {
- set_flags(Panel.AppletFlags.EXPAND_MINOR);
+ private int size;
+ private int fixed_width = -1;
+ private int fixed_height = -1;
+ private Gtk.Allocation old_allocation;
+
+ public DClock() {
+ }
+
+ static construct {
+ Gtk.rc_parse_string("\n" +
+ " style \"dclock-applet-button-style\"\n" +
+ " {\n" +
+ " GtkWidget::focus-line-width=0\n" +
+ " GtkWidget::focus-padding=0\n" +
+ " }\n" +
+ "\n" +
+ " widget \"*.dclock-applet-button\" style \"dclock-applet-button-style\"\n" +
+ "\n");
+ }
+
+ private void create() {
+ set_flags(Panel.AppletFlags.EXPAND_MINOR);
- button = new Gtk.ToggleButton();
- button.set_relief(Gtk.ReliefStyle.NONE);
- button.set_name("dclock-applet-button");
- GLib.Signal.connect(button, "button_press_event", (GLib.Callback)do_not_eat_button_press, null);
- GLib.Signal.connect(this, "change_orient", (GLib.Callback)applet_change_orient, this);
- GLib.Signal.connect(button, "size_allocate", (GLib.Callback)change_pixel_size, this);
- this.add(button);
+ button = new Gtk.ToggleButton();
+ button.set_relief(Gtk.ReliefStyle.NONE);
+ button.set_name("dclock-applet-button");
+ GLib.Signal.connect(button, "button_press_event", (GLib.Callback)do_not_eat_button_press, null);
+ GLib.Signal.connect(this, "change_orient", (GLib.Callback)applet_change_orient, this);
+ GLib.Signal.connect(button, "size_allocate", (GLib.Callback)change_pixel_size, this);
+ this.add(button);
- label = new Gtk.Label(null);
- GLib.Signal.connect(label, "size_request", (GLib.Callback)clock_size_request, this);
- GLib.Signal.connect_swapped(label, "style_set", (GLib.Callback)unfix_size, this);
- label.set_justify(Gtk.Justification.CENTER);
- clock_update_text_gravity(label);
- GLib.Signal.connect(label, "screen-changed", (GLib.Callback)clock_update_text_gravity, null);
- button.add(label);
+ label = new Gtk.Label(null);
+ GLib.Signal.connect(label, "size_request", (GLib.Callback)clock_size_request, this);
+ GLib.Signal.connect_swapped(label, "style_set", (GLib.Callback)unfix_size, this);
+ label.set_justify(Gtk.Justification.CENTER);
+ clock_update_text_gravity(label);
+ GLib.Signal.connect(label, "screen-changed", (GLib.Callback)clock_update_text_gravity, null);
+ button.add(label);
- set_border_width(0);
- size = (int)get_size();
+ set_border_width(0);
+ size = (int)get_size();
- set_background_widget(this);
+ set_background_widget(this);
- verbs = new BonoboUI.Verb[2];
+ verbs = new BonoboUI.Verb[2];
- verbs[0].cname = "About";
- verbs[0].cb = on_about_clicked;
- verbs[0].user_data = this;
+ verbs[0].cname = "About";
+ verbs[0].cb = on_about_clicked;
+ verbs[0].user_data = this;
- verbs[1].cname = null;
- verbs[1].cb = null;
- verbs[1].user_data = null;
+ verbs[1].cname = null;
+ verbs[1].cb = null;
+ verbs[1].user_data = null;
- string menuxml = "<popup name=\"button3\">" +
- "<menuitem name=\"About Item\" verb=\"About\" _label=\"About\" pixtype=\"stock\" pixname=\"gnome-stock-about\"/>" +
- "</popup>";
- setup_menu(menuxml, verbs, this);
+ string menuxml = "<popup name=\"button3\">" +
+ "<menuitem name=\"About Item\" verb=\"About\" _label=\"About\" pixtype=\"stock\" pixname=\"gnome-stock-about\"/>" +
+ "</popup>";
+ setup_menu(menuxml, verbs, this);
- show_all();
+ show_all();
- refresh_clock_timeout();
- applet_change_orient(this, get_orient(), this);
- }
-
- private void unfix_size() {
- fixed_width = -1;
- fixed_height = -1;
- button.queue_resize();
- }
-
- private static void clock_size_request (Gtk.Widget clock, Gtk.Requisition req, DClock data) {
- if(req.width > data.fixed_width)
- data.fixed_width = req.width;
- if (req.height > data.fixed_height)
- data.fixed_height = req.height;
- req.width = data.fixed_width;
- req.height = data.fixed_height;
- }
+ refresh_clock_timeout();
+ applet_change_orient(this, get_orient(), this);
+ }
+
+ private void unfix_size() {
+ fixed_width = -1;
+ fixed_height = -1;
+ button.queue_resize();
+ }
+
+ private static void clock_size_request (Gtk.Widget clock, Gtk.Requisition req, DClock data) {
+ if(req.width > data.fixed_width)
+ data.fixed_width = req.width;
+ if (req.height > data.fixed_height)
+ data.fixed_height = req.height;
+ req.width = data.fixed_width;
+ req.height = data.fixed_height;
+ }
- private static void clock_update_text_gravity(Gtk.Label label) {
- Pango.Layout layout;
- Pango.Context context;
-
- layout = label.get_layout();
- context = layout.get_context();
- context.set_base_gravity(Pango.Gravity.AUTO);
- }
- private void update_timeformat() {
-
- }
-
- private void update_clock() {
- current_time = time_t();
- string date_str = DDate.with_time_t(current_time).to_string();
- string time_str = Time.local(current_time).format("%H:%M");
-
- label.set_text(date_str + ", " + time_str);
-
- update_orient();
- button.queue_resize();
- }
-
- /*private void refresh_clock() {
- unfix_size();
- update_clock();
- }*/
+ private static void clock_update_text_gravity(Gtk.Label label) {
+ Pango.Layout layout;
+ Pango.Context context;
+
+ layout = label.get_layout();
+ context = layout.get_context();
+ context.set_base_gravity(Pango.Gravity.AUTO);
+ }
+ private void update_timeformat() {
+
+ }
+
+ private void update_clock() {
+ current_time = time_t();
+ string date_str = DDate.with_time_t(current_time).to_string();
+ string time_str = Time.local(current_time).format("%H:%M");
+
+ label.set_text(date_str + ", " + time_str);
+
+ update_orient();
+ button.queue_resize();
+ }
+
+ /*private void refresh_clock() {
+ unfix_size();
+ update_clock();
+ }*/
- private void refresh_clock_timeout() {
- unfix_size();
+ private void refresh_clock_timeout() {
+ unfix_size();
- update_timeformat();
+ update_timeformat();
- if (timeout != 0)
- GLib.Source.remove (timeout);
+ if (timeout != 0)
+ GLib.Source.remove (timeout);
- update_clock();
+ update_clock();
- clock_set_timeout(current_time);
- }
+ clock_set_timeout(current_time);
+ }
- /*private void refresh_click_timeout_time_only() {
- if (timeout != 0)
- GLib.Source.remove (timeout);
-
- clock_timeout_callback(this);
- }*/
-
- private void clock_set_timeout(time_t now) {
- uint timeouttime;
-
- GLib.TimeVal tv = GLib.TimeVal();
-
- timeouttime = (uint)((1000000 - tv.tv_usec)/1000 + 1 + 1000*(59 - now % 60));
-
- timeout = GLib.Timeout.add (timeouttime, clock_timeout_callback);
- }
-
- private bool clock_timeout_callback() {
- time_t new_time = time_t();
-
- if(new_time/60 != current_time/60) {
- update_clock();
- }
-
- clock_set_timeout(new_time);
-
- return false;
- }
-
- private static void on_about_clicked(BonoboUI.Component component, void* user_data, string cname) {
+ /*private void refresh_click_timeout_time_only() {
+ if (timeout != 0)
+ GLib.Source.remove (timeout);
+
+ clock_timeout_callback(this);
+ }*/
+
+ private void clock_set_timeout(time_t now) {
+ uint timeouttime;
+
+ GLib.TimeVal tv = GLib.TimeVal();
+
+ timeouttime = (uint)((1000000 - tv.tv_usec)/1000 + 1 + 1000*(59 - now % 60));
- }
+ timeout = GLib.Timeout.add (timeouttime, clock_timeout_callback);
+ }
- private static bool do_not_eat_button_press(Gtk.Widget widget, Gdk.EventButton event) {
- if(event.button != 1)
- GLib.Signal.stop_emission_by_name(widget, "button_press_event");
+ private bool clock_timeout_callback() {
+ time_t new_time = time_t();
+
+ if(new_time/60 != current_time/60) {
+ update_clock();
+ }
+
+ clock_set_timeout(new_time);
+
+ return false;
+ }
+
+ private static void on_about_clicked(BonoboUI.Component component, void* user_data, string cname) {
+
+ }
- return false;
- }
+ private static bool do_not_eat_button_press(Gtk.Widget widget, Gdk.EventButton event) {
+ if(event.button != 1)
+ GLib.Signal.stop_emission_by_name(widget, "button_press_event");
- private static void change_pixel_size(Gtk.Widget widget, Gtk.Allocation allocation, DClock clock) {
- if(clock.old_allocation.width == allocation.width && clock.old_allocation.height == allocation.height)
- return;
+ return false;
+ }
+
+ private static void change_pixel_size(Gtk.Widget widget, Gtk.Allocation allocation, DClock clock) {
+ if(clock.old_allocation.width == allocation.width && clock.old_allocation.height == allocation.height)
+ return;
- clock.old_allocation.width = allocation.width;
- clock.old_allocation.height = allocation.height;
+ clock.old_allocation.width = allocation.width;
+ clock.old_allocation.height = allocation.height;
- int new_size;
+ int new_size;
- if(clock.orient == Panel.AppletOrient.LEFT || clock.orient == Panel.AppletOrient.RIGHT)
- new_size = allocation.width;
- else
- new_size = allocation.height;
+ if(clock.orient == Panel.AppletOrient.LEFT || clock.orient == Panel.AppletOrient.RIGHT)
+ new_size = allocation.width;
+ else
+ new_size = allocation.height;
- clock.size = new_size;
+ clock.size = new_size;
- clock.unfix_size();
- clock.update_timeformat();
- clock.update_clock();
- }
+ clock.unfix_size();
+ clock.update_timeformat();
+ clock.update_clock();
+ }
- void update_orient() {
- double new_angle;
- double angle;
+ void update_orient() {
+ double new_angle;
+ double angle;
- if(orient == Panel.AppletOrient.LEFT)
- new_angle = 270;
- else if(orient == Panel.AppletOrient.RIGHT)
- new_angle = 90;
- else
- new_angle = 0;
+ if(orient == Panel.AppletOrient.LEFT)
+ new_angle = 270;
+ else if(orient == Panel.AppletOrient.RIGHT)
+ new_angle = 90;
+ else
+ new_angle = 0;
- angle = label.get_angle();
- if (angle != new_angle) {
- unfix_size();
- label.set_angle(new_angle);
- }
- }
+ angle = label.get_angle();
+ if (angle != new_angle) {
+ unfix_size();
+ label.set_angle(new_angle);
+ }
+ }
- private static void applet_change_orient(Panel.Applet applet, Panel.AppletOrient orient, DClock clock) {
- if(orient == clock.orient)
- return;
+ private static void applet_change_orient(Panel.Applet applet, Panel.AppletOrient orient, DClock clock) {
+ if(orient == clock.orient)
+ return;
- clock.orient = orient;
+ clock.orient = orient;
- clock.unfix_size();
- clock.update_clock();
- //update_calendar_popup (cd);
- }
-
- private static bool factory(DClock applet, string iid, void *data) {
- applet.create();
- return true;
- }
-
- public static int main(string[] args) {
- Gnome.Program.init("DClock", "0", Gnome.libgnomeui_module, args);
- return Panel.Applet.factory_main("OAFIID:GNOME_DClock_Factory", typeof(DClock), (Panel.AppletFactoryCallback)factory);
- }
+ clock.unfix_size();
+ clock.update_clock();
+ //update_calendar_popup (cd);
+ }
+
+ private static bool factory(DClock applet, string iid, void *data) {
+ applet.create();
+ return true;
+ }
+
+ public static int main(string[] args) {
+ Gnome.Program.init("DClock", "0", Gnome.libgnomeui_module, args);
+ return Panel.Applet.factory_main("OAFIID:GNOME_DClock_Factory", typeof(DClock), (Panel.AppletFactoryCallback)factory);
+ }
}
-
diff --git a/DDate.vala b/DDate.vala
index 54c1064..b29944d 100644
--- a/DDate.vala
+++ b/DDate.vala
@@ -1,98 +1,98 @@
using GLib;
public enum DDateMonth {
- CHAOS = 0, DISCORD = 1, CONFUSION = 2, BUREAUCRACY = 3, THE_AFTERMATH = 4, ST_TIBS_DAY;
-
- public string to_short_string() {
- switch(this) {
- case CHAOS:
- return "Chs";
- case DISCORD:
- return "Dsc";
- case CONFUSION:
- return "Cfn";
- case BUREAUCRACY:
- return "Bcy";
- case THE_AFTERMATH:
- return "Afm";
- default:
- return "St. Tib's Day";
- }
- }
+ CHAOS = 0, DISCORD = 1, CONFUSION = 2, BUREAUCRACY = 3, THE_AFTERMATH = 4, ST_TIBS_DAY;
+
+ public string to_short_string() {
+ switch(this) {
+ case CHAOS:
+ return "Chs";
+ case DISCORD:
+ return "Dsc";
+ case CONFUSION:
+ return "Cfn";
+ case BUREAUCRACY:
+ return "Bcy";
+ case THE_AFTERMATH:
+ return "Afm";
+ default:
+ return "St. Tib's Day";
+ }
+ }
}
public enum DDateWeekday {
- SWEETMORN = 0, BOOMTIME = 1, PUNGENDAY = 2, PRICKLE_PRICKLE = 3, SETTING_ORANGE = 4, ST_TIBS_DAY;
-
- public string to_short_string() {
- switch(this) {
- case SWEETMORN:
- return "SM";
- case BOOMTIME:
- return "BT";
- case PUNGENDAY:
- return "PD";
- case PRICKLE_PRICKLE:
- return "PP";
- case SETTING_ORANGE:
- return "SO";
- default:
- return "St. Tib's Day";
- }
- }
+ SWEETMORN = 0, BOOMTIME = 1, PUNGENDAY = 2, PRICKLE_PRICKLE = 3, SETTING_ORANGE = 4, ST_TIBS_DAY;
+
+ public string to_short_string() {
+ switch(this) {
+ case SWEETMORN:
+ return "SM";
+ case BOOMTIME:
+ return "BT";
+ case PUNGENDAY:
+ return "PD";
+ case PRICKLE_PRICKLE:
+ return "PP";
+ case SETTING_ORANGE:
+ return "SO";
+ default:
+ return "St. Tib's Day";
+ }
+ }
}
public struct DDate {
- private GLib.Date date;
-
- private uint get_day_of_year() {
- if (date.get_year().is_leap_year() && date.get_day_of_year() > 60)
- return date.get_day_of_year()-1;
- else
- return date.get_day_of_year();
- }
-
- public DDate(GLib.Date date0) {
- date = date0;
- }
-
- public DDate.with_time_t(time_t time) {
- date = Date();
- date.set_time_t(time);
- }
-
- public bool is_st_tibs_day() {
- return (date.get_month() == GLib.DateMonth.FEBRUARY && date.get_day() == 29);
- }
-
- public uchar get_day() {
- return (uchar)(get_day_of_year() % 73);
- }
-
- public DDateMonth get_month() {
- if(is_st_tibs_day())
- return DDateMonth.ST_TIBS_DAY;
-
- return (DDateMonth)(get_day_of_year()/73);
- }
-
- public DDateWeekday get_weekday() {
- if(is_st_tibs_day())
- return DDateWeekday.ST_TIBS_DAY;
-
- return (DDateWeekday)((get_day_of_year()-1)%5);
- }
-
- public string to_string() {
- string ret = "";
-
- if(is_st_tibs_day()) {
- ret = "St. Tib's Day";
- }
- else {
- ret = get_weekday().to_short_string() + ", " + get_day().to_string() + ". " + get_month().to_short_string();
- }
-
- return ret;
- }
+ private GLib.Date date;
+
+ private uint get_day_of_year() {
+ if (date.get_year().is_leap_year() && date.get_day_of_year() > 60)
+ return date.get_day_of_year()-1;
+ else
+ return date.get_day_of_year();
+ }
+
+ public DDate(GLib.Date date0) {
+ date = date0;
+ }
+
+ public DDate.with_time_t(time_t time) {
+ date = Date();
+ date.set_time_t(time);
+ }
+
+ public bool is_st_tibs_day() {
+ return (date.get_month() == GLib.DateMonth.FEBRUARY && date.get_day() == 29);
+ }
+
+ public uchar get_day() {
+ return (uchar)(get_day_of_year() % 73);
+ }
+
+ public DDateMonth get_month() {
+ if(is_st_tibs_day())
+ return DDateMonth.ST_TIBS_DAY;
+
+ return (DDateMonth)(get_day_of_year()/73);
+ }
+
+ public DDateWeekday get_weekday() {
+ if(is_st_tibs_day())
+ return DDateWeekday.ST_TIBS_DAY;
+
+ return (DDateWeekday)((get_day_of_year()-1)%5);
+ }
+
+ public string to_string() {
+ string ret = "";
+
+ if(is_st_tibs_day()) {
+ ret = "St. Tib's Day";
+ }
+ else {
+ ret = get_weekday().to_short_string() + ", " + get_day().to_string() + ". " + get_month().to_short_string();
+ }
+
+ return ret;
+ }
}