int main (int argc, char **argv) { ClutterActor *stage; ClutterActor *pane; ClutterActor *button; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) { g_warning ("Unable to initialise Clutter"); return EXIT_FAILURE; } mx_style_load_from_file (mx_style_get_default (), THEMEDIR "/theme.css", NULL); stage = clutter_stage_get_default (); pane = mpl_content_pane_new ("Foo"); clutter_actor_set_size (pane, 480, 320); clutter_container_add_actor (CLUTTER_CONTAINER (stage), pane); button = mx_button_new_with_label ("Bar"); mpl_content_pane_set_header_actor (MPL_CONTENT_PANE (pane), button); button = mx_button_new_with_label ("Baz"); clutter_container_add_actor (CLUTTER_CONTAINER (pane), button); clutter_actor_show_all (stage); clutter_main (); return EXIT_SUCCESS; }
int main (int argc, char **argv) { MxWindow *window; MxApplication *app; ClutterActor *stage, *bar, *button, *hbox; app = mx_application_new (&argc, &argv, "Test PathBar", 0); window = mx_application_create_window (app); stage = (ClutterActor *)mx_window_get_clutter_stage (window); bar = mx_path_bar_new (); mx_path_bar_set_clear_on_change (MX_PATH_BAR (bar), TRUE); hbox = mx_box_layout_new (); button = mx_button_new_with_label ("Add crumb"); g_signal_connect_swapped (button, "clicked", G_CALLBACK (add_cb), bar); clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button); button = mx_button_new_with_label ("Remove crumb"); g_signal_connect_swapped (button, "clicked", G_CALLBACK (remove_cb), bar); clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button); button = mx_button_new_with_label ("Toggle editable"); g_signal_connect_swapped (button, "clicked", G_CALLBACK (toggle_editable_cb), bar); clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button); button = mx_button_new_with_label ("Re-label first crumb"); g_signal_connect_swapped (button, "clicked", G_CALLBACK (relabel_cb), bar); clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button); /* -a for 'alternative packing'... */ if (argc > 1 && g_str_equal (argv[1], "-a")) { ClutterActor *vbox = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), bar); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), hbox); mx_window_set_child (window, vbox); mx_path_bar_set_editable (MX_PATH_BAR (bar), TRUE); } else { MxToolbar *toolbar = mx_window_get_toolbar (window); clutter_container_add_actor (CLUTTER_CONTAINER (toolbar), bar); mx_window_set_child (window, hbox); } clutter_actor_show (stage); mx_application_run (app); return 0; }
static void mx_menu_init (MxMenu *self) { MxMenuPrivate *priv = self->priv = MENU_PRIVATE (self); priv->children = g_array_new (FALSE, FALSE, sizeof (MxMenuChild)); g_object_set (G_OBJECT (self), "show-on-set-parent", FALSE, NULL); priv->id_offset = 0; priv->last_shown_id = 0; priv->up_button = mx_button_new_with_label("/\\"); clutter_actor_add_child (CLUTTER_ACTOR (self), CLUTTER_ACTOR (priv->up_button)); g_signal_connect (priv->up_button, "enter-event", G_CALLBACK(mx_menu_up_enter), self); g_signal_connect (priv->up_button, "leave-event", G_CALLBACK(mx_menu_up_leave), self); priv->down_button = mx_button_new_with_label ("\\/"); clutter_actor_add_child (CLUTTER_ACTOR (self), CLUTTER_ACTOR (priv->down_button)); g_signal_connect (priv->down_button, "enter-event", G_CALLBACK(mx_menu_down_enter), self); g_signal_connect (priv->down_button, "leave-event", G_CALLBACK(mx_menu_down_leave), self); }
int main (int argc, char *argv[]) { ClutterActor *button, *box, *stage; MxApplication *application; MxWindow *window; application = mx_application_new (&argc, &argv, "Test Mx focus handling", MX_APPLICATION_SINGLE_INSTANCE); window = mx_application_create_window (application); stage = (ClutterActor *)mx_window_get_clutter_stage (window); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL); mx_window_set_child (window, box); button = mx_button_new_with_label ("button #1 (activate to remove)"); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1); mx_focus_manager_push_focus (mx_focus_manager_get_for_stage (CLUTTER_STAGE (stage)), MX_FOCUSABLE (button)); button = mx_button_new_with_label ("button #2 (activate to remove)"); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1); button = mx_button_new_with_label ("button #3 (activate to remove)"); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1); button = mx_button_new_with_label ("button #4 (activate to remove)"); g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), NULL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (box), button, -1); clutter_actor_show (stage); mx_application_run (application); return EXIT_SUCCESS; }
static ClutterActor * _make_messenger_launcher_tile (MnbPeoplePanel *panel) { ClutterActor *table; ClutterActor *icon_tex; ClutterActor *button; GAppInfo *app_info; gchar *button_str; ClutterActor *bin; bin = mx_frame_new (); clutter_actor_set_name (bin, "people-panel-messenger-launcher-tile"); table = mx_table_new (); mx_bin_set_child (MX_BIN (bin), table); mx_table_set_column_spacing (MX_TABLE (table), 16); app_info = (GAppInfo *)g_desktop_app_info_new ("empathy.desktop"); icon_tex = g_object_new (MX_TYPE_ICON, "icon-name", "netbook-empathy", NULL); mx_table_add_actor_with_properties (MX_TABLE (table), icon_tex, 0, 0, "x-expand", FALSE, "y-expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, NULL); button_str = g_strdup_printf (_("Open %s"), g_app_info_get_name (app_info)); button = mx_button_new_with_label (button_str); g_free (button_str); g_signal_connect (button, "clicked", (GCallback)_messenger_launcher_button_clicked_cb, panel); mx_table_add_actor_with_properties (MX_TABLE (table), button, 0, 1, "x-expand", FALSE, "y-expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, NULL); g_object_unref (app_info); return bin; }
ClutterActor * _make_settings_launcher (MnbPeoplePanel *people_panel) { ClutterActor *table; ClutterActor *icon_tex; ClutterActor *button; GAppInfo *app_info; gchar *button_str; app_info = (GAppInfo *)g_desktop_app_info_new ("empathy-accounts.desktop"); table = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (table), 16); app_info = (GAppInfo *)g_desktop_app_info_new ("empathy-accounts.desktop"); icon_tex = g_object_new (MX_TYPE_ICON, "icon-name", "netbook-empathy-accounts", NULL); mx_table_insert_actor_with_properties (MX_TABLE (table), icon_tex, 0, 0, "x-expand", FALSE, "y-expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, NULL); button_str = g_strdup_printf (_("Open %s"), g_app_info_get_name (app_info)); button = mx_button_new_with_label (button_str); g_free (button_str); g_signal_connect (button, "clicked", (GCallback)_settings_launcher_button_clicked_cb, people_panel); mx_table_insert_actor_with_properties (MX_TABLE (table), button, 0, 1, "x-expand", FALSE, "y-expand", TRUE, "x-fill", FALSE, "y-fill", FALSE, NULL); g_object_unref (app_info); return table; }
int main (int argc, char **argv) { MpdIdleManager *idlr; ClutterActor *stage; ClutterActor *box; ClutterActor *button; clutter_init (&argc, &argv); /* Needed for egg-idletime's X extensions. */ gtk_init (&argc, &argv); idlr = mpd_idle_manager_new (); stage = clutter_stage_get_default (); box = mx_box_layout_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); button = mx_button_new_with_label ("Activate screensaver"); g_signal_connect (button, "clicked", G_CALLBACK (_lock_button_clicked_cb), idlr); clutter_container_add_actor (CLUTTER_CONTAINER (box), button); button = mx_button_new_with_label ("Suspend"); g_signal_connect (button, "clicked", G_CALLBACK (_suspend_button_clicked_cb), idlr); clutter_container_add_actor (CLUTTER_CONTAINER (box), button); clutter_actor_show_all (stage); clutter_main (); g_object_unref (idlr); return EXIT_SUCCESS; }
static void mex_music_player_set_context (MexContentView *player, MexModel *model) { MexMusicPlayerPrivate *priv = MEX_MUSIC_PLAYER (player)->priv; ClutterActor *box, *button; MexContent *content; gint i; if (priv->model) g_object_unref (priv->model); priv->model = model; if (model) g_object_ref (model); box = mex_script_get_actor (priv->script, "tracks"); clutter_actor_remove_all_children (box); for (i = 0; (content = mex_model_get_content (model, i)); i++) { const gchar *title; title = mex_content_get_metadata (content, MEX_CONTENT_METADATA_TITLE); button = mx_button_new_with_label (title); mx_stylable_set_style_class (MX_STYLABLE (button), "Track"); mx_button_set_is_toggle (MX_BUTTON (button), TRUE); g_object_set_data (G_OBJECT (button), "content", content); g_signal_connect (button, "clicked", G_CALLBACK (mex_music_player_item_clicked), player); mx_button_set_icon_position (MX_BUTTON (button), MX_POSITION_RIGHT); clutter_actor_add_child (box, button); } }
int main (int argc, char **argv) { ClutterActor *stage; MxBoxLayout *vbox; MxBoxLayout *hbox; ClutterActor *button; ClutterActor *label; ObjectStoreTest app = { 0, }; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 320.0, 240.0); vbox = (MxBoxLayout *) mx_box_layout_new (); clutter_actor_set_size (CLUTTER_ACTOR (vbox), 320.0, 240.0); mx_box_layout_set_orientation (vbox, MX_ORIENTATION_VERTICAL); clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (vbox)); /* Create model */ app.store = foo_object_store_new (2, FOO_TYPE_TEST_OBJECT, "foo", /* column #0 */ G_TYPE_STRING, "text"); /* column #1 */ /* * Create view */ app.view = mx_list_view_new (); /* Use MxButton to render the model's items */ mx_list_view_set_item_type (MX_LIST_VIEW (app.view), MX_TYPE_BUTTON); /* Map column #1 to attribute "label" of view's GtkButton */ mx_list_view_add_attribute (MX_LIST_VIEW (app.view), "label", 1); /* Connect to model */ mx_list_view_set_model (MX_LIST_VIEW (app.view), app.store); mx_box_layout_add_actor_with_properties (vbox, app.view, -1, "expand", true, "x-fill", true, "y-fill", true, NULL); hbox = (MxBoxLayout *) mx_box_layout_new (); mx_box_layout_set_orientation (hbox, MX_ORIENTATION_HORIZONTAL); mx_box_layout_add_actor_with_properties (vbox, CLUTTER_ACTOR (hbox), -1, "expand", false, "x-fill", true, NULL); app.entry = (MxEntry *) mx_entry_new (); mx_box_layout_add_actor_with_properties (hbox, CLUTTER_ACTOR (app.entry), -1, "expand", true, "x-fill", true, NULL); button = mx_button_new_with_label ("Update"); g_signal_connect (button, "clicked", G_CALLBACK (_update_clicked), &app); clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button); button = mx_button_new_with_label ("Dump"); g_signal_connect (button, "clicked", G_CALLBACK (_dump_clicked), &app); clutter_container_add_actor (CLUTTER_CONTAINER (hbox), button); label = mx_label_new_with_text ("Enter text and update to add item\n" "Enter <number>:<text> to change item <number>\n" "Enter -<number> to delete item <number>"); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label); clutter_actor_show_all (stage); clutter_main (); return EXIT_SUCCESS; }
static void penge_calendar_pane_init (PengeCalendarPane *self) { PengeCalendarPanePrivate *priv = GET_PRIVATE_REAL (self); JanaTime *now; JanaTime *on_the_next_hour; glong next_timeout_seconds; ClutterActor *label; ClutterActor *tasks_icon; ClutterActor *button; self->priv = priv; now = jana_ecal_utils_time_now_local (); /* Events header */ priv->events_header_table = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (priv->events_header_table), 8); mx_stylable_set_style_class (MX_STYLABLE (priv->events_header_table), "PengeEventsPaneHeader"); priv->calendar_tex = clutter_texture_new (); /* Need to fix the size to avoid being squashed */ clutter_actor_set_size (priv->calendar_tex, 27, 28); mx_table_insert_actor_with_properties (MX_TABLE (priv->events_header_table), priv->calendar_tex, 0, 0, "x-expand", FALSE, "x-fill", FALSE, "y-expand", TRUE, "y-fill", FALSE, NULL); penge_calendar_pane_update_calendar_icon (self, now); label = mx_label_new_with_text (_("Appointments")); mx_stylable_set_style_class (MX_STYLABLE (label), "PengeEventsPaneTitle"); mx_table_insert_actor_with_properties (MX_TABLE (priv->events_header_table), label, 0, 1, "y-expand", TRUE, "y-fill", FALSE, "x-expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_START, NULL); button = mx_button_new_with_label (_("Open")); g_signal_connect (button, "clicked", (GCallback)_events_open_button_clicked_cb, NULL); mx_table_insert_actor_with_properties (MX_TABLE (priv->events_header_table), button, 0, 2, "y-expand", TRUE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-expand", FALSE, NULL); /* Tasks header */ priv->tasks_header_table = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (priv->tasks_header_table), 8); mx_stylable_set_style_class (MX_STYLABLE (priv->tasks_header_table), "PengeTasksPaneHeader"); tasks_icon = mx_icon_new (); clutter_actor_set_name (tasks_icon, "tasks-icon"); mx_table_insert_actor_with_properties (MX_TABLE (priv->tasks_header_table), tasks_icon, 0, 0, "x-expand", FALSE, "x-fill", FALSE, "y-expand", TRUE, "y-fill", FALSE, NULL); label = mx_label_new_with_text (_("Tasks")); mx_stylable_set_style_class (MX_STYLABLE (label), "PengeTasksPaneTitle"); mx_table_insert_actor_with_properties (MX_TABLE (priv->tasks_header_table), label, 0, 1, "y-expand", TRUE, "y-fill", FALSE, "x-expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_START, NULL); button = mx_button_new_with_label (_("Open")); g_signal_connect (button, "clicked", (GCallback)_tasks_open_button_clicked_cb, NULL); mx_table_insert_actor_with_properties (MX_TABLE (priv->tasks_header_table), button, 0, 2, "y-expand", TRUE, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, "x-expand", FALSE, NULL); priv->events_pane = g_object_new (PENGE_TYPE_EVENTS_PANE, "time", now, NULL); priv->tasks_pane = g_object_new (PENGE_TYPE_TASKS_PANE, NULL); clutter_actor_set_parent (CLUTTER_ACTOR (priv->events_header_table), CLUTTER_ACTOR (self)); clutter_actor_set_parent (CLUTTER_ACTOR (priv->events_pane), CLUTTER_ACTOR (self)); clutter_actor_set_parent (CLUTTER_ACTOR (priv->tasks_header_table), CLUTTER_ACTOR (self)); clutter_actor_set_parent (CLUTTER_ACTOR (priv->tasks_pane), CLUTTER_ACTOR (self)); on_the_next_hour = jana_ecal_utils_time_now_local (); jana_time_set_minutes (on_the_next_hour, 0); jana_time_set_seconds (on_the_next_hour, 0); jana_utils_time_adjust (on_the_next_hour, 0, 0, 0, 1, 0, 0); jana_utils_time_diff (now, on_the_next_hour, NULL, NULL, NULL, NULL, NULL, &next_timeout_seconds); priv->refresh_timeout_id = g_timeout_add_seconds (next_timeout_seconds % (60 * 10), _first_refresh_timeout_cb, self); g_object_unref (now); g_object_unref (on_the_next_hour); }
void mnb_home_widget_set_edit_mode (MnbHomeWidget *self, gboolean edit_mode) { //if (edit_mode == self->priv->edit_mode) // return; DEBUG ("%d -> %d for widget %s", self->priv->edit_mode, edit_mode, self->priv->settings_path); self->priv->edit_mode = edit_mode; //g_object_notify (G_OBJECT (self), "edit-mode"); /* FIXME: should hold refs to the actors rather than destroy/recreate them? */ mx_bin_set_child (MX_BIN (self), NULL); /* FIXME: animate this */ if (edit_mode) { ClutterActor *table; table = mx_table_new (); mx_bin_set_child (MX_BIN (self), table); if (!STR_EMPTY (self->priv->module)) { ClutterActor *config, *remove; remove = mx_button_new_with_label ("x"); mx_table_insert_actor_with_properties (MX_TABLE (table), remove, 0, 1, "x-expand", FALSE, "y-expand", FALSE, "x-fill", FALSE, "y-fill", FALSE, NULL); g_signal_connect (remove, "clicked", G_CALLBACK (home_widget_remove_module), self); if (self->priv->app != NULL) config = dawati_home_plugins_app_get_configuration ( self->priv->app); else config = mx_label_new_with_text (_("Plugin missing")); if (CLUTTER_IS_ACTOR (config)) mx_table_insert_actor_with_properties (MX_TABLE (table), config, 1, 0, "x-expand", TRUE, "y-expand", TRUE, "x-fill", TRUE, "y-fill", TRUE, NULL); } else /* STR_EMPTY (self->priv->module) */ { ClutterActor *button; button = mx_button_new_with_label ("+"); mx_table_insert_actor (MX_TABLE (table), button, 0, 0); g_signal_connect (button, "clicked", G_CALLBACK (home_widget_add_module), self); } clutter_actor_show_all (table); } else /* !edit_mode */ { ClutterActor *widget = NULL; if (self->priv->app != NULL) { widget = dawati_home_plugins_app_get_widget (self->priv->app); if (!CLUTTER_IS_ACTOR (widget)) /* FIXME: make this better */ { widget = mx_label_new_with_text (_("Broken plugin")); } } else if (!STR_EMPTY (self->priv->module)) { widget = mx_label_new_with_text (_("Plugin missing")); } if (widget != NULL) mx_bin_set_child (MX_BIN (self), widget); } }
void scroll_grid_main (ClutterContainer *stage) { ClutterActor *scroll, *grid, *table, *label, *visible_entry, *stride_entry; int i; scroll = mx_scroll_view_new (); clutter_container_add_actor (stage, scroll); clutter_actor_set_position (scroll, 10, 10); clutter_actor_set_size (scroll, 400, 400); grid = mx_grid_new (); clutter_container_add_actor (CLUTTER_CONTAINER (scroll), grid); for (i = 1; i <= 200; i++) { ClutterActor *button; gchar *text; text = g_strdup_printf ("Button %d", i); button = mx_button_new_with_label (text); clutter_container_add_actor (CLUTTER_CONTAINER (grid), button); mx_widget_set_tooltip_text (MX_WIDGET (button), "test"); if (i == 1) g_signal_connect (button, "clicked", G_CALLBACK (swap_orientation), grid); g_free (text); } table = mx_table_new (); label = mx_label_new_with_text ("Make button visible:"); visible_entry = mx_entry_new (); mx_table_insert_actor_with_properties (MX_TABLE (table), label, 0, 0, "x-expand", FALSE, NULL); mx_table_insert_actor (MX_TABLE (table), visible_entry, 0, 1); label = mx_label_new_with_text ("Set max-stride:"); stride_entry = mx_entry_new (); mx_table_insert_actor_with_properties (MX_TABLE (table), label, 1, 0, "x-expand", FALSE, NULL); mx_table_insert_actor (MX_TABLE (table), stride_entry, 1, 1); clutter_actor_set_position (table, 10, 420); clutter_actor_set_width (table, 400); clutter_container_add_actor (stage, table); g_signal_connect (mx_entry_get_clutter_text (MX_ENTRY (visible_entry)), "activate", G_CALLBACK (ensure_visible), grid); g_signal_connect (mx_entry_get_clutter_text (MX_ENTRY (stride_entry)), "activate", G_CALLBACK (set_max_stride), grid); }
void entry_main (ClutterContainer *stage) { ClutterActor *entry, *button, *clear_button; entry = mx_entry_new_with_text ("Hello World!"); clutter_actor_set_position (entry, 20, 20); clutter_actor_set_width (entry, 150); clutter_container_add_actor (stage, entry); clutter_stage_set_key_focus (CLUTTER_STAGE (clutter_actor_get_stage (entry)), mx_entry_get_clutter_text (MX_ENTRY (entry))); entry = mx_entry_new (); clutter_actor_set_position (entry, 20, 70); clutter_container_add_actor (stage, entry); mx_entry_set_hint_text (MX_ENTRY (entry), "hint hint..."); #ifdef HAVE_CLUTTER_IMCONTEXT clutter_imtext_set_autoshow_im (CLUTTER_IMTEXT (mx_entry_get_clutter_text (MX_ENTRY (entry))), TRUE); #else g_debug ("Input method support is disabled"); #endif g_signal_connect (G_OBJECT (entry), "notify::text", G_CALLBACK (text_changed_cb), NULL); button = mx_button_new_with_label ("Set"); clutter_actor_set_position (button, 20, 120); g_signal_connect (button, "clicked", G_CALLBACK (btn_clicked_cb), entry); clear_button = mx_button_new_with_label ("clear"); clutter_actor_set_position (clear_button, 70, 120); g_signal_connect (clear_button, "clicked", G_CALLBACK (clear_btn_clicked_cb), entry); clutter_container_add (stage, button, clear_button, NULL); entry = mx_entry_new (); clutter_actor_set_position (entry, 20, 170); clutter_container_add_actor (stage, entry); mx_entry_set_hint_text (MX_ENTRY (entry), "Search..."); mx_entry_set_primary_icon_from_file (MX_ENTRY (entry), "edit-find.png"); mx_entry_set_secondary_icon_from_file (MX_ENTRY (entry), "edit-clear.png"); mx_entry_set_icon_highlight_suffix (MX_ENTRY (entry), "-highlight"); mx_entry_set_secondary_icon_tooltip_text (MX_ENTRY (entry), "one"); mx_entry_set_primary_icon_tooltip_text (MX_ENTRY (entry), "two"); g_signal_connect (entry, "primary-icon-clicked", G_CALLBACK (print_notice), "primary icon clicked\n"); g_signal_connect (entry, "secondary-icon-clicked", G_CALLBACK (print_notice), "secondary icon clicked\n"); entry = mx_entry_new (); clutter_actor_set_position (entry, 20, 220); clutter_container_add_actor (stage, entry); mx_entry_set_hint_text (MX_ENTRY (entry), "Secret!"); mx_entry_set_password_char (MX_ENTRY (entry), 0x2022); }
static void dawati_bt_shell_init (DawatiBtShell *shell) { ClutterActor *label, *active_label, *active_box, *settings_button; DawatiBtShellPrivate *priv = GET_PRIVATE (shell); priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); priv->requests = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); priv->notification = notify_notification_new ("", NULL, icon); notify_notification_set_timeout (priv->notification, NOTIFY_EXPIRES_NEVER); /* TRANSLATORS: button in a notification, will open the * bluetooth panel */ notify_notification_add_action (priv->notification, "show", _("Show"), (NotifyActionCallback)_notify_action_cb, shell, NULL); mx_box_layout_set_orientation (MX_BOX_LAYOUT (shell), MX_ORIENTATION_VERTICAL); label = mx_label_new_with_text (_("Bluetooth")); mx_stylable_set_style_class (MX_STYLABLE (label), "titleBar"); mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (shell), label, -1, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); priv->content = mx_box_layout_new (); clutter_actor_set_name (priv->content, "bt-panel-content"); mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->content), TRUE); mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->content), MX_ORIENTATION_VERTICAL); mx_box_layout_insert_actor (MX_BOX_LAYOUT (shell), priv->content, -1); active_box = mx_box_layout_new (); clutter_actor_set_name (active_box, "bt-panel-active-box"); mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content), active_box, -1); /* TRANSLATORS: Label for bluetooth enable/disable toggle */ active_label = mx_label_new_with_text (_("Active")); mx_stylable_set_style_class (MX_STYLABLE (active_label), "BtTitle"); mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (active_box), active_label, -1, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, "y-fill", FALSE, "y-align", MX_ALIGN_MIDDLE, NULL); priv->kill_toggle = mx_toggle_new (); priv->kill_handler = g_signal_connect (priv->kill_toggle, "notify::active", G_CALLBACK (_toggle_active_cb), shell); mx_box_layout_insert_actor (MX_BOX_LAYOUT (active_box), priv->kill_toggle, -1); /* devices that are requesting something go here */ priv->request_box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->request_box), MX_ORIENTATION_VERTICAL); mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->request_box), TRUE); mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content), priv->request_box, -1); /* connected devices go here */ priv->device_panelbox = g_object_ref (mx_box_layout_new ()); mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->device_panelbox), MX_ORIENTATION_VERTICAL); mx_stylable_set_style_class (MX_STYLABLE (priv->device_panelbox), "contentPanel"); priv->info_label = mx_label_new_with_text (_("Nothing connected")); mx_stylable_set_style_class (MX_STYLABLE (priv->info_label), "BtTitle"); clutter_actor_hide (priv->info_label); mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_panelbox), priv->info_label, -1); priv->device_box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->device_box), MX_ORIENTATION_VERTICAL); mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->device_box), TRUE); mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_panelbox), priv->device_box, -1); /* button row */ priv->button_box = mx_box_layout_new (); clutter_actor_set_name (priv->button_box, "bt-panel-button-box"); mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->button_box), TRUE); mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->content), priv->button_box, -1, "expand", TRUE, "x-fill", TRUE, NULL); mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->button_box), mx_box_layout_new (), 0, "expand", TRUE, NULL); priv->send_button = mx_button_new_with_label (_("Send file")); g_signal_connect (priv->send_button, "clicked", G_CALLBACK (_send_clicked_cb), shell); mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box), priv->send_button, 1); priv->add_button = mx_button_new_with_label (_("Add new")); g_signal_connect (priv->add_button, "clicked", G_CALLBACK (_add_clicked_cb), shell); mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box), priv->add_button, 2); settings_button = mx_button_new_with_label (_("Settings")); g_signal_connect (settings_button, "clicked", G_CALLBACK (_settings_clicked_cb), shell); mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box), settings_button, 3); dawati_bt_shell_init_applet (shell); priv->cm = carrick_connman_manager_new (); g_signal_connect (priv->cm, "notify::available-technologies", G_CALLBACK (_available_techs_changed), shell); g_signal_connect (priv->cm, "notify::enabled-technologies", G_CALLBACK (_enabled_techs_changed), shell); #ifdef TEST_WITH_BOGUS_DATA g_debug ("TEST_WITH_BOGUS_DATA: Adding false devices & requests, " "and setting Bluetooth available even if connman is not there"); /* Dummies for quick testing without bluetooth devices or connman */ dawati_bt_shell_add_device (shell, "TestDeviceA", "a"); dawati_bt_shell_add_device (shell, "TestDeviceB", "b"); dawati_bt_shell_add_request (shell, "TestDeviceC", "c", DAWATI_BT_REQUEST_TYPE_PIN, NULL); dawati_bt_shell_add_request (shell, "TestDeviceD", "d", DAWATI_BT_REQUEST_TYPE_CONFIRM, "001234"); dawati_bt_shell_add_request (shell, "TestDeviceE", "e", DAWATI_BT_REQUEST_TYPE_AUTH, "0000111f-0000-1000-8000-00805f9b34fb"); priv->enabled = priv->available = TRUE; dawati_bt_shell_update (shell); #endif }
int main (int argc, char **argv) { ClutterActor *stage = stage; ClutterActor *side_box; ClutterActor *button_box; ClutterActor *box; ClutterAnimation *anim; MashLightSet *light_set; MxStyle *style; GError *error = NULL; Data data; int i; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; style = mx_style_get_default (); if (!mx_style_load_from_file (style, "lights.css", &error)) { g_warning ("Error setting style: %s", error->message); g_clear_error (&error); } stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 800, 600); side_box = mx_table_new (); clutter_actor_set_name (side_box, "side-box"); clutter_container_add_actor (CLUTTER_CONTAINER (stage), side_box); clutter_actor_set_size (side_box, 300, clutter_actor_get_height (stage)); clutter_actor_set_x (side_box, clutter_actor_get_width (stage) - clutter_actor_get_width (side_box)); button_box = mx_table_new (); mx_table_add_actor (MX_TABLE (side_box), button_box, 0, 0); data.notebook = mx_notebook_new (); mx_table_add_actor (MX_TABLE (side_box), data.notebook, 1, 0); data.model = mash_model_new_from_file (MASH_DATA_NONE, argc > 1 ? argv[1] : "suzanne.ply", &error); if (data.model == NULL) { g_warning ("Error loading model: %s", error->message); g_clear_error (&error); return 1; } light_set = mash_light_set_new (); box = clutter_box_new (clutter_fixed_layout_new ()); clutter_actor_set_size (data.model, 400, 400); clutter_actor_set_position (data.model, 50.0, 100.0); clutter_container_add_actor (CLUTTER_CONTAINER (box), data.model); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); g_signal_connect_swapped (box, "paint", G_CALLBACK (cogl_set_depth_test_enabled), GINT_TO_POINTER (TRUE)); g_signal_connect_data (box, "paint", G_CALLBACK (cogl_set_depth_test_enabled), GINT_TO_POINTER (FALSE), NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED); data.light_marker_material = cogl_material_new (); { CoglColor color; cogl_color_set_from_4ub (&color, 255, 0, 0, 255); /* Use the layer state to ignore the vertex color from the shader so that the light marker won't itself be lit */ cogl_material_set_layer_combine_constant (data.light_marker_material, 0, &color); cogl_material_set_layer_combine (data.light_marker_material, 0, "RGBA = REPLACE(CONSTANT)", NULL); } clutter_actor_set_rotation (data.model, CLUTTER_Y_AXIS, 0.0f, clutter_actor_get_width (data.model) / 2.0f, 0.0f, 0.0f); anim = clutter_actor_animate (data.model, CLUTTER_LINEAR, 3000, "rotation-angle-y", 360.0f, NULL); clutter_animation_set_loop (anim, TRUE); for (i = 0; i < N_LIGHTS; i++) { ClutterActor *table = mx_table_new (); ClutterActor *button; static ClutterActor *(* constructors[N_LIGHTS]) (void) = { mash_directional_light_new, mash_point_light_new, mash_spot_light_new }; static const ClutterColor black = { 0, 0, 0, 255 }; data.lights[i] = constructors[i] (); button = mx_button_new_with_label (G_OBJECT_TYPE_NAME (data.lights[i])); mx_table_add_actor (MX_TABLE (button_box), button, i, 0); /* Default to disable all of the lights */ g_object_set (data.lights[i], "ambient", &black, "diffuse", &black, "specular", &black, NULL); data.notebook_buttons[i] = button; clutter_container_add_actor (CLUTTER_CONTAINER (box), data.lights[i]); mash_light_set_add_light (light_set, MASH_LIGHT (data.lights[i])); add_color_prop (table, "ambient light", G_OBJECT (data.lights[i]), "ambient"); add_color_prop (table, "diffuse light", G_OBJECT (data.lights[i]), "diffuse"); add_color_prop (table, "specular light", G_OBJECT (data.lights[i]), "specular"); if (MASH_IS_POINT_LIGHT (data.lights[i])) { add_float_prop (table, "constant attenuation", G_OBJECT (data.lights[i]), "constant-attenuation", 0.0f, 10.0f); add_float_prop (table, "linear attenuation", G_OBJECT (data.lights[i]), "linear-attenuation", 0.0f, 10.0f); add_float_prop (table, "quadratic attenuation", G_OBJECT (data.lights[i]), "quadratic-attenuation", 0.0f, 10.0f); } if (MASH_IS_SPOT_LIGHT (data.lights[i])) { clutter_actor_set_x (data.lights[i], 250); add_float_prop (table, "spot cutoff", G_OBJECT (data.lights[i]), "spot-cutoff", 0.0f, 90.0f); add_float_prop (table, "spot exponent", G_OBJECT (data.lights[i]), "spot-exponent", 0.0f, 128.0f); } clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); data.notebook_pages[i] = table; } { ClutterActor *button; ClutterActor *table; CoglHandle material; float maximum_shininess; material = mash_model_get_pipeline (MASH_MODEL (data.model)); /* Before version 1.3.10 on the 1.3 branch and 1.2.14 on the 1.2 branch Cogl would remap the shininess property to the range [0,1]. After this it is just a value greater or equal to zero (but GL imposes a limit of 128.0) */ if (clutter_check_version (1, 3, 9) || (clutter_major_version == 1 && clutter_minor_version == 2 && clutter_micro_version >= 13)) maximum_shininess = 128.0f; else maximum_shininess = 1.0f; cogl_material_set_shininess (material, maximum_shininess); button = mx_button_new_with_label ("Material"); data.notebook_buttons[i] = button; mx_table_add_actor (MX_TABLE (button_box), button, i, 0); table = mx_table_new (); data.notebook_pages[i] = table; clutter_container_add_actor (CLUTTER_CONTAINER (data.notebook), table); add_material_color_prop (table, "emission", material, cogl_material_set_emission, cogl_material_get_emission); add_material_color_prop (table, "diffuse", material, cogl_material_set_diffuse, cogl_material_get_diffuse); add_material_color_prop (table, "ambient", material, cogl_material_set_ambient, cogl_material_get_ambient); add_material_color_prop (table, "specular", material, cogl_material_set_specular, cogl_material_get_specular); add_material_float_prop (table, "shininess", material, 0.0f, maximum_shininess, cogl_material_set_shininess, cogl_material_get_shininess); } mash_model_set_light_set (MASH_MODEL (data.model), light_set); g_object_unref (light_set); for (i = 0; i < N_PAGES; i++) { g_signal_connect (data.notebook_buttons[i], "notify::toggled", G_CALLBACK (notebook_button_cb), &data); mx_button_set_is_toggle (MX_BUTTON (data.notebook_buttons[i]), TRUE); } mx_button_set_toggled (MX_BUTTON (data.notebook_buttons[0]), TRUE); g_signal_connect (stage, "motion-event", G_CALLBACK (motion_event_cb), &data); clutter_actor_show (stage); clutter_main (); cogl_handle_unref (data.light_marker_material); return 0; }
static void mtp_bin_constructed (GObject *self) { MtpBinPrivate *priv = MTP_BIN (self)->priv; MtpToolbar *toolbar = (MtpToolbar*) mtp_toolbar_new (); ClutterActor *box = (ClutterActor *)self; ClutterActor *jar = mtp_jar_new (); GConfClient *client; priv->toolbar = (ClutterActor*)toolbar; priv->jar = jar; clutter_actor_set_name (jar, "jar"); clutter_actor_set_height ((ClutterActor*)toolbar, TOOLBAR_HEIGHT); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 10); clutter_container_add (CLUTTER_CONTAINER (box), (ClutterActor*)toolbar, NULL); { ClutterActor *dummy = mx_label_new (); ClutterActor *hbox = mx_box_layout_new (); ClutterActor *button = mx_button_new_with_label (_("Save toolbar")); clutter_actor_set_name (hbox, "message-box"); clutter_actor_set_name (button, "save-button"); priv->err_msg = _("Sorry, you'll have to remove a panel before you can " "add a new one."); priv->normal_msg = _("You can add, remove, and reorder many of the panels " "in your toolbar."); priv->message = mx_label_new_with_text (priv->normal_msg); clutter_actor_set_name (priv->message, "error-message"); clutter_container_add (CLUTTER_CONTAINER (box), hbox, NULL); clutter_container_add (CLUTTER_CONTAINER (hbox), priv->message, dummy, button, NULL); clutter_container_child_set (CLUTTER_CONTAINER (hbox), dummy, "expand", TRUE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (hbox), button, "x-align", MX_ALIGN_END, "y-align", MX_ALIGN_MIDDLE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (hbox), priv->message, "y-align", MX_ALIGN_MIDDLE, NULL); g_signal_connect (button, "clicked", G_CALLBACK (mtp_bin_save_button_clicked_cb), self); g_signal_connect (toolbar, "notify::free-space", G_CALLBACK (mtp_bin_toolbar_free_space_cb), self); } clutter_container_add (CLUTTER_CONTAINER (box), jar, NULL); clutter_container_child_set (CLUTTER_CONTAINER (box), jar, "expand", TRUE, NULL); client = priv->client = gconf_client_get_default (); gconf_client_add_dir (client, KEY_DIR, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); }
static void mpd_storage_device_tile_init (MpdStorageDeviceTile *self) { MpdStorageDeviceTilePrivate *priv = GET_PRIVATE (self); ClutterText *text; ClutterActor *separator; mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL); mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (self), true); priv->table = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (priv->table), 5); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (self), priv->table, -1, "x-fill", true, NULL); /* 0 1 2 +--------------------------+ Table 0 | | Text | Open | 1 | Icon | Progress | Eject | +------+-----------+-------+ Vbox 2 | <message> .. Import data | +--------------------------+ 3 | ======================== | +--------------------------+ */ /* * Column 0: icon */ priv->icon = clutter_texture_new (); clutter_actor_set_size (priv->icon, MPD_STORAGE_DEVICE_TILE_ICON_SIZE, MPD_STORAGE_DEVICE_TILE_ICON_SIZE); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->icon, 0, 0, "row-span", 2, "column-span", 1, "x-align", MX_ALIGN_START, "x-expand", false, "x-fill", false, "y-align", MX_ALIGN_MIDDLE, "y-expand", false, "y-fill", false, NULL); /* * Column 1 */ /* Text */ priv->label = mx_label_new (); clutter_actor_set_width (priv->label, 200.0); text = (ClutterText *) mx_label_get_clutter_text (MX_LABEL (priv->label)); clutter_text_set_line_wrap (text, true); clutter_text_set_line_wrap_mode (text, PANGO_WRAP_WORD); clutter_text_set_single_line_mode (text, false); clutter_text_set_ellipsize (text, PANGO_ELLIPSIZE_END); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->label, 0, 1, "x-align", MX_ALIGN_START, "x-expand", true, "x-fill", true, "y-align", MX_ALIGN_MIDDLE, "y-expand", false, "y-fill", false, NULL); /* Progress */ priv->meter = mx_progress_bar_new (); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->meter, 1, 1, "x-align", MX_ALIGN_START, "x-expand", true, "x-fill", true, "y-align", MX_ALIGN_MIDDLE, "y-expand", false, "y-fill", false, NULL); /* * Column 2: buttons */ /* Open button */ priv->open = mx_button_new_with_label (_("Open")); g_signal_connect (priv->open, "clicked", G_CALLBACK (_open_clicked_cb), self); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->open, 0, 2, "x-align", MX_ALIGN_END, "x-expand", false, "x-fill", true, "y-align", MX_ALIGN_END, "y-expand", false, "y-fill", false, NULL); /* Eject button */ priv->eject = mx_button_new_with_label (_("Eject")); g_signal_connect (priv->eject, "clicked", G_CALLBACK (_eject_clicked_cb), self); mx_table_add_actor_with_properties (MX_TABLE (priv->table), priv->eject, 1, 2, "x-align", MX_ALIGN_END, "x-expand", false, "x-fill", true, "y-align", MX_ALIGN_MIDDLE, "y-expand", false, "y-fill", false, NULL); /* * Row 2 */ /* Import button */ priv->import = mx_button_new (); clutter_actor_set_name (priv->import, "import"); g_signal_connect (priv->import, "clicked", G_CALLBACK (_import_clicked_cb), self); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (self), priv->import, -1, "expand", false, "x-align", MX_ALIGN_END, "x-fill", false, NULL); /* * 4th row: separator */ /* Separator */ separator = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (separator), "separator"); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (self), separator, -1, "expand", false, "x-align", MX_ALIGN_MIDDLE, "x-fill", true, "y-align", MX_ALIGN_START, "y-fill", false, NULL); }