int main() { GUI* g=NULL; WIDGET* pic=NULL; g=init_gui(); create_main_window(g,"Example GUI"); set_main_size(g,500,500); build_labs(g); build_buts(g); build_check(g); build_radio(g); build_text(g); build_misc(g); pic=create_picture(g,"pic.xpm",10,300); add_to_main(g,pic); show_main(g); while(gui_running(g)){ usleep(250000); } destroy_gui(g); return 0; }
int main(int argc, char **argv) { gtk_init(&argc, &argv); glade_init(); uv_gtk_env = init_uv(); init_abacus(uv_gtk_env); if (argc == 2) open_file(argv[1]); show_main(); gtk_main(); return (0); }
static void save_conf (GtkButton *button, MaintainrProjectbox *item) { GList *iter; gtk_label_set_text (GTK_LABEL (item->priv->label), gtk_entry_get_text (GTK_ENTRY (item->priv->project_name))); set_priority_icon (item, gtk_combo_box_get_active (GTK_COMBO_BOX (item->priv->priority))); show_main (item); for (iter = maintainr_projectconf_get_services (item->priv->conf); iter; iter = iter->next) maintainr_service_config_saved (iter->data); hide_and_show_services (item); g_signal_emit (item, signals [CONF_CHANGE], 0, NULL); }
int main() { GUI* g = init_gui(NULL); create_main_window(g,"Test Window"); set_main_size(g,300, 300); WIDGET* box = create_combobox(20,10,10,my_string); WIDGET* but = create_button("Hello",50,50); add_item_to_combobox(box,"Test 1"); add_to_main(g,box); add_to_main(g,but); show_main(g); while(gui_running(g)){ sleep(1); } destroy_gui(g); return 0; }
static void inbox_received_handler(DictionaryIterator *iterator, void *context) { Tuple *t = dict_read_first(iterator); while (t) { // if (t->type == TUPLE_CSTRING) { // APP_LOG(APP_LOG_LEVEL_INFO, "RxTuple %d:%s", (int)t->key, t->value->cstring); // } else { // APP_LOG(APP_LOG_LEVEL_INFO, "RxTuple (unknown type)"); // } switch(t->key) { case ConfShowTime: switch (atoi(t->value->cstring)) { default: case 0: // Hide conf.showTime = false; conf.showTimeOnTap = false; break; case 1: // Show conf.showTime = true; conf.showTimeOnTap = false; break; case 2: // Show on tap conf.showTime = false; conf.showTimeOnTap = true; break; } persist_write_bool(t->key, conf.showTime); persist_write_bool(ConfShowTimeOnTap, conf.showTimeOnTap); layer_set_hidden(text_layer_get_layer(s_time_layer), !conf.showTime); if (conf.showTimeOnTap) { accel_tap_service_subscribe(tap_handler); // APP_LOG(APP_LOG_LEVEL_INFO, "Subscribe tap"); } else { accel_tap_service_unsubscribe(); // APP_LOG(APP_LOG_LEVEL_INFO, "Unsubscribe tap"); } break; case ConfShowDate: conf.showDate = atoi(t->value->cstring); persist_write_bool(t->key, conf.showDate); layer_set_hidden(text_layer_get_layer(s_date_layer), !(conf.showDate || conf.showMonth)); break; case ConfShowMonth: conf.showMonth = atoi(t->value->cstring); persist_write_bool(t->key, conf.showMonth); layer_set_hidden(text_layer_get_layer(s_date_layer), !(conf.showDate || conf.showMonth)); break; case ConfShowWeekNum: conf.showWeekNum = atoi(t->value->cstring); persist_write_bool(t->key, conf.showWeekNum); layer_set_hidden(text_layer_get_layer(s_week_layer), !conf.showWeekNum); break; case ConfShowCharge: conf.showCharge = atoi(t->value->cstring); persist_write_bool(t->key, conf.showCharge); layer_set_hidden(s_charge_layer, !conf.showCharge); break; case ConfShowBluetooth: conf.showBluetooth = atoi(t->value->cstring); persist_write_bool(t->key, conf.showBluetooth); layer_set_hidden(s_bluetooth_layer, !conf.showBluetooth); break; case ConfVibeBluetooth: conf.vibeBluetooth = atoi(t->value->cstring); persist_write_bool(t->key, conf.vibeBluetooth); break; case ConfShowSpiral: conf.showSpiral = atoi(t->value->cstring); persist_write_bool(t->key, conf.showSpiral); layer_set_hidden(s_arc1x1L_layer, !conf.showSpiral); layer_set_hidden(s_arc1x1R_layer, !conf.showSpiral); layer_set_hidden(s_arc2x2_layer, !conf.showSpiral); layer_set_hidden(s_arc3x3_layer, !conf.showSpiral); layer_set_hidden(s_arc5x5_layer, !conf.showSpiral); break; case ConfHourColor: conf.hourColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.hourColor.argb); layer_mark_dirty(s_fibo_layer); break; case ConfMinuteColor: conf.minuteColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.minuteColor.argb); layer_mark_dirty(s_fibo_layer); break; case ConfHourMinuteColor: conf.hourMinuteColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.hourMinuteColor.argb); layer_mark_dirty(s_fibo_layer); break; case ConfNoneColor: conf.noneColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.noneColor.argb); layer_mark_dirty(s_fibo_layer); break; case ConfSpiralColor: conf.spiralColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.spiralColor.argb); layer_mark_dirty(s_arc1x1L_layer); layer_mark_dirty(s_arc1x1R_layer); layer_mark_dirty(s_arc2x2_layer); layer_mark_dirty(s_arc3x3_layer); layer_mark_dirty(s_arc5x5_layer); break; case ConfBackgroundColor: { conf.backgroundColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.backgroundColor.argb); window_set_background_color(s_window, conf.backgroundColor); } break; case ConfGridColor: conf.gridColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.gridColor.argb); layer_mark_dirty(s_fibo_layer); break; case ConfDotColor: conf.dotColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.dotColor.argb); layer_mark_dirty(s_fibo_layer); break; case ConfTimeColor: { int value = atoi(t->value->cstring); conf.legibleText = (value == 256); conf.timeColor = (GColor){.argb = (uint8_t)(value & 0xFF)}; persist_write_int(t->key, value); tick_handler(NULL, (TimeUnits)0); } break; case ConfOutlineColor: conf.outlineColor = (GColor){.argb = atoi(t->value->cstring)}; persist_write_int(t->key, conf.outlineColor.argb); layer_mark_dirty(s_fibo_layer); break; case ConfFiboDisplay: conf.fiboDisplay = atoi(t->value->cstring); persist_write_int(t->key, conf.fiboDisplay); layer_mark_dirty(s_fibo_layer); layer_set_frame(s_arc1x1L_layer, fibo[conf.fiboDisplay].s_1x1L_square); layer_set_frame(s_arc1x1R_layer, fibo[conf.fiboDisplay].s_1x1R_square); layer_set_frame(s_arc2x2_layer, fibo[conf.fiboDisplay].s_2x2_square); layer_set_frame(s_arc3x3_layer, fibo[conf.fiboDisplay].s_3x3_square); layer_set_frame(s_arc5x5_layer, fibo[conf.fiboDisplay].s_5x5_square); layer_set_frame(text_layer_get_layer(s_time_layer), fibo[conf.fiboDisplay].s_time); layer_set_frame(text_layer_get_layer(s_date_layer), fibo[conf.fiboDisplay].s_date); layer_set_frame(text_layer_get_layer(s_week_layer), fibo[conf.fiboDisplay].s_week); break; } t = dict_read_next(iterator); } } void show_main(void) { initialise_ui(); window_set_window_handlers(s_window, (WindowHandlers) { .unload = handle_window_unload, }); window_stack_push(s_window, true); // Set up layer callbacks layer_set_update_proc(s_fibo_layer, fibo_layer_update_callback); layer_set_update_proc(s_charge_layer, charge_layer_update_callback); layer_set_update_proc(s_arc3x3_layer, arc3x3_layer_update_callback); layer_set_update_proc(s_arc2x2_layer, arc2x2_layer_update_callback); layer_set_update_proc(s_arc1x1L_layer, arc1x1L_layer_update_callback); layer_set_update_proc(s_arc1x1R_layer, arc1x1R_layer_update_callback); layer_set_update_proc(s_arc5x5_layer, arc5x5_layer_update_callback); layer_set_update_proc(s_bluetooth_layer, bluetooth_layer_update_callback); // Create bitmaps s_charging_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_CHARGING); s_plugged_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PLUGGED); s_bluetooth_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH); s_cross_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_CROSS); // Register with TickTimerService #if ACTIVATE_COLOR_LOOP tick_timer_service_subscribe(SECOND_UNIT, tick_handler); #else tick_timer_service_subscribe(MINUTE_UNIT, tick_handler); #endif // Register with BatteryStateService battery_state_service_subscribe(battery_charge_handler); // Register with BluetoothConnectionService bluetooth_connection_service_subscribe(bluetooth_handler); app_message_register_inbox_received((AppMessageInboxReceived) inbox_received_handler); app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); load_config(); layer_set_hidden(text_layer_get_layer(s_time_layer), !conf.showTime); layer_set_hidden(text_layer_get_layer(s_date_layer), !(conf.showDate || conf.showMonth)); layer_set_hidden(text_layer_get_layer(s_week_layer), !conf.showWeekNum); // Create used path s_bat_frame_path_ptr = gpath_create(&BAT_FRAME_PATH_INFO); // Make sure that the currnet time is displayed from the start time_t temp = time(NULL); struct tm *tick_time = localtime(&temp); tick_handler(tick_time, YEAR_UNIT | MONTH_UNIT | DAY_UNIT | HOUR_UNIT | MINUTE_UNIT | SECOND_UNIT); } void hide_main(void) { window_stack_remove(s_window, true); gbitmap_destroy(s_battery_image); gbitmap_destroy(s_charging_image); gbitmap_destroy(s_plugged_image); gbitmap_destroy(s_bluetooth_image); gbitmap_destroy(s_cross_image); tick_timer_service_unsubscribe(); battery_state_service_unsubscribe(); bluetooth_connection_service_unsubscribe(); } int main(void) { show_main(); app_event_loop(); hide_main(); }