ClutterScript * gnome_app_script_new_from_file (const gchar *script_name) { ClutterScript *script; GError *error; gchar *filename; gint i, len; const gchar *path [] = { PIXMAPSDIR, NULL}; filename = open_app_get_ui_uri (script_name); if (!filename) return NULL; script = clutter_script_new (); for (len = 0; path [len]; len++) { } clutter_script_add_search_paths (script, path, len); error = NULL; clutter_script_load_from_file (script, filename, &error); if (error) { g_error ("fail to load app login script %s\n", error->message); g_error_free (error); g_object_unref (script); script = NULL; } gnome_app_script_preload (script); g_free (filename); return script; }
G_MODULE_EXPORT int test_state_script_main (int argc, char *argv[]) { ClutterActor *stage, *button; ClutterScript *script; GError *error = NULL; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return EXIT_FAILURE; script = clutter_script_new (); clutter_script_load_from_file (script, TEST_STATE_SCRIPT_FILE, &error); if (error != NULL) g_error ("Unable to load '%s': %s\n", TEST_STATE_SCRIPT_FILE, error->message); stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "State Script"); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); clutter_actor_show (stage); button = CLUTTER_ACTOR (clutter_script_get_object (script, "button")); clutter_container_add_actor (CLUTTER_CONTAINER (stage), button); clutter_actor_add_constraint (button, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5)); clutter_script_connect_signals (script, NULL); clutter_main (); g_object_unref (script); return EXIT_SUCCESS; }
static void mex_info_bar_init (MexInfoBar *self) { ClutterScript *script; ClutterActor *notification_area; GError *err = NULL; gchar *tmp; MexInfoBarPrivate *priv = self->priv = INFO_BAR_PRIVATE (self); priv->script = script = clutter_script_new (); tmp = g_build_filename (mex_get_data_dir (), "json", "info-bar.json", NULL); clutter_script_load_from_file (script, tmp, &err); g_free (tmp); if (err) g_error ("Could not load info bar: %s", err->message); priv->group = CLUTTER_ACTOR (clutter_script_get_object (script, "main-group")); clutter_actor_set_parent (priv->group, CLUTTER_ACTOR (self)); priv->settings_button = CLUTTER_ACTOR (clutter_script_get_object (script, "settings-button")); priv->power_button = CLUTTER_ACTOR (clutter_script_get_object (script, "power-button")); priv->back_button = CLUTTER_ACTOR (clutter_script_get_object (script, "back-button")); priv->notification_source = mex_generic_notification_source_new (); notification_area = CLUTTER_ACTOR (clutter_script_get_object (priv->script, "notification-area")); mex_notification_area_add_source (MEX_NOTIFICATION_AREA (notification_area), MEX_NOTIFICATION_SOURCE (priv->notification_source)); g_signal_connect (priv->settings_button, "clicked", G_CALLBACK (_show_settings_dialog_cb), self); g_signal_connect (priv->power_button, "clicked", G_CALLBACK (_show_power_dialog_cb), self); g_signal_connect (priv->back_button, "clicked", G_CALLBACK (_back_button_cb), self); _create_power_dialog (MEX_INFO_BAR (self)); _create_settings_dialog (MEX_INFO_BAR (self)); }
int main (int argc, char *argv[]) { ClutterActor *stage; g_type_init (); g_thread_init (NULL); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; clutter_threads_init (); GMainLoop *loop; loop = g_main_loop_new (NULL, FALSE); stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "message test"); clutter_actor_set_size (stage, 400, 600); clutter_actor_show_all (stage); #if 1 ClutterActor *message; GnomeAppStore *store; store = gnome_app_store_get_default (); gnome_app_store_set_lock_function (store, clutter_threads_enter); gnome_app_store_set_unlock_function (store, clutter_threads_leave); message = CLUTTER_ACTOR (gnome_app_message_new ()); clutter_container_add (CLUTTER_CONTAINER (stage), message, NULL); #else ClutterActor *page, *actor; ClutterScript *script; GError *error; script = clutter_script_new (); error = NULL; clutter_script_load_from_file (script, "/home/dliang/gnome-app-store/ui/message-info-page.json", &error); // clutter_script_load_from_file (script, "/home/dliang/gnome-app-store/ui/test.json", &error); if (error) printf ("error in load %s\n", error->message); clutter_script_get_objects (script, "message-info-page", &page, "sender_label", &actor, NULL); ClutterLayoutManager *layout; layout = clutter_box_get_layout_manager (page); gint col, row; clutter_layout_manager_child_get (layout, page, actor, "column", &col, "row", &row, NULL); printf ("col %d %d\n", col, row); clutter_layout_manager_child_set (layout, page, actor, "column", 2, "row", 1, NULL); clutter_container_add (CLUTTER_CONTAINER (stage), page, NULL); #endif g_main_loop_run (loop); g_main_loop_unref (loop); return EXIT_SUCCESS; }
static VALUE rbclt_script_load_from_file (VALUE self, VALUE filename) { ClutterScript *script = CLUTTER_SCRIPT (RVAL2GOBJ (self)); guint merge_id; GError *error = NULL; merge_id = clutter_script_load_from_file (script, StringValuePtr (filename), &error); if (error) RAISE_GERROR (error); return UINT2NUM (merge_id); }
static gboolean load_script_from_file (ClutterScript *script, gchar *filename) { GError *error = NULL; clutter_script_load_from_file (script, filename, &error); if (error != NULL) { g_critical ("Error loading ClutterScript file %s\n%s", filename, error->message); g_error_free (error); exit (EXIT_FAILURE); } return TRUE; }
bool StageManager::initStage() { stage_ = clutter_stage_get_default(); float width = (float) getAttribute("size").getInt(0); float height =(float) getAttribute("size").getInt(1); clutter_actor_set_size(stage_, width, height); clutter_stage_set_color(CLUTTER_STAGE(stage_), &black); g_signal_connect(stage_, "destroy", G_CALLBACK(on_stage_destroyed), (gpointer) this); std::string filename = getAttribute("script").getString(0); GError *error = NULL; /* load JSON from a file */ ClutterScript *script = clutter_script_new(); clutter_script_load_from_file(script, filename.c_str(), &error); if (error != NULL) { std::cerr << "Unable to read file: " << error->message << std::endl; g_error_free(error); // TODO: fail g_critical("Could not load GUI"); return false; } ClutterActor *group0 = CLUTTER_ACTOR(clutter_script_get_object(script, "group0")); // TODO: rename to root clutter_container_add_actor(CLUTTER_CONTAINER(stage_), group0); //clutter_script_connect_signals(script, this); clutter_script_connect_signals_full(script, tempi_clutter_connect_signals, this); // timeline to attach a callback for each frame that is rendered ClutterTimeline *timeline; timeline = clutter_timeline_new(60); // ms clutter_timeline_set_loop(timeline, TRUE); clutter_timeline_start(timeline); g_signal_connect(timeline, "new-frame", G_CALLBACK(on_frame_cb), this); g_signal_connect(stage_, "key-press-event", G_CALLBACK(key_event_cb), this); g_object_unref(script); // avoid memory leak clutter_actor_show(stage_); if (CLUTTER_IS_ACTOR(stage_)) return true; else return false; }
int main (int argc, char *argv[]) { gchar *filename = UI_FILE; ClutterScript *script; ClutterActor *stage; GError *error = NULL; if (argc > 1) filename = argv[1]; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; script = clutter_script_new (); clutter_script_load_from_file (script, filename, &error); if (error != NULL) { g_critical ("Error loading ClutterScript file %s\n%s", filename, error->message); g_error_free (error); exit (EXIT_FAILURE); } /* connect signal handlers as defined in the script */ clutter_script_connect_signals (script, script); clutter_script_get_objects (script, "stage", &stage, NULL); clutter_actor_show (stage); clutter_main (); g_object_unref (script); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterScript *ui; gchar *filename = "script-states.json"; GError *error = NULL; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; ui = clutter_script_new (); clutter_script_load_from_file (ui, filename, &error); if (error != NULL) { g_critical ("Error loading ClutterScript file %s\n%s", filename, error->message); g_error_free (error); exit (EXIT_FAILURE); } clutter_script_get_objects (ui, "stage", &stage, NULL); /* make the objects in the script available to all signals * by passing the script as the second argument * to clutter_script_connect_signals() */ clutter_script_connect_signals (ui, ui); clutter_actor_show (stage); clutter_main (); g_object_unref (ui); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { GObject *stage, *blue_button, *red_button; GError *error = NULL; gint res; clutter_init (&argc, &argv); script = clutter_script_new (); g_assert (CLUTTER_IS_SCRIPT (script)); clutter_script_load_from_data (script, test_behaviour, -1, &error); if (error) { g_print ("*** Error:\n" "*** %s\n", error->message); g_error_free (error); g_object_unref (script); return EXIT_FAILURE; } clutter_script_load_from_file (script, "test-script.json", &error); if (error) { g_print ("*** Error:\n" "*** %s\n", error->message); g_error_free (error); g_object_unref (script); return EXIT_FAILURE; } merge_id = clutter_script_load_from_data (script, test_unmerge, -1, &error); if (error) { g_print ("*** Error:\n" "*** %s\n", error->message); g_error_free (error); g_object_unref (script); return EXIT_FAILURE; } clutter_script_connect_signals (script, NULL); res = clutter_script_get_objects (script, "main-stage", &stage, "red-button", &red_button, "blue-button", &blue_button, NULL); g_assert (res == 3); clutter_actor_show (CLUTTER_ACTOR (stage)); g_signal_connect (red_button, "button-press-event", G_CALLBACK (red_button_press), NULL); g_signal_connect (blue_button, "button-press-event", G_CALLBACK (blue_button_press), NULL); clutter_main (); g_object_unref (script); return EXIT_SUCCESS; }
static void mex_info_bar_init (MexInfoBar *self) { ClutterScript *script; ClutterActor *notification_area; GError *err = NULL; gchar *tmp; GSettings *settings; MexInfoBarPrivate *priv = self->priv = INFO_BAR_PRIVATE (self); priv->script = script = clutter_script_new (); tmp = g_build_filename (mex_get_data_dir (), "json", "info-bar.json", NULL); clutter_script_load_from_file (script, tmp, &err); g_free (tmp); if (err) g_error ("Could not load info bar: %s", err->message); priv->group = CLUTTER_ACTOR (clutter_script_get_object (script, "main-group")); clutter_actor_set_parent (priv->group, CLUTTER_ACTOR (self)); priv->settings_button = CLUTTER_ACTOR (clutter_script_get_object (script, "settings-button")); priv->power_button = CLUTTER_ACTOR (clutter_script_get_object (script, "power-button")); priv->back_button = CLUTTER_ACTOR (clutter_script_get_object (script, "back-button")); priv->notification_source = mex_generic_notification_source_new (); notification_area = CLUTTER_ACTOR (clutter_script_get_object (priv->script, "notification-area")); /* ensure the notification area is above any other actors */ clutter_actor_set_child_above_sibling (clutter_actor_get_parent (notification_area), notification_area, NULL); mex_notification_area_add_source (MEX_NOTIFICATION_AREA (notification_area), MEX_NOTIFICATION_SOURCE (priv->notification_source)); g_signal_connect (priv->settings_button, "clicked", G_CALLBACK (_show_settings_dialog_cb), self); g_signal_connect (priv->power_button, "clicked", G_CALLBACK (_close_request_cb), self); g_signal_connect (priv->back_button, "clicked", G_CALLBACK (_back_button_cb), self); _create_settings_dialog (MEX_INFO_BAR (self)); settings = g_settings_new ("org.media-explorer.Shell"); if (!g_settings_get_boolean (settings, "close-button-visible")) clutter_actor_hide (priv->power_button); g_clear_object (&settings); }
static void mex_media_controls_init (MexMediaControls *self) { ClutterActor *actor; ClutterScript *script; GError *err = NULL; MxAdjustment *adjustment; ClutterActor *related_box; gchar *tmp; MexMediaControlsPrivate *priv = self->priv = MEDIA_CONTROLS_PRIVATE (self); priv->script = script = clutter_script_new (); tmp = g_build_filename (mex_get_data_dir (), "json", "media-controls.json", NULL); clutter_script_load_from_file (script, tmp, &err); g_free (tmp); if (err) g_error ("Could not load media controls interface: %s", err->message); priv->vbox = (ClutterActor*) clutter_script_get_object (script, "media-controls"); clutter_actor_set_parent (priv->vbox, CLUTTER_ACTOR (self)); /* add shadow to media controls box */ actor = (ClutterActor *) clutter_script_get_object (script, "media-controls-box"); clutter_actor_add_effect (actor, CLUTTER_EFFECT (mex_shadow_new ())); /* vertical fade effect */ priv->vertical_effect = mx_fade_effect_new (); clutter_actor_add_effect (priv->vbox, priv->vertical_effect); mx_scrollable_get_adjustments (MX_SCROLLABLE (mx_bin_get_child (MX_BIN (priv->vbox))), NULL, &adjustment); g_signal_connect (adjustment, "changed", G_CALLBACK (notify_vertical_changed_cb), self); g_signal_connect (adjustment, "notify::value", G_CALLBACK (notify_vertical_value_cb), self); /* horizontal fade effect */ priv->horizontal_effect = mx_fade_effect_new (); related_box = (ClutterActor *) clutter_script_get_object (priv->script, "related-box"); clutter_actor_add_effect (related_box, priv->horizontal_effect); mx_scrollable_get_adjustments (MX_SCROLLABLE (related_box), &adjustment, NULL); g_signal_connect (adjustment, "changed", G_CALLBACK (notify_horizontal_changed_cb), self); g_signal_connect (adjustment, "notify::value", G_CALLBACK (notify_horizontal_value_cb), self); /* slider setup */ priv->slider = (ClutterActor*) clutter_script_get_object (script, "slider"); g_signal_connect (priv->slider, "notify::value", G_CALLBACK (slider_value_changed_cb), self); g_signal_connect (priv->slider, "captured-event", G_CALLBACK (slider_captured_event), self); priv->play_pause_action = (MxAction*) clutter_script_get_object (script, "play-pause-action"); priv->stop_action = (MxAction*) clutter_script_get_object (script, "stop-action"); priv->add_to_queue_action = (MxAction*) clutter_script_get_object (script, "add-to-queue-action"); priv->queue_button = (ClutterActor *) clutter_script_get_object (script, "add-to-queue-button"); g_signal_connect (priv->play_pause_action, "activated", G_CALLBACK (mex_media_controls_play_cb), self); g_signal_connect (priv->stop_action, "activated", G_CALLBACK (mex_media_controls_stop_cb), self); #if 0 g_signal_connect (priv->add_to_queue_action, "activated", G_CALLBACK (mex_media_controls_add_to_queue_cb), self); #endif /* proxy setup */ priv->proxy_model = MEX_VIEW_MODEL (mex_view_model_new (NULL)); /* FIXME: Set an arbitrary 200-item limit as we can't handle large * amounts of actors without massive slow-down. */ mex_view_model_set_limit (priv->proxy_model, 200); priv->proxy = mex_content_proxy_new (MEX_MODEL (priv->proxy_model), CLUTTER_CONTAINER (related_box), MEX_TYPE_CONTENT_TILE); g_signal_connect (priv->proxy, "object-created", G_CALLBACK (tile_created_cb), self); priv->is_disabled = TRUE; }