#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <stdio.h>
#include <glib.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
GtkWidget *window;
GtkWidget *prog_view;
GtkWidget *view_1;
GtkWidget *view_2;
GtkWidget *view_3;
char * GetText(GtkWidget *tview)
{
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tview));
GtkTextIter iterstart, iterend;
gtk_text_buffer_get_start_iter(buffer,&iterstart);
gtk_text_buffer_get_end_iter(buffer,&iterend);
char * data = gtk_text_buffer_get_text(buffer,&iterstart,&iterend,0);
return data;
}
void function_run()
{
char *dt1 = GetText(view_1);
char *dt2 = GetText(view_2);
char *dt3 = GetText(view_3);
char *dt4 = GetText(prog_view);
int intdt1 = atoi(dt1);
int intdt2 = atoi(dt2);
int intdt3 = atoi(dt3);
time_t t = time(NULL);
struct tm* aTm = localtime(&t);
int h = aTm->tm_hour;
int m = aTm->tm_min;
int s = aTm->tm_sec;
if (intdt1 == h && intdt2 == m && intdt3 == s)
{
WinExec(dt4,SW_SHOW);
}
}
void button_clicked(GtkWidget *widget, gpointer data)
{
gtk_timeout_add(1000,function_run,0);
}
int main( int argc,char *argv[] )
{
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window),500,500);
GtkWidget *fixed = gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(window), fixed);
GtkWidget *label_1 = gtk_label_new(g_locale_to_utf8("Часы",-1,0,0,0));
gtk_fixed_put(GTK_FIXED(fixed),label_1,0,0);
view_1 = gtk_text_view_new();
gtk_fixed_put(GTK_FIXED(fixed),view_1,0,25);
gtk_widget_set_size_request(view_1,250,20);
GtkWidget *label_2 = gtk_label_new(g_locale_to_utf8("Минуты",-1,0,0,0));
gtk_fixed_put(GTK_FIXED(fixed),label_2,0,50);
view_2 = gtk_text_view_new();
gtk_fixed_put(GTK_FIXED(fixed),view_2,0,75);
gtk_widget_set_size_request(view_2,250,20);
GtkWidget *label_3 = gtk_label_new(g_locale_to_utf8("Секунды",-1,0,0,0));
gtk_fixed_put(GTK_FIXED(fixed),label_3,0,100);
view_3 = gtk_text_view_new();
gtk_fixed_put(GTK_FIXED(fixed),view_3,0,125);
gtk_widget_set_size_request(view_3,250,20);
GtkTextBuffer *buf_1 = gtk_text_buffer_new(0);
gtk_text_buffer_set_text(buf_1,"notepad",-1);
prog_view = gtk_text_view_new();
gtk_text_view_set_buffer(prog_view,buf_1);
gtk_fixed_put(GTK_FIXED(fixed),prog_view,0,200);
gtk_widget_set_size_request(prog_view,250,20);
GtkTextBuffer *buf_2 = gtk_text_buffer_new(0);
GtkTextBuffer *buf_3 = gtk_text_buffer_new(0);
GtkTextBuffer *buf_4 = gtk_text_buffer_new(0);
gtk_text_buffer_set_text(buf_2,"0",-1);
gtk_text_buffer_set_text(buf_3,"0",-1);
gtk_text_buffer_set_text(buf_4,"0",-1);
gtk_text_view_set_buffer(view_1,buf_2);
gtk_text_view_set_buffer(view_2,buf_3);
gtk_text_view_set_buffer(view_3,buf_4);
GtkWidget *button = gtk_button_new_with_label ("run");
gtk_fixed_put(GTK_FIXED(fixed),button,0,300);
gtk_widget_show_all(window);
g_signal_connect (G_OBJECT (button), "clicked",G_CALLBACK (button_clicked), NULL);
g_signal_connect(G_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL);
gtk_main ();
return 0;
}
|