summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt15
-rw-r--r--logging.cpp20
-rw-r--r--logging.h17
-rw-r--r--main.cpp16
-rw-r--r--totimer.cpp51
-rw-r--r--totimer.h16
6 files changed, 135 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..fefeba2
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.3)
+project(pomodori)
+
+INCLUDE(FindPkgConfig)
+
+pkg_check_modules(GTKLIB REQUIRED "gtk+-2.0")
+include_directories(${GTKLIB_INCLUDE_DIRS})
+link_directories(${GTKLIB_LIBRARY_DIRS})
+
+set(CMAKE_CXX_FLAGS " -std=c++11 -lnotify")
+
+set(SOURCE_FILES main.cpp totimer.cpp totimer.h logging.cpp logging.h)
+add_executable(pomodori ${SOURCE_FILES})
+
+target_link_libraries(pomodori ${GTKLIB_LIBRARIES}) \ No newline at end of file
diff --git a/logging.cpp b/logging.cpp
new file mode 100644
index 0000000..d426978
--- /dev/null
+++ b/logging.cpp
@@ -0,0 +1,20 @@
+//
+// Created by joe on 9/3/15.
+//
+
+#include "logging.h"
+#include "stdlib.h"
+#include<iostream>
+#include <fstream>
+
+using namespace std;
+void log(tres* res,int code)
+{
+ if (code)
+ {
+ ofstream fot;
+ fot.open("~/.pomodori");
+ fot<<1<<endl;
+ }
+ exit(0);
+} \ No newline at end of file
diff --git a/logging.h b/logging.h
new file mode 100644
index 0000000..1f655dd
--- /dev/null
+++ b/logging.h
@@ -0,0 +1,17 @@
+//
+// Created by joe on 9/3/15.
+//
+
+#ifndef POMODORI_LOGGING_H
+#define POMODORI_LOGGING_H
+
+#include <glib.h>
+
+typedef struct tres {
+ guint32 time;
+ const char* reason;
+} tres;
+
+void log(tres* res,int code);
+
+#endif //POMODORI_LOGGING_H
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..a997880
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,16 @@
+#include <glib.h>
+#include<libnotify/notify.h>
+#include <gtk/gtk.h>
+#include "logging.h"
+#include "totimer.h"
+
+int main(int argc, char** argv)
+{
+ gtk_init(&argc, &argv);
+ notify_init("Tomodori");
+ tres lastres;
+ lastres.time=0;
+ settimer(&lastres,1);
+ gtk_main();
+ return 0;
+} \ No newline at end of file
diff --git a/totimer.cpp b/totimer.cpp
new file mode 100644
index 0000000..8bdbfe2
--- /dev/null
+++ b/totimer.cpp
@@ -0,0 +1,51 @@
+//
+// Created by joe on 9/3/15.
+//
+
+#include "totimer.h"
+#include<stdlib.h>
+#include<stdio.h>
+
+void quit(NotifyNotification *note,gpointer user_data)
+{
+ tres* lastres = (tres*)user_data;
+ log(lastres,0);
+}
+
+void timeup(NotifyNotification *note,const char *action,gpointer user_data){
+ g_object_unref(G_OBJECT(note));
+ tres* lastres = (tres*)user_data;
+ switch (action[0]){
+ case 'M':
+ settimer(lastres, 5);
+ break;
+ case 'G':
+ log(lastres,1);
+ break;
+ case 'F':
+ default:
+ log(lastres,0);
+ break;
+ }
+}
+
+bool notify(gpointer user_data)
+{
+ tres* lastres = (tres*)user_data;
+ NotifyNotification *n;
+ n = notify_notification_new ("Tomodori","Time's Up", NULL);
+ notify_notification_set_urgency(n,NOTIFY_URGENCY_CRITICAL);
+ notify_notification_add_action(n,"M", "More",(NotifyActionCallback)timeup,lastres,NULL);
+ notify_notification_add_action(n,"G", "Good",(NotifyActionCallback)timeup,lastres,NULL);
+ g_signal_connect (n, "closed", G_CALLBACK(quit), NULL);
+// printf("1");
+ notify_notification_set_timeout(n,0); //3 seconds
+ notify_notification_show(n,NULL);
+ return FALSE;
+}
+
+int settimer(tres* lastres, guint32 wait)
+{
+ lastres->time = lastres->time + wait;
+ g_timeout_add(wait*60*1000,(GSourceFunc)notify,lastres);
+} \ No newline at end of file
diff --git a/totimer.h b/totimer.h
new file mode 100644
index 0000000..19c51b9
--- /dev/null
+++ b/totimer.h
@@ -0,0 +1,16 @@
+//
+// Created by joe on 9/3/15.
+//
+
+#ifndef POMODORI_TOTIMER_H
+#define POMODORI_TOTIMER_H
+
+#include <libnotify/notify.h>
+#include "logging.h"
+#include "glib.h"
+
+bool notify(gpointer user_data);
+
+int settimer(tres* lastres,guint32 wait);
+
+#endif //POMODORI_TOTIMER_H