Exemplo n.º 1
0
GtkWidget *sphinx_gui_list_new() {
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeIter iter;
	GtkListStore *store = gtk_list_store_new(2, G_TYPE_STRING,
						G_TYPE_STRING);
	GtkTreeView *list = GTK_TREE_VIEW(gtk_tree_view_new_with_model(
			GTK_TREE_MODEL(store)));
	GtkTreeSelection *sel = gtk_tree_view_get_selection(list);
	gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);

	list_load(store);

	column = gtk_tree_view_column_new();
	renderer = gtk_cell_renderer_text_new();
	g_object_set_qdata_full(G_OBJECT(renderer),
		g_quark_from_static_string("column"), (gpointer)0, NULL);
	g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
	g_signal_connect(renderer, "edited", G_CALLBACK(list_edit), list);
	gtk_tree_view_insert_column_with_attributes(list, -1, "Phrase",
						renderer, "text", 0, NULL);

	column = gtk_tree_view_column_new();
	renderer = gtk_cell_renderer_text_new();
	g_object_set_qdata_full(G_OBJECT(renderer),
		g_quark_from_static_string("column"), (gpointer)1, NULL);
	g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
	g_signal_connect(renderer, "edited", G_CALLBACK(list_edit), list),
	gtk_tree_view_insert_column_with_attributes(list, -1, "Command",
						renderer, "text", 1, NULL);

	return GTK_WIDGET(list);
}
Exemplo n.º 2
0
void viewer_load(viewer_t *viewer, char *filename)
{
  viewer_clear(viewer);
  viewer_setup(viewer, filename);

  if ( viewer->filename != NULL ) {
    viewer->loaded = (list_load(viewer->list, viewer->filename) == 0);
  }
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
/* 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 );
    }

}
Exemplo n.º 5
0
int viewer_follow(viewer_t *viewer, int moveto)
{
  int ret;

  if ( viewer == NULL )
    return -1;
  if ( viewer->filename == NULL )
    return -1;

  if ( viewer->loaded ) {
    ret = list_follow(viewer->list, moveto);
    if ( ret )
      fprintf(stderr, NAME ": WARNING: Cannot follow file %s\n", viewer->filename);
  }
  else {
    ret = list_load(viewer->list, viewer->filename);
    viewer->loaded = (ret == 0);
  }

  return ret;
}
Exemplo n.º 6
0
int main (int argc, char *argv[]) {

  char lang[128] = "de-DE";
  guint j, notify_time_cycle = 0;

  if (argc > 2) {
    for (j = 1; j < argc; j++) {
      if (strcmp(argv[j], "-notify") == 0 && atoi(argv[j+1]) > 0) {
        notify_time_cycle = atoi(argv[j+1]);
      }
      if (strcmp(argv[j], "-lang") == 0 && strlen(argv[j+1]) > 0) {
        strncpy(lang, argv[j+1], sizeof(lang));
      }
      j++;
    }
  }

  phrases_set_lang(lang);
  phrases_load();
  list_get_file();

  if (notify_time_cycle > 0) {
    notification_service(notify_time_cycle);
  }
  list_load();
  list_sort();

  GtkWidget *window, *vbox, *treeview, *scrolled_win;
  GtkWidget *hbox_buttons, *button_add, *button_remove;
  GtkListStore *store;
  GtkTreeIter iter;
  GtkTreeSelection *selection;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "gEventlist");
  gtk_container_set_border_width(GTK_CONTAINER(window), 10);
  gtk_widget_set_size_request(window, 480, 360);

  g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);

  // teeview / scrolled_win
  treeview = gtk_tree_view_new();
  setup_tree_view(treeview);

  store = gtk_list_store_new(COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);

  guint i = 0;
  while (i < list_length) {
    st_gtk_list_item temp = get_gtk_list_item(i);

    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter,
      TYPE, temp.type, DATE, temp.date, TIME, temp.time,
      TEXT, temp.text, CYCLE, temp.cycle,
      -1
    );
    i++;
  }

  gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(store));
  g_object_unref(store);

  selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
  gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);

  scrolled_win = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_win),
                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_container_add(GTK_CONTAINER(scrolled_win), treeview);

  // button bar
  button_add = gtk_button_new_from_stock(GTK_STOCK_ADD);
  button_remove = gtk_button_new_from_stock(GTK_STOCK_REMOVE);

  hbox_buttons = gtk_hbox_new(TRUE, 5);
  gtk_box_pack_start(GTK_BOX(hbox_buttons), button_add, FALSE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(hbox_buttons), button_remove, FALSE, TRUE, 0);

  // button events
  g_signal_connect(G_OBJECT(button_add), "clicked",
                   G_CALLBACK(add_event), (gpointer)treeview);
  g_signal_connect(G_OBJECT(button_remove), "clicked",
                   G_CALLBACK(remove_events), (gpointer)treeview);

  // vbox
  vbox = gtk_vbox_new(FALSE, 5);
  gtk_box_pack_start (GTK_BOX(vbox), scrolled_win, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX(vbox), hbox_buttons, FALSE, TRUE, 0);

  gtk_container_add(GTK_CONTAINER(window), vbox);

  gtk_widget_show_all(window);

  gtk_main ();
  return 0;
}
Exemplo n.º 7
0
void load_trains(LIST *trains, FILE* fp){
    list_load(trains, fp, _load_train, _destroy_train);
}
Exemplo n.º 8
0
static void _load_train(void *elem, FILE *fp){
    TRAIN *train = (TRAIN*)elem;
    fread(train, sizeof(TRAIN), 1, fp);
    train->stations = malloc(sizeof(LIST));
    list_load(train->stations, fp, NULL, NULL);
}