void notification_service(int sleep_seconds) { while (1) { list_load(); list_sort(); send_next_notification(); fflush(stdout); list_save(); sleep(sleep_seconds); } exit(EXIT_SUCCESS); }
void sphinx_gui_list_remove(GtkWidget *button, gpointer userdata) { GtkTreeView *tree = userdata; GtkTreeModel *store = gtk_tree_view_get_model(tree); GtkTreeIter iter; GtkTreeSelection *sel = gtk_tree_view_get_selection(tree); if (gtk_tree_selection_get_selected(sel, &store, &iter)) { gtk_list_store_remove(GTK_LIST_STORE(store), &iter); } list_save(store); }
static void list_edit(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data) { GtkTreeView *tree = user_data; GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(tree)); gint column = (gint)g_object_get_qdata(G_OBJECT(renderer), g_quark_from_static_string("column")); GtkTreePath *tree_path = gtk_tree_path_new_from_string(path); GtkTreeIter iter; gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, tree_path); gtk_tree_path_free(tree_path); gtk_list_store_set(store, &iter, column, new_text, -1); list_save(GTK_TREE_MODEL(store)); }
void sphinx_gui_list_add(GtkWidget *button, gpointer user_data) { GtkTreeView *tree = user_data; GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(tree)); GtkTreeIter iter; GtkWidget *phrase; GtkWidget *command; GtkWidget *label; GtkWidget *box; GtkWidget *dialog = gtk_dialog_new_with_buttons ("Add an action", GTK_WINDOW(gtk_widget_get_toplevel(button)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); label = gtk_label_new("Phrase"); gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 2); phrase = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(box), phrase, TRUE, TRUE, 2); gtk_container_add(GTK_CONTAINER(content), box); box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); label = gtk_label_new("Command"); gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 2); command = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(box), command, TRUE, TRUE, 2); gtk_container_add(GTK_CONTAINER(content), box); gtk_widget_show_all(content); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, gtk_entry_get_text(GTK_ENTRY(phrase)), 1, gtk_entry_get_text(GTK_ENTRY(command)), -1); } gtk_widget_destroy(dialog); list_save(GTK_TREE_MODEL(store)); }
/* Run in non-interactive mode */ void nonInteractive_run( OPTIONS *opts, int argc, char **argv ) { if ( argc == 1 ) { MESSAGE *msg = NULL; list_init( &msg ); list_load( msg ); nonInteractive_appendMessage( msg ); msg->root->hasChanged = true; /* Clean up */ list_save( msg ); list_destroy( &msg ); } else { /* If we get here there are command line arguments, parse and execute them */ options_parse( opts, argc, argv ); options_execute( opts ); } }
static void destroy (GtkWidget *window, gpointer data) { list_save(); gtk_main_quit(); }
void save_trains(LIST *trains, FILE* fp){ list_save(trains, fp, _save_train); }
static void _save_train(void *elem, FILE *fp){ TRAIN *train = (TRAIN*)elem; fwrite(train, sizeof(TRAIN), 1, fp); list_save(train->stations, fp, NULL); }