extracted ui code to create a new task
authorJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 25 Nov 2013 21:56:20 +0000 (21:56 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Mon, 25 Nov 2013 21:56:20 +0000 (21:56 +0000)
src/Makefile.am
src/Makefile.in
src/main.c
src/ui.c
src/ui.h
src/ui_newtask_diag.c [new file with mode: 0644]
src/ui_newtask_diag.h [new file with mode: 0644]

index 84f2093..e8dae2f 100644 (file)
@@ -17,7 +17,8 @@ ptask_SOURCES = main.c \
        pstr.c pstr.h \
        ptime.c ptime.h \
        tw.c tw.h \
-       ui.c ui.h
+       ui.c ui.h \
+       ui_newtask_diag.c ui_newtask_diag.h
 
 dist_man_MANS = ptask.1
 
index ccfd917..3b3042d 100644 (file)
@@ -66,7 +66,8 @@ CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
 PROGRAMS = $(bin_PROGRAMS)
 am_ptask_OBJECTS = main.$(OBJEXT) log.$(OBJEXT) note.$(OBJEXT) \
-       pstr.$(OBJEXT) ptime.$(OBJEXT) tw.$(OBJEXT) ui.$(OBJEXT)
+       pstr.$(OBJEXT) ptime.$(OBJEXT) tw.$(OBJEXT) ui.$(OBJEXT) \
+       ui_newtask_diag.$(OBJEXT)
 ptask_OBJECTS = $(am_ptask_OBJECTS)
 ptask_LDADD = $(LDADD)
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -294,7 +295,8 @@ ptask_SOURCES = main.c \
        pstr.c pstr.h \
        ptime.c ptime.h \
        tw.c tw.h \
-       ui.c ui.h
+       ui.c ui.h \
+       ui_newtask_diag.c ui_newtask_diag.h
 
 dist_man_MANS = ptask.1
 gsettings_SCHEMAS = ptask.gschema.xml
@@ -390,6 +392,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptime.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tw.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_newtask_diag.Po@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
index 29204e9..2171895 100644 (file)
@@ -148,7 +148,7 @@ static void clear_task_panel()
        gtk_widget_set_sensitive(GTK_WIDGET(w_priority), 0);
 }
 
-static void refresh()
+void refresh()
 {
        GtkWidget *dialog;
        GtkTreeModel *model;
@@ -293,47 +293,6 @@ int refresh_clicked_cbk(GtkButton *btn, gpointer data)
        return FALSE;
 }
 
-int newtask_clicked_cbk(GtkButton *btn, gpointer data)
-{
-       gint result;
-       static GtkDialog *diag;
-       GtkBuilder *builder;
-       GtkEntry *entry;
-       const char *ctxt;
-
-       log_debug("newtask_clicked_cbk");
-
-       builder = gtk_builder_new();
-       gtk_builder_add_from_file
-               (builder,
-                PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "ptask.glade",
-                NULL);
-       diag = GTK_DIALOG(gtk_builder_get_object(builder, "diag_tasknew"));
-       gtk_builder_connect_signals(builder, NULL);
-
-       result = gtk_dialog_run(diag);
-
-       if (result == GTK_RESPONSE_ACCEPT) {
-               log_debug("ok");
-               entry = GTK_ENTRY(gtk_builder_get_object
-                                 (builder, "diag_tasknew_description"));
-               ctxt = gtk_entry_get_text(entry);
-
-               log_debug("%s", ctxt);
-
-               tw_add(ctxt);
-               refresh();
-       } else {
-               log_debug("cancel");
-       }
-
-       g_object_unref(G_OBJECT(builder));
-
-       gtk_widget_destroy(GTK_WIDGET(diag));
-
-       return FALSE;
-}
-
 static int status_changed_cbk(GtkComboBox *w, gpointer data)
 {
        log_debug("status_changed_cbk");
index 83e9876..eda9ecc 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
 
 #include <log.h>
 #include <ui.h>
+#include <ui_newtask_diag.h>
 
 static GtkTreeView *w_treeview;
 
+int newtask_clicked_cbk(GtkButton *btn, gpointer data)
+{
+       ui_newtask();
+
+       return FALSE;
+}
+
+
 static void save_settings(GtkWindow *window, GSettings *settings)
 {
        int w, h, x, y, sort_col_id;
index 27aebce..54914e3 100644 (file)
--- a/src/ui.h
+++ b/src/ui.h
@@ -23,5 +23,6 @@
 #include <gtk/gtk.h>
 
 GtkWindow *create_window(GtkBuilder *, GSettings *);
+void refresh();
 
 #endif
diff --git a/src/ui_newtask_diag.c b/src/ui_newtask_diag.c
new file mode 100644 (file)
index 0000000..96d0291
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2012-2013 jeanfi@gmail.com
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <gtk/gtk.h>
+
+#include <log.h>
+#include <tw.h>
+#include <ui.h>
+
+void ui_newtask()
+{
+       gint result;
+       static GtkDialog *diag;
+       GtkBuilder *builder;
+       GtkEntry *entry;
+       const char *ctxt;
+
+       log_debug("newtask_clicked_cbk");
+
+       builder = gtk_builder_new();
+       gtk_builder_add_from_file
+               (builder,
+                PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "ptask.glade",
+                NULL);
+       diag = GTK_DIALOG(gtk_builder_get_object(builder, "diag_tasknew"));
+       gtk_builder_connect_signals(builder, NULL);
+
+       result = gtk_dialog_run(diag);
+
+       if (result == GTK_RESPONSE_ACCEPT) {
+               log_debug("ok");
+               entry = GTK_ENTRY(gtk_builder_get_object
+                                 (builder, "diag_tasknew_description"));
+               ctxt = gtk_entry_get_text(entry);
+
+               log_debug("%s", ctxt);
+
+               tw_add(ctxt);
+               refresh();
+       } else {
+               log_debug("cancel");
+       }
+
+       g_object_unref(G_OBJECT(builder));
+
+       gtk_widget_destroy(GTK_WIDGET(diag));
+}
diff --git a/src/ui_newtask_diag.h b/src/ui_newtask_diag.h
new file mode 100644 (file)
index 0000000..d9e5e26
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2012-2013 jeanfi@gmail.com
+ *
+ * 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 2 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _PTASK_UI_NEWTASK_DIAG_H_
+#define _PTASK_UI_NEWTASK_DIAG_H_
+
+void ui_newtask();
+
+#endif