/* Tabs 4 */ FROM MAIN.C static void wnd_init() { /* Create the clutter widget */ GtkWidget *sbmgr_widget = sbmgr_new(); if (!sbmgr_widget) { return; } main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_resizable(GTK_WINDOW(main_window), FALSE); gtk_window_set_title(GTK_WINDOW(main_window), PACKAGE_NAME); /* gtk_vbox_new’ is deprecated */ /* Widget *vbox = gtk_vbox_new(FALSE, 6); */ GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6); gtk_container_add(GTK_CONTAINER(main_window), vbox); gtk_widget_show(vbox); /* create a toolbar */ GtkWidget *toolbar = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); btn_reload = (GtkWidget*)gtk_tool_button_new_from_stock(GTK_STOCK_REFRESH); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(btn_reload), _("Reload icons from device")); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(btn_reload), -1); btn_apply = (GtkWidget*)gtk_tool_button_new_from_stock(GTK_STOCK_APPLY); gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(btn_apply), _("Upload changes to device")); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(btn_apply), -1); GtkToolItem *btn_info = gtk_tool_button_new_from_stock(GTK_STOCK_INFO); gtk_tool_item_set_tooltip_text(btn_info, _("Get info about this cool program")); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), btn_info, -1); GtkToolItem *spacer = gtk_tool_item_new(); gtk_tool_item_set_expand(spacer, TRUE); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), spacer, -1); GtkToolItem *btn_quit = gtk_tool_button_new_from_stock(GTK_STOCK_QUIT); gtk_tool_item_set_tooltip_text(btn_quit, _("Quit this program")); gtk_toolbar_insert(GTK_TOOLBAR(toolbar), btn_quit, -1); gtk_widget_set_sensitive(btn_reload, FALSE); gtk_widget_set_sensitive(btn_apply, FALSE); gtk_widget_show(toolbar); /* set up signal handlers */ g_signal_connect(btn_reload, "clicked", G_CALLBACK(reload_button_clicked_cb), NULL); g_signal_connect(btn_apply, "clicked", G_CALLBACK(apply_button_clicked_cb), NULL); g_signal_connect(btn_info, "clicked", G_CALLBACK(info_button_clicked_cb), NULL); g_signal_connect(btn_quit, "clicked", G_CALLBACK(quit_button_clicked_cb), NULL); /* insert sbmgr widget */ gtk_box_pack_start(GTK_BOX(vbox), sbmgr_widget, TRUE, TRUE, 0); gtk_widget_show(sbmgr_widget); gtk_widget_grab_focus(sbmgr_widget); /* create a statusbar */ /* statusbar = gtk_statusbar_new(); gtk_statusbar_set_has_resize_grip(GTK_STATUSBAR(statusbar), FALSE); gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0); gtk_widget_show(statusbar); */ /* attach to window signals */ g_signal_connect(G_OBJECT(main_window), "map-event", G_CALLBACK(win_map_cb), NULL); /* Show the window. This also sets the stage's bounding box. */ gtk_widget_show_all(GTK_WIDGET(main_window)); g_set_printerr_handler((GPrintFunc)gui_error_dialog); /* Stop the application when the window is closed */ g_signal_connect(main_window, "hide", G_CALLBACK(quit_program_cb), NULL); /* get notified when plug in/out events occur */ idevice_event_subscribe(device_event_cb, NULL); } /* main */ static void print_usage(int argc, char **argv) { char *name = NULL; name = strrchr(argv[0], '/'); printf("Usage: %s [OPTIONS]\n", (name ? name + 1 : argv[0])); printf("Manage SpringBoard icons of an iPhone/iPod Touch.\n\n"); printf(" -d, --debug\t\tenable communication debugging\n"); printf(" -D, --debug-app\tenable application debug messages\n"); printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); printf(" -h, --help\t\tprints usage information\n"); printf("\n"); } int main(int argc, char **argv) { int i; /* parse cmdline args */ for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { idevice_set_debug_level(1); continue; } else if (!strcmp(argv[i], "-D") || !strcmp(argv[i], "--debug-app")) { set_debug(TRUE); continue; } else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { i++; if (!argv[i] || (strlen(argv[i]) != 40)) { print_usage(argc, argv); return 0; } match_uuid = g_strndup(argv[i], 40); continue; } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { print_usage(argc, argv); return 0; } else { print_usage(argc, argv); return 0; } } /* Create the window and some child widgets */ wnd_init(); /* Start the main loop, so we can respond to events */ gtk_main(); return 0; } FROM SBMGR.C GtkWidget *sbmgr_new() { /* if (!g_thread_supported()) g_thread_init(NULL); g_thread_init is deprecated */ /* initialize device communication environment */ device_init(); /* Create the clutter widget and return it */ return gui_init(); FROM GUI.C GtkWidget *gui_init() { device_info = device_info_new(); ClutterActor *actor; ClutterContent *image; GdkPixbuf *pixbuf; /* if (!g_thread_supported()) */ /* g_thread_init' is deprecated No longer necessary */ /* g_thread_init(NULL); */ /* if (icon_loader_mutex == NULL) */ /* 'g_mutex_new' is deprecated */ /* icon_loader_mutex = g_mutex_new(); */ /* initialize clutter threading environment */ if (!clutter_threads_initialized) { /* 'clutter_threads_init' is deprecated */ /* clutter_threads_init(); */ clutter_threads_initialized = 1; } if (!clutter_initialized) { g_setenv ("CLUTTER_VBLANK", "none", FALSE); if (gtk_clutter_init(NULL, NULL) != CLUTTER_INIT_SUCCESS) { g_error("Unable to initialize GtkClutter"); return NULL; } clutter_initialized = 1; } gettimeofday(&last_page_switch, NULL); /* Create the clutter widget */ GtkWidget *clutter_widget = clutter_gtk_widget = gtk_clutter_embed_new(); /* Set the size of the widget, because we should not set the size of its * stage when using GtkClutterEmbed. */ gtk_widget_set_size_request(clutter_widget, stage_area.x2, stage_area.y2); /* Set the stage background color */ stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(clutter_widget)); /* clutter_stage_set_color is deprecated */ /* clutter_stage_set_color(CLUTTER_STAGE(stage), &stage_color); */ clutter_actor_set_background_color(CLUTTER_ACTOR(stage), &stage_color); /* attach to stage signals */ g_signal_connect(stage, "motion-event", G_CALLBACK(stage_motion_cb), NULL); g_signal_connect(stage, "key-press-event", G_CALLBACK(stage_key_press_cb), NULL); /* Load ui background */ GError *err = NULL; /* clutter_texture_new' is deprecated */ /* actor = clutter_texture_new(); */ actor = clutter_actor_new(); /* clutter_texture_set_load_async' is deprecated */ /* clutter_texture_set_load_async(CLUTTER_TEXTURE(actor), TRUE); */ /* clutter_texture_set_from_file is deprecated */ /* clutter_texture_set_from_file(CLUTTER_TEXTURE(actor), SBMGR_DATA "/background.png", &err); */ /* image = gtk_image_new_from_file(SBMGR_DATA "/background.png"); */ /* pixbuf = gdk_pixbuf_new_from_file (iconfilename, &err); TEST */ /* pixbuf = gdk_pixbuf_new_from_file (SBMGR_DATA "/background.png", NULL); */ pixbuf = gdk_pixbuf_new_from_file ("/usr/local/share/sbmanager/background.png", NULL); if(pixbuf == NULL){ fprintf(stderr, "\n%spixbuf error reading file on background\n", __func__); } image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), NULL); g_object_unref (pixbuf); clutter_actor_set_content (actor, image); g_object_unref (image); /* gtk_widget_show(image); This does not work */ if (err) { g_printerr("%s", err->message); fprintf(stderr,"\n%s\n",err->message); g_error_free(err); err = NULL; } if (actor) { clutter_actor_set_position(actor, 0, 0); clutter_actor_show(actor); /* clutter_container_add_actor' is deprecated */ /* clutter_group_add(CLUTTER_GROUP(stage), actor); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), actor); } else { fprintf(stderr, "could not load background.png\n"); } /* Create device type widget */ type_label = clutter_text_new_full(CLOCK_FONT, "", &clock_text_color); /* clutter_container_add_actor' is deprecated */ /* clutter_group_add(CLUTTER_GROUP(stage), type_label); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), type_label); clutter_actor_set_position(type_label, 3.0, 2.0); /* clock widget */ clock_label = clutter_text_new_full(CLOCK_FONT, "00:00", &clock_text_color); /* clutter_container_add_actor' is deprecated */ /* clutter_group_add(CLUTTER_GROUP(stage), clock_label); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), clock_label); /* page indicator group for holding the page indicator dots */ /* clutter_group_new is deprecated */ /* page_indicator_group = clutter_group_new(); */ page_indicator_group = clutter_actor_new(); /* clutter_container_add_actor' is deprecated */ /* clutter_group_add(CLUTTER_GROUP(stage), page_indicator_group); */ /* pixbuf = gdk_pixbuf_new_from_file (iconfilename, &err); TEST */ /* pixbuf = gdk_pixbuf_new_from_file (SBMGR_DATA "/background.png", NULL); */ /* alignment will be done when new indicators are added */ clutter_actor_set_position(page_indicator_group, 0, stage_area.y2 - DOCK_HEIGHT - ICON_SPACING); /* page indicator (dummy), will be cloned when the pages are created */ /* clutter_texture_new' is deprecated */ /* page_indicator = clutter_texture_new(); */ page_indicator = clutter_actor_new(); /* clutter_texture_set_load_async' is deprecated */ /* clutter_texture_set_load_async(CLUTTER_TEXTURE(page_indicator), TRUE); */ /* clutter_texture_set_from_file is deprecated */ /* clutter_texture_set_from_file(CLUTTER_TEXTURE(page_indicator), SBMGR_DATA "/dot.png", &err); */ /* gdk_pixbuf_new_from_file(SBMGR_DATA "/dot.png", &err); TEST */ pixbuf = gdk_pixbuf_new_from_file ("/usr/local/share/sbmanager/dot.png", NULL); image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), NULL); g_object_unref (pixbuf); clutter_actor_set_content (actor, image); g_object_unref (image); if (err) { fprintf(stderr, "Could not load texture " SBMGR_DATA "/dot.png" ": %s\n", err->message); g_error_free(err); err = NULL; } if (page_indicator) { clutter_actor_hide(page_indicator); /* clutter_container_add_actor is deprecated */ /* clutter_container_add_actor(CLUTTER_CONTAINER(stage), page_indicator); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), page_indicator); /* clutter_actor_show(stage); TEST */ } /* icon shadow texture dummy, cloned when drawing the icons */ /* clutter_texture_new' is deprecated */ /* icon_shadow = clutter_texture_new(); */ icon_shadow = clutter_actor_new(); /* clutter_texture_set_load_async' is deprecated */ /* clutter_texture_set_load_async(CLUTTER_TEXTURE(icon_shadow), TRUE); */ /* clutter_texture_set_from_file is deprecated */ /* clutter_texture_set_from_file(CLUTTER_TEXTURE(icon_shadow), SBMGR_DATA "/iconshadow.png", &err); */ /*gtk_image_new_from_file(SBMGR_DATA "/iconshadow.png"); */ pixbuf = gdk_pixbuf_new_from_file ("/usr/local/share/sbmanager/iconshadow.png", NULL); image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), NULL); g_object_unref (pixbuf); clutter_actor_set_content (icon_shadow, image); g_object_unref (image); if (err) { fprintf(stderr, "Could not load texture " SBMGR_DATA "/iconshadow.png" ": %s\n", err->message); g_error_free(err); err = NULL; } if (icon_shadow) { /* clutter_actor_hide(icon_shadow); */ clutter_actor_show(icon_shadow); /* TEST */ /* clutter_container_add_actor is deprecated */ /* clutter_container_add_actor(CLUTTER_CONTAINER(stage), icon_shadow); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), icon_shadow); } /* folder marker */ /* clutter_texture_new' is deprecated */ /* folder_marker = clutter_texture_new(); */ folder_marker = clutter_actor_new(); /* clutter_texture_set_load_async' is deprecated */ /* clutter_texture_set_load_async(CLUTTER_TEXTURE(folder_marker), TRUE); */ /* clutter_texture_set_from_file is deprecated */ /* clutter_texture_set_from_file(CLUTTER_TEXTURE(folder_marker), SBMGR_DATA "/foldermarker.png", &err); */ /* gtk_image_new_from_file(SBMGR_DATA "/foldermarker.png"); */ pixbuf = gdk_pixbuf_new_from_file ("/usr/local/share/sbmanager/foldermarker.png", NULL); image = clutter_image_new (); clutter_image_set_data (CLUTTER_IMAGE (image), gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf) ? COGL_PIXEL_FORMAT_RGBA_8888 : COGL_PIXEL_FORMAT_RGB_888, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), gdk_pixbuf_get_rowstride (pixbuf), NULL); g_object_unref (pixbuf); clutter_actor_set_content (folder_marker, image); g_object_unref (image); if (err) { fprintf(stderr, "Could not load texture " SBMGR_DATA "/foldermarker.png" ": %s\n", err->message); g_error_free(err); err = NULL; } if (folder_marker) { /* clutter_actor_hide(folder_marker); */ clutter_actor_show(folder_marker); /* TEST */ /* clutter_container_add_actor is deprecated */ /* clutter_container_add_actor(CLUTTER_CONTAINER(stage), folder_marker); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), folder_marker); } /* a group for the springboard icons */ /* clutter_group_new is deprecated */ /* the_sb = clutter_group_new(); */ the_sb = clutter_actor_new(); /* clutter_container_add_actor' is deprecated */ /* clutter_group_add(CLUTTER_GROUP(stage), the_sb); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), the_sb); clutter_actor_set_position(the_sb, sb_area.x1, sb_area.y1); /* a group for the dock icons */ /* clutter_group_new is deprecated */ /* the_dock = clutter_group_new(); */ the_dock = clutter_actor_new(); /* clutter_container_add_actor' is deprecated*/ /* clutter_group_add(CLUTTER_GROUP(stage), the_dock); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), the_dock); clutter_actor_set_position(the_dock, dock_area.x1, dock_area.y1); gui_fade_init(); gui_spinner_init(); /* Show the stage */ clutter_actor_show(stage); /* Create a timeline to manage animation */ clock_timeline = clutter_timeline_new(200); /* clutter_timeline_set_loop' is deprecated */ /* clutter_timeline_set_loop(clock_timeline, TRUE); */ /* have it loop */ clutter_timeline_set_repeat_count(clock_timeline, -1); /* have it loop */ /* fire a callback for frame change */ g_signal_connect(clock_timeline, "completed", G_CALLBACK(clock_update_cb), NULL); /* and start it */ clutter_timeline_start(clock_timeline); /* if (selected_mutex == NULL) */ /* 'g_mutex_new' is deprecated */ /* selected_mutex = g_mutex_new(); */ /* Position and update the clock */ clock_set_time(clock_label, time(NULL)); clutter_actor_show(clock_label); /* battery capacity */ /* clutter_rectange_new_with_color is deprecated */ /* battery_level = clutter_rectangle_new_with_color(&battery_color); */ battery_level = clutter_actor_new(); /* clutter_container_add_actor' is deprecated */ /* clutter_group_add(CLUTTER_GROUP(stage), battery_level); */ clutter_actor_add_child(CLUTTER_ACTOR(stage), battery_level); clutter_actor_set_position(battery_level, stage_area.x2 - 22, 6); return clutter_widget; }