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 ClutterActor * mex_menu_create_layout (MexMenu *menu, gboolean lower) { ClutterActor *layout, *scroll; MexMenuPrivate *priv = menu->priv; layout = mx_box_layout_new (); if (priv->min_width >= 0) g_object_set (G_OBJECT (layout), "min-width", priv->min_width, NULL); mx_box_layout_set_orientation (MX_BOX_LAYOUT (layout), MX_ORIENTATION_VERTICAL); mx_stylable_set_style_class (MX_STYLABLE (layout), "Menu"); clutter_container_add_actor (CLUTTER_CONTAINER (menu), layout); priv->action_layout = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->action_layout), MX_ORIENTATION_VERTICAL); scroll = mex_scroll_view_new (); clutter_container_add_actor (CLUTTER_CONTAINER (scroll), priv->action_layout); clutter_container_add_actor (CLUTTER_CONTAINER (layout), scroll); g_object_set_data (G_OBJECT (layout), "action-layout", priv->action_layout); return layout; }
int main (int argc, char **argv) { const ClutterColor dark_gray = { 0x40, 0x40, 0x40, 0xff }; ClutterActor *box, *stage; MxApplication *app; MxWindow *window; mex_init (&argc, &argv); app = mx_application_new (&argc, &argv, "test-mex-expander-box", 0); clutter_init (&argc, &argv); mex_style_load_default (); window = mx_application_create_window (app); stage = (ClutterActor *)mx_window_get_clutter_stage (window); clutter_stage_set_color (CLUTTER_STAGE (stage), &dark_gray); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL); add_pictures (box); clutter_container_add_actor (CLUTTER_CONTAINER (stage), box); mx_window_set_has_toolbar (window, FALSE); clutter_actor_set_size (stage, 640, 480); clutter_actor_show (stage); clutter_main (); return 0; }
static ClutterActor * _make_notification_actor (MexNotification *notification) { ClutterActor *box; ClutterActor *label, *icon; box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_HORIZONTAL); if (notification->icon) { icon = mx_icon_new (); clutter_actor_set_size (icon, 26, 26); mx_icon_set_icon_name (MX_ICON (icon), notification->icon); clutter_container_add_actor (CLUTTER_CONTAINER (box), icon); mx_box_layout_child_set_y_align (MX_BOX_LAYOUT (box), icon, MX_ALIGN_MIDDLE); } label = mx_label_new_with_text (notification->message); mx_label_set_y_align (MX_LABEL (label), MX_ALIGN_MIDDLE); clutter_container_add_actor (CLUTTER_CONTAINER (box), label); return box; }
static void mex_clock_bin_init (MexClockBin *self) { MexClockBinPrivate *priv = self->priv = CLOCK_BIN_PRIVATE (self); priv->clock_hbox = mx_box_layout_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->clock_hbox), "MexClockBin"); clutter_actor_set_parent (priv->clock_hbox, CLUTTER_ACTOR (self)); priv->time_label = mx_label_new (); priv->icon = mx_icon_new (); mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->clock_hbox), priv->time_label, 0, "x-align", MX_ALIGN_START, "expand", TRUE, NULL); mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->clock_hbox), priv->icon, 1, NULL); g_signal_connect (self, "actor-added", G_CALLBACK (mex_clock_bin_actor_added), NULL); g_signal_connect (self, "actor-removed", G_CALLBACK (mex_clock_bin_actor_removed), NULL); mex_clock_update_cb (self); }
static void mpl_content_pane_init (MplContentPane *self) { MplContentPanePrivate *priv = GET_PRIVATE (self); mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (self), 6); priv->header = (MxBoxLayout *) mx_box_layout_new (); mx_box_layout_set_spacing (priv->header, 12); mx_stylable_set_style_class (MX_STYLABLE (priv->header), "header"); clutter_actor_set_height ((ClutterActor *) priv->header, 36); mx_box_layout_insert_actor (MX_BOX_LAYOUT (self), CLUTTER_ACTOR (priv->header), 0); clutter_container_child_set (CLUTTER_CONTAINER (self), (ClutterActor *) priv->header, "expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, NULL); priv->title = (MxLabel *) mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->title), "title"); mx_box_layout_insert_actor (priv->header, (ClutterActor *) priv->title, 0); clutter_container_child_set (CLUTTER_CONTAINER (priv->header), (ClutterActor *) priv->title, "expand", TRUE, "x-fill", TRUE, "y-fill", FALSE, NULL); }
static void mex_queue_button_init (MexQueueButton *self) { ClutterActor *temp_text; self->priv = QUEUE_BUTTON_PRIVATE (self); self->priv->inner_box = mx_box_layout_new (); self->priv->icon = mx_icon_new (); self->priv->label = mx_label_new_with_text ("Unknown queue state"); self->priv->spinner = mx_spinner_new (); self->priv->queue_model = mex_queue_model_dup_singleton (); g_signal_connect (self->priv->spinner, "looped", (GCallback)_spinner_looped_cb, self); clutter_container_add (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->label, self->priv->icon, self->priv->spinner, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->label, "expand", TRUE, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->icon, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, "x-align", MX_ALIGN_END, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->spinner, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, "x-align", MX_ALIGN_END, NULL); clutter_actor_hide (self->priv->spinner); mx_bin_set_child (MX_BIN (self), self->priv->inner_box); mx_bin_set_fill (MX_BIN (self), TRUE, FALSE); temp_text = mx_label_get_clutter_text (MX_LABEL (self->priv->label)); clutter_text_set_ellipsize (CLUTTER_TEXT (temp_text), PANGO_ELLIPSIZE_NONE); g_signal_connect (self, "notify::toggled", (GCallback)_queue_button_notify_toggled_cb, self); mx_button_set_is_toggle (MX_BUTTON (self), TRUE); }
static void mpd_devices_tile_init (MpdDevicesTile *self) { MpdDevicesTilePrivate *priv = GET_PRIVATE (self); ClutterActor *tile; GList *mounts; priv->tiles = g_hash_table_new (g_direct_hash, g_direct_equal); priv->vbox = mx_box_layout_new (); mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->vbox), TRUE); mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->vbox), MX_ORIENTATION_VERTICAL); clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->vbox); tile = mpd_default_device_tile_new (); clutter_container_add_actor (CLUTTER_CONTAINER (priv->vbox), tile); priv->monitor = g_volume_monitor_get (); g_signal_connect (priv->monitor, "mount-added", G_CALLBACK (_monitor_mount_added_cb), self); g_signal_connect (priv->monitor, "mount-changed", G_CALLBACK (_monitor_mount_changed_cb), self); g_signal_connect (priv->monitor, "mount-removed", G_CALLBACK (_monitor_mount_removed_cb), self); mounts = g_volume_monitor_get_mounts (priv->monitor); g_list_foreach (mounts, (GFunc) _add_mount_cb, self); g_list_free (mounts); }
static void mex_tile_init (MexTile *self) { MexTilePrivate *priv = self->priv = TILE_PRIVATE (self); const ClutterColor opaque = { 0x00, 0x00, 0x00, 0x00 }; ClutterEffect *fade; /* create a template material for the header background from which cheap * copies can be made for each instance */ if (G_UNLIKELY (!template_material)) template_material = cogl_material_new (); priv->material = cogl_material_copy (template_material); /* layout for primary and secondary labels */ priv->box_layout = mx_box_layout_new (); mx_box_layout_set_spacing (MX_BOX_LAYOUT (priv->box_layout), 12); /* add fade effect to the box layout */ fade = (ClutterEffect*) mx_fade_effect_new (); mx_fade_effect_set_border (MX_FADE_EFFECT (fade), 0, 50, 0, 0); mx_fade_effect_set_color (MX_FADE_EFFECT (fade), &opaque); clutter_actor_add_effect_with_name (priv->box_layout, "fade", fade); clutter_actor_meta_set_enabled (CLUTTER_ACTOR_META (fade), TRUE); clutter_actor_push_internal (CLUTTER_ACTOR (self)); clutter_actor_set_parent (priv->box_layout, CLUTTER_ACTOR (self)); clutter_actor_pop_internal (CLUTTER_ACTOR (self)); priv->label = clutter_text_new (); priv->secondary_label = clutter_text_new (); clutter_actor_set_opacity (priv->secondary_label, 128); clutter_container_add (CLUTTER_CONTAINER (priv->box_layout), priv->label, priv->secondary_label, NULL); priv->header_visible = TRUE; priv->timeline = clutter_timeline_new (DURATION); priv->important_alpha = clutter_alpha_new_full (priv->timeline, CLUTTER_EASE_OUT_QUAD); g_signal_connect_object (priv->timeline, "new-frame", G_CALLBACK (mex_tile_important_new_frame_cb), self, 0); g_signal_connect_object (priv->timeline, "completed", G_CALLBACK (mex_tile_timeline_completed_cb), self, 0); g_signal_connect (self, "style-changed", G_CALLBACK (mex_tile_style_changed_cb), NULL); g_signal_connect (self, "actor-added", G_CALLBACK (mex_tile_actor_added), NULL); g_signal_connect (self, "actor-removed", G_CALLBACK (mex_tile_actor_removed), NULL); }
static void mex_content_box_init (MexContentBox *self) { MexContentBoxPrivate *priv = self->priv = CONTENT_BOX_PRIVATE (self); ClutterActor *hline, *box; priv->thumb_width = 426; priv->thumb_height = 240; /* Create description panel */ box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL); hline = clutter_rectangle_new_with_color (&hline_color); clutter_actor_set_height (hline, 1); priv->panel = mex_info_panel_new (MEX_INFO_PANEL_MODE_SIMPLE); clutter_container_add (CLUTTER_CONTAINER (box), hline, priv->panel, NULL); /* monitor key press events */ g_signal_connect (self, "key-press-event", G_CALLBACK (mex_content_box_key_press_event_cb), self); /* Create tile */ priv->tile = mex_content_tile_new (); g_object_set (G_OBJECT (priv->tile), "thumb-width", priv->thumb_width, "thumb-height", priv->thumb_height, NULL); mx_bin_set_fill (MX_BIN (priv->tile), TRUE, TRUE); clutter_actor_set_reactive (priv->tile, TRUE); g_signal_connect (priv->tile, "button-release-event", G_CALLBACK (mex_content_box_tile_clicked_cb), self); /* Create secondary box for tile/menu */ priv->box = mex_expander_box_new (); mex_expander_box_set_important (MEX_EXPANDER_BOX (priv->box), TRUE); mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (priv->box), MEX_EXPANDER_BOX_RIGHT); mex_expander_box_set_primary_child (MEX_EXPANDER_BOX (priv->box), priv->tile); /* Pack box and panel into self */ mex_expander_box_set_primary_child (MEX_EXPANDER_BOX (self), priv->box); mex_expander_box_set_secondary_child (MEX_EXPANDER_BOX (self), box); /* Create the action list */ priv->action_list = mex_action_list_new (); mex_expander_box_set_secondary_child (MEX_EXPANDER_BOX (priv->box), priv->action_list); /* Connect to the open notify signal */ g_signal_connect (self, "notify::open", G_CALLBACK (mex_content_box_notify_open_cb), NULL); }
static void mex_telepathy_channel_create_busy_box (MexTelepathyChannel *self) { MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv; ClutterActor *calling_padding; ClutterActor *calling_box; ClutterActor *spinner; ClutterActor *stack; priv->busy_label = mx_label_new(); mx_label_set_y_align (MX_LABEL (priv->busy_label), MX_ALIGN_MIDDLE); mx_label_set_x_align (MX_LABEL (priv->busy_label), MX_ALIGN_MIDDLE); spinner = mx_spinner_new (); calling_box = mx_box_layout_new (); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (calling_box), priv->busy_label, 0, "expand", TRUE, "x-align", MX_ALIGN_START, "x-fill", TRUE, NULL); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (calling_box), spinner, 1, "expand", TRUE, "x-align", MX_ALIGN_END, "x-fill", FALSE, NULL); priv->busy_box = mx_frame_new (); clutter_actor_set_width (CLUTTER_ACTOR (priv->busy_box), 475); mx_stylable_set_style_class (MX_STYLABLE (priv->busy_box), "CallingFrameBorder"); calling_padding = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (calling_padding), "CallingFrame"); mx_bin_set_child (MX_BIN (priv->busy_box), calling_padding); mx_bin_set_fill (MX_BIN (priv->busy_box), TRUE, TRUE); mx_bin_set_child (MX_BIN (calling_padding), calling_box); mx_bin_set_fill (MX_BIN (calling_padding), TRUE, TRUE); stack = mx_window_get_child (mex_get_main_window ()); clutter_container_add (CLUTTER_CONTAINER (stack), priv->busy_box, NULL); mx_stack_child_set_x_fill (MX_STACK (stack), priv->busy_box, FALSE); mx_stack_child_set_y_fill (MX_STACK (stack), priv->busy_box, FALSE); }
static void mex_column_view_init (MexColumnView *self) { MexColumnViewPrivate *priv = self->priv = COLUMN_VIEW_PRIVATE (self); /* Begin private children */ clutter_actor_push_internal (CLUTTER_ACTOR (self)); /* Create the header */ priv->header = mx_box_layout_new (); mx_box_layout_set_orientation ((MxBoxLayout *) priv->header, MX_ORIENTATION_HORIZONTAL); clutter_actor_push_internal (CLUTTER_ACTOR (self)); clutter_actor_set_parent (priv->header, CLUTTER_ACTOR (self)); clutter_actor_pop_internal (CLUTTER_ACTOR (self)); priv->button = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->button), "Header"); priv->label = mx_label_new (); g_object_set (priv->label, "clip-to-allocation", TRUE, "fade-out", TRUE, NULL); clutter_actor_add_child (CLUTTER_ACTOR (priv->button), priv->label); clutter_actor_add_child (priv->header, priv->button); clutter_container_child_set (CLUTTER_CONTAINER (priv->header), priv->button, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, "y-fill", TRUE, NULL); g_signal_connect (priv->button, "clicked", G_CALLBACK (mex_column_header_clicked_cb), self); priv->scroll = mex_scroll_view_new (); mx_kinetic_scroll_view_set_scroll_policy (MX_KINETIC_SCROLL_VIEW (priv->scroll), MX_SCROLL_POLICY_VERTICAL); mex_scroll_view_set_indicators_hidden (MEX_SCROLL_VIEW (priv->scroll), TRUE); clutter_actor_set_parent (priv->scroll, CLUTTER_ACTOR (self)); priv->column = mex_column_new (); clutter_actor_add_child (CLUTTER_ACTOR (priv->scroll), priv->column); g_signal_connect (priv->column, "notify::opened", G_CALLBACK (mex_column_view_opened_cb), self); /* End of private children */ clutter_actor_pop_internal (CLUTTER_ACTOR (self)); /* Set the column as reactive and enable collapsing */ clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); }
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 void mx_button_init (MxButton *button) { MxButtonPrivate *priv; priv = button->priv = MX_BUTTON_GET_PRIVATE (button); clutter_actor_set_reactive ((ClutterActor *) button, TRUE); g_signal_connect (button, "style-changed", G_CALLBACK (mx_button_style_changed), NULL); priv->icon_visible = TRUE; priv->label_visible = TRUE; priv->icon_position = MX_POSITION_LEFT; /* take an extra reference to the hbox */ priv->hbox = g_object_ref (mx_box_layout_new ()); mx_bin_set_child (MX_BIN (button), priv->hbox); priv->icon = mx_icon_new (); priv->label = g_object_new (CLUTTER_TYPE_TEXT, "line-alignment", PANGO_ALIGN_CENTER, "ellipsize", PANGO_ELLIPSIZE_END, NULL); clutter_actor_add_child (priv->hbox, priv->icon); clutter_actor_add_child (priv->hbox, priv->label); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (priv->hbox), priv->label, TRUE); mx_box_layout_child_set_y_fill (MX_BOX_LAYOUT (priv->hbox), priv->label, FALSE); mx_box_layout_child_set_x_fill (MX_BOX_LAYOUT (priv->hbox), priv->label, FALSE); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (priv->hbox), priv->icon, TRUE); mx_box_layout_child_set_y_fill (MX_BOX_LAYOUT (priv->hbox), priv->icon, FALSE); mx_box_layout_child_set_x_fill (MX_BOX_LAYOUT (priv->hbox), priv->icon, FALSE); mx_button_update_contents (button); }
static ClutterActor * create_controls (RBShell *shell) { RBShellPlayer *player; ClutterActor *box; ClutterActor *button; int pos; gboolean playing; g_object_get (shell, "shell-player", &player, NULL); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 16); mx_stylable_set_style_class (MX_STYLABLE (box), "ControlsBox"); mx_stylable_set_style (MX_STYLABLE (box), style); clutter_actor_set_reactive (box, TRUE); /* XXX rtl? */ pos = 0; button = create_button ("PrevButton", "PrevButtonIcon", "media-skip-backward"); g_signal_connect_object (button, "clicked", G_CALLBACK (prev_clicked_cb), player, 0); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), button, pos++); button = create_button ("PlayPauseButton", "PlayPauseButtonIcon", "media-playback-start"); g_signal_connect_object (button, "clicked", G_CALLBACK (playpause_clicked_cb), player, 0); g_signal_connect_object (player, "playing-changed", G_CALLBACK (playing_changed_cb), button, 0); g_object_get (player, "playing", &playing, NULL); update_playing (MX_BUTTON (button), playing); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), button, pos++); button = create_button ("NextButton", "NextButtonIcon", "media-skip-forward"); g_signal_connect_object (button, "clicked", G_CALLBACK (next_clicked_cb), player, 0); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), button, pos++); g_object_unref (player); return box; }
static void mpd_folder_button_init (MpdFolderButton *self) { MpdFolderButtonPrivate *priv = GET_PRIVATE (self); ClutterActor *vbox; ClutterText *text; /* Box */ vbox = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL); mx_bin_set_child (MX_BIN (self), vbox); /* Icon */ priv->icon = clutter_texture_new (); clutter_texture_set_sync_size (CLUTTER_TEXTURE (priv->icon), true); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), priv->icon); clutter_container_child_set (CLUTTER_CONTAINER (vbox), priv->icon, "expand", false, "x-align", MX_ALIGN_MIDDLE, "x-fill", false, "y-align", MX_ALIGN_START, "y-fill", false, NULL); /* Label */ priv->label = mx_label_new (); text = (ClutterText *) mx_label_get_clutter_text (MX_LABEL (priv->label)); clutter_text_set_line_wrap_mode (text, PANGO_WRAP_WORD_CHAR); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), priv->label); clutter_container_child_set (CLUTTER_CONTAINER (vbox), priv->label, "expand", false, "x-align", MX_ALIGN_MIDDLE, "x-fill", false, "y-align", MX_ALIGN_START, "y-fill", false, NULL); }
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; }
int main (int argc, char *argv[]) { ClutterActor *stage, *box, *scrollview; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; mx_style_load_from_file (mx_style_get_default(), "style/default.css", NULL); stage = clutter_stage_get_default (); clutter_actor_set_size (stage, 640, 480); clutter_stage_set_user_resizable ((ClutterStage *) stage, TRUE); scrollview = mx_scroll_view_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), scrollview); clutter_actor_set_position (scrollview, 50, 50); clutter_actor_set_size (scrollview, 500, 300); box = mx_box_layout_new (); clutter_container_add_actor (CLUTTER_CONTAINER (scrollview), box); add_actor ((ClutterContainer*) box); add_actor ((ClutterContainer*) box); add_actor ((ClutterContainer*) box); g_signal_connect (stage, "key-release-event", G_CALLBACK (key_release_cb), box); g_signal_connect (stage, "notify::allocation", G_CALLBACK (stage_size_changed_cb), scrollview); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
static void mex_grid_view_init (MexGridView *self) { MexGridViewPrivate *priv = self->priv = GRID_VIEW_PRIVATE (self); ClutterActor *scroll_view; priv->state = STATE_CLOSED; /* Create the menu */ priv->menu_layout = mex_menu_new (); mex_resizing_hbox_set_max_depth (MEX_RESIZING_HBOX (priv->menu_layout), 1); /* Add a title/icon */ priv->menu_title = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->menu_title), "Header"); clutter_actor_set_name (priv->menu_title, "menu-header"); priv->menu = (ClutterActor*) mex_menu_get_layout (MEX_MENU (priv->menu_layout)); clutter_actor_set_width (priv->menu, MENU_MIN_WIDTH); clutter_actor_insert_child_at_index (priv->menu, priv->menu_title, 0); /* Add the grid */ priv->grid_layout = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->grid_layout), MX_ORIENTATION_VERTICAL); /* header */ priv->grid_title = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->grid_title), "Header"); clutter_actor_add_child (priv->grid_layout, priv->grid_title); /* scroll view */ scroll_view = mex_scroll_view_new (); mx_kinetic_scroll_view_set_scroll_policy (MX_KINETIC_SCROLL_VIEW (scroll_view), MX_SCROLL_POLICY_VERTICAL); mx_stylable_set_style_class (MX_STYLABLE (scroll_view), "Grid"); mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->grid_layout), scroll_view, 1, "expand", TRUE, NULL); /* grid */ priv->grid = mex_grid_new (); mx_bin_set_child (MX_BIN (scroll_view), priv->grid); clutter_actor_set_opacity (priv->grid, 0); /* Name actors so we can style */ clutter_actor_set_name (CLUTTER_ACTOR (self), "grid-page"); clutter_actor_set_name (priv->grid_layout, "content"); clutter_actor_push_internal (CLUTTER_ACTOR (self)); clutter_actor_set_parent (priv->menu_layout, CLUTTER_ACTOR (self)); clutter_actor_set_parent (priv->grid_layout, CLUTTER_ACTOR (self)); clutter_actor_pop_internal (CLUTTER_ACTOR (self)); /* timeline for animations */ priv->timeline = clutter_timeline_new (ANIMATION_DURATION); priv->alpha = clutter_alpha_new_full (priv->timeline, CLUTTER_EASE_IN_OUT_CUBIC); g_signal_connect (priv->timeline, "new-frame", G_CALLBACK (mex_grid_view_timeline_cb), self); g_signal_connect (priv->timeline, "completed", G_CALLBACK (mex_grid_view_timeline_complete_cb), self); }
static void mex_search_plugin_init (MexSearchPlugin *self) { MexProxy *suggest_proxy; ClutterActor *icon, *header, *text, *frame, *box, *hbox; MexSearchPluginPrivate *priv = self->priv = SEARCH_PLUGIN_PRIVATE (self); /* Load style data */ mx_style_load_from_file (mx_style_get_default (), PLUGIN_DATA_DIR "/style.css", NULL); /* Create the history model and models list */ priv->history_model = mex_feed_new (_("Search"), _("Search")); priv->model_info = mex_model_info_new_with_sort_funcs (MEX_MODEL (priv->history_model), "search", 0); g_object_unref (priv->history_model); priv->models = g_list_append (NULL, priv->model_info); /* Create the actions list */ memset (&priv->action_info, 0, sizeof (MexActionInfo)); priv->action_info.action = mx_action_new_full ("x-mex/search", _("Search"), G_CALLBACK (mex_search_plugin_history_cb), self); priv->action_info.mime_types = (gchar **)search_mimetypes; priv->actions = g_list_append (NULL, &priv->action_info); /* Create the suggestions model */ priv->suggest_model = mex_feed_new (_("Suggestions"), _("Google Suggestions")); /* Create the search page */ /* Create header */ icon = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (icon), "Search"); header = mx_box_layout_new (); mx_box_layout_set_spacing (MX_BOX_LAYOUT (header), 5); clutter_actor_set_name (header, "search-header"); /* Create search entry */ frame = mx_table_new (); clutter_actor_set_name (frame, "search-entry-frame"); priv->search_entry = mx_entry_new (); priv->spinner = mx_spinner_new (); mx_table_add_actor (MX_TABLE (frame), priv->search_entry, 0, 0); mx_table_add_actor (MX_TABLE (frame), priv->spinner, 0, 1); mx_table_child_set_x_fill (MX_TABLE (frame), priv->spinner, FALSE); mx_table_child_set_x_expand (MX_TABLE (frame), priv->spinner, FALSE); mx_table_child_set_y_fill (MX_TABLE (frame), priv->spinner, FALSE); mx_spinner_set_animating (MX_SPINNER (priv->spinner), FALSE); clutter_actor_hide (priv->spinner); clutter_container_add (CLUTTER_CONTAINER (header), icon, frame, NULL); clutter_container_child_set (CLUTTER_CONTAINER (header), icon, "x-fill", FALSE, "y-fill", FALSE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (header), frame, "expand", TRUE, "x-fill", TRUE, NULL); text = mx_entry_get_clutter_text (MX_ENTRY (priv->search_entry)); g_signal_connect_swapped (text, "activate", G_CALLBACK (mex_search_plugin_search_cb), self); g_signal_connect (priv->search_entry, "notify::text", G_CALLBACK (mex_search_text_changed_cb), self); g_signal_connect (priv->search_entry, "notify::style-pseudo-class", G_CALLBACK (mex_search_text_style_changed), header); /* Create the suggestions column */ priv->suggest_column = mx_box_layout_new (); clutter_actor_set_name (priv->suggest_column, "suggest-column"); mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->suggest_column), MX_ORIENTATION_VERTICAL); suggest_proxy = mex_generic_proxy_new (MEX_MODEL (priv->suggest_model), MX_TYPE_BUTTON); mex_generic_proxy_bind (MEX_GENERIC_PROXY (suggest_proxy), mex_enum_to_string (MEX_TYPE_CONTENT_METADATA, MEX_CONTENT_METADATA_TITLE), "label"); g_signal_connect (suggest_proxy, "object-created", G_CALLBACK (mex_search_proxy_add_cb), priv->suggest_column); g_signal_connect (suggest_proxy, "object-removed", G_CALLBACK (mex_search_proxy_remove_cb), priv->suggest_column); g_object_weak_ref (G_OBJECT (priv->suggest_column), (GWeakNotify)g_object_unref, suggest_proxy); /* Pack the search page */ priv->search_page = mx_frame_new (); clutter_actor_set_name (priv->search_page, "search-page"); mx_bin_set_fill (MX_BIN (priv->search_page), FALSE, TRUE); mx_bin_set_alignment (MX_BIN (priv->search_page), MX_ALIGN_START, MX_ALIGN_START); hbox = mex_resizing_hbox_new (); mex_resizing_hbox_set_resizing_enabled (MEX_RESIZING_HBOX (hbox), FALSE); box = mx_box_layout_new (); clutter_container_add_actor (CLUTTER_CONTAINER (priv->search_page), hbox); clutter_container_add_actor (CLUTTER_CONTAINER (hbox), box); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL); clutter_container_add (CLUTTER_CONTAINER (box), header, priv->suggest_column, NULL); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (box), priv->suggest_column, TRUE); clutter_container_child_set (CLUTTER_CONTAINER (box), header, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); clutter_container_child_set (CLUTTER_CONTAINER (box), priv->suggest_column, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); clutter_actor_set_width (box, 426.0); /* Update the history list */ mex_search_plugin_update_history (self, NULL); /* Start the history list and suggestions proxy */ mex_proxy_start (suggest_proxy); }
static ClutterActor * create_track_info (RBShell *shell) { RBShellPlayer *player; RhythmDB *db; ClutterActor *box; ClutterActor *box2; ClutterActor *widget; ClutterActor *frame; RhythmDBEntry *entry; GValue *value; guint elapsed; g_object_get (shell, "shell-player", &player, "db", &db, NULL); entry = rb_shell_player_get_playing_entry (player); box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_HORIZONTAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 16); mx_stylable_set_style_class (MX_STYLABLE (box), "TrackInfoBox"); mx_stylable_set_style (MX_STYLABLE (box), style); /* XXX rtl? */ /* image container */ frame = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (frame), "TrackInfoImage"); mx_stylable_set_style (MX_STYLABLE (frame), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), frame, 0); clutter_container_child_set (CLUTTER_CONTAINER (box), frame, "expand", FALSE, NULL); set_blank_image (MX_FRAME (frame)); clutter_actor_show_all (CLUTTER_ACTOR (frame)); g_signal_connect_object (player, "playing-song-changed", G_CALLBACK (cover_art_entry_changed_cb), frame, 0); request_cover_art (MX_FRAME (frame), entry); box2 = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box2), MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (box2), 16); mx_stylable_set_style (MX_STYLABLE (box2), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box), box2, 1); clutter_container_child_set (CLUTTER_CONTAINER (box), box2, "expand", TRUE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); /* track info */ widget = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (widget), "TrackInfoText"); mx_stylable_set_style (MX_STYLABLE (widget), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box2), widget, 1); clutter_container_child_set (CLUTTER_CONTAINER (box2), widget, "expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); g_signal_connect_object (player, "playing-song-changed", G_CALLBACK (playing_song_changed_cb), widget, 0); g_signal_connect_object (db, "entry-changed", G_CALLBACK (entry_changed_cb), widget, 0); g_signal_connect_object (db, "entry-extra-metadata-notify::" RHYTHMDB_PROP_STREAM_SONG_TITLE, G_CALLBACK (streaming_title_notify_cb), widget, 0); value = rhythmdb_entry_request_extra_metadata (db, entry, RHYTHMDB_PROP_STREAM_SONG_TITLE); if (value != NULL) { update_track_info (MX_LABEL (widget), db, entry, g_value_get_string (value)); g_value_unset (value); g_free (value); } else { update_track_info (MX_LABEL (widget), db, entry, NULL); } /* elapsed/duration */ widget = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (widget), "TrackTimeText"); mx_stylable_set_style (MX_STYLABLE (widget), style); mx_box_layout_add_actor (MX_BOX_LAYOUT (box2), widget, 2); clutter_container_child_set (CLUTTER_CONTAINER (box2), widget, "expand", FALSE, "x-fill", TRUE, "y-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, NULL); g_signal_connect_object (player, "elapsed-changed", G_CALLBACK (elapsed_changed_cb), widget, 0); if (rb_shell_player_get_playing_time (player, &elapsed, NULL)) { update_elapsed (widget, player, elapsed); } rhythmdb_entry_unref (entry); g_object_unref (player); g_object_unref (db); return box; }
int main (int argc, char **argv) { const ClutterColor grey = { 0x40, 0x40, 0x40, 0xff }; ClutterActor *stage, *tile, *tile2, *image, *image2, *dialog, *tiles; MxApplication *app; ClutterConstraint *constraint; mex_init (&argc, &argv); app = mx_application_new (&argc, &argv, "mex-tile-controls-test", 0); mex_style_load_default (); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &grey); clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE); image = mx_image_new (); mx_image_set_from_file (MX_IMAGE (image), "/home/michael/dev/mex-info-bar/graphic-mapButtons.png", NULL); image2 = mx_image_new (); mx_image_set_from_file (MX_IMAGE (image2), "/home/michael/dev/mex-info-bar/graphic-network.png", NULL); tile = mex_tile_new (); mex_tile_set_label (tile, "Remote mapping"); mex_tile_set_important (tile, TRUE); ClutterActor *button; button = mx_button_new (); mx_bin_set_child (MX_BIN (tile), button); mx_bin_set_child (MX_BIN (button), image); tile2 = mex_tile_new (); mex_tile_set_label (tile2, "Network"); mex_tile_set_important (tile2, TRUE); ClutterActor *button2; button2 = mx_button_new (); mx_bin_set_child (MX_BIN (tile2), button2); mx_bin_set_child (MX_BIN (button2), image2); tiles = mx_box_layout_new (); mx_box_layout_set_spacing (tiles, 10); mx_box_layout_set_orientation (tiles, MX_ORIENTATION_HORIZONTAL); mx_box_layout_add_actor (tiles, tile, 0); mx_box_layout_add_actor (tiles, tile2, 1); g_print (clutter_actor_get_reactive (tile) ? "reactive" : "notreactive"); dialog = mx_dialog_new (); mx_dialog_set_transient_parent (dialog, stage); g_signal_connect (button2, "clicked", G_CALLBACK (focus_in_cb), NULL); g_signal_connect (button, "clicked", G_CALLBACK (focus_in_cb), NULL); clutter_container_add_actor (CLUTTER_CONTAINER (dialog), tiles); clutter_actor_show (dialog); clutter_actor_set_size (stage, 1024, 768); clutter_actor_show (stage); clutter_main (); return 0; }
static void mex_telepathy_channel_create_toolbar (MexTelepathyChannel *self) { MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv; gchar *static_image_path; ClutterActor *toolbar; MxAction *end_action; MxAction *camera_action; MxAction *mute_action; GError *error = NULL; // Create the user label priv->avatar_image = mx_image_new (); static_image_path = g_build_filename (mex_get_data_dir (), "style", "thumb-call-avatar-small.png", NULL); mx_image_set_from_file (MX_IMAGE (priv->avatar_image), static_image_path, &error); if (error) { g_warning ("Error loading texture %s", error->message); g_clear_error (&error); } if (static_image_path) g_free (static_image_path); priv->title_label = mx_label_new (); mx_label_set_y_align (MX_LABEL (priv->title_label), MX_ALIGN_MIDDLE); mx_label_set_x_align (MX_LABEL (priv->title_label), MX_ALIGN_MIDDLE); end_action = mx_action_new_full ("End", "Hang Up", G_CALLBACK (mex_telepathy_channel_on_hangup), self); priv->end_button = mex_action_button_new (end_action); mx_stylable_set_style_class (MX_STYLABLE (priv->end_button), "EndCall"); camera_action = mx_action_new_full("Camera", "Camera Off", G_CALLBACK (mex_telepathy_channel_toggle_camera), self); priv->camera_button = mex_action_button_new (camera_action); /* off by default */ mex_telepathy_channel_set_camera_state (self, FALSE); mute_action = mx_action_new_full("Mute", "Mic Off", G_CALLBACK (mex_telepathy_channel_toggle_mute), self); priv->mute_button = mex_action_button_new (mute_action); mx_stylable_set_style_class (MX_STYLABLE (priv->mute_button), "MediaMute"); toolbar = mx_box_layout_new (); clutter_actor_set_width (toolbar, 980); clutter_actor_set_height (toolbar, 48); mx_stylable_set_style_class (MX_STYLABLE (toolbar), "MexCallControlsTitle"); // Put the buttons in the toolbar mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar), priv->avatar_image, 0, "expand", FALSE, "x-align", MX_ALIGN_END, "x-fill", FALSE, NULL); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar), priv->title_label, 1, "expand", TRUE, NULL); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar), priv->camera_button, 2, "expand", TRUE, NULL); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar), priv->mute_button, 3, "expand", TRUE, NULL); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (toolbar), priv->end_button, 4, "expand", TRUE, NULL); priv->toolbar_area = mx_frame_new (); mx_bin_set_child (MX_BIN (priv->toolbar_area), toolbar); mx_stylable_set_style_class (MX_STYLABLE (priv->toolbar_area), "ToolbarArea"); }
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 ClutterActor * create_property_editor (GObject *object, GParamSpec *pspec) { ClutterActor *box, *label, *value; gint i; /* skip properties that are not writable */ if (!(pspec->flags & G_PARAM_WRITABLE)) return NULL; /* skip other properties */ for (i = 0; i < G_N_ELEMENTS (skip_properties); i++) { if (g_str_equal (pspec->name, skip_properties[i])) return NULL; } box = mx_box_layout_new (); label = mx_label_new_with_text (pspec->name); clutter_actor_set_width (label, 150); clutter_actor_add_child (box, label); if (pspec->value_type == G_TYPE_BOOLEAN) { value = mx_toggle_new (); g_object_bind_property (object, pspec->name, value, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); } else if (pspec->value_type == G_TYPE_STRING) { value = mx_entry_new (); g_object_bind_property (object, pspec->name, value, "text", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); } else if (pspec->value_type == G_TYPE_INT || pspec->value_type == G_TYPE_UINT || pspec->value_type == G_TYPE_FLOAT || pspec->value_type == G_TYPE_DOUBLE) { value = mx_entry_new (); g_object_bind_property_full (object, pspec->name, value, "text", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, num_to_string, string_to_num, NULL, NULL); } else if (g_type_is_a (pspec->value_type, G_TYPE_ENUM)) { GEnumValue *evalue; GEnumClass *eclass; gint init = 0; value = mx_combo_box_new (); clutter_actor_set_width (value, 100); eclass = g_type_class_ref (pspec->value_type); while ((evalue = g_enum_get_value (eclass, init))) { mx_combo_box_append_text (MX_COMBO_BOX (value), evalue->value_nick); init++; } g_type_class_unref (eclass); g_object_bind_property (object, pspec->name, value, "index", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); } else value = NULL; if (value) { clutter_actor_add_child (box, value); return box; } else return NULL; }
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 }
static void add_pictures (ClutterActor *box) { GList *files = get_pictures (); while (files) { gint w, h, i; ClutterActor *drawer, *drawer2, *tile, *texture, *menu, *description; gchar *file = files->data; /* Create texture */ texture = clutter_texture_new_from_file (file, NULL); clutter_texture_get_base_size (CLUTTER_TEXTURE (texture), &w, &h); clutter_actor_set_size (texture, 300, 300.0/w * h); /* Create menu */ menu = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (menu), MX_ORIENTATION_VERTICAL); for (i = 0; i < 4; i++) { ClutterActor *button, *layout, *icon, *label; button = mx_button_new (); layout = mx_box_layout_new (); icon = mx_icon_new (); label = mx_label_new (); mx_box_layout_set_spacing (MX_BOX_LAYOUT (layout), 8); mx_icon_set_icon_size (MX_ICON (icon), 16); clutter_actor_set_size (icon, 16, 16); clutter_container_add (CLUTTER_CONTAINER (layout), icon, label, NULL); mx_bin_set_child (MX_BIN (button), layout); mx_bin_set_alignment (MX_BIN (button), MX_ALIGN_START, MX_ALIGN_MIDDLE); clutter_container_add_actor (CLUTTER_CONTAINER (menu), button); mx_box_layout_child_set_x_fill (MX_BOX_LAYOUT (menu), button, TRUE); switch (i) { case 0: mx_icon_set_icon_name (MX_ICON (icon), "dialog-information"); mx_label_set_text (MX_LABEL (label), "This"); break; case 1: mx_icon_set_icon_name (MX_ICON (icon), "dialog-question"); mx_label_set_text (MX_LABEL (label), "is"); break; case 2: mx_icon_set_icon_name (MX_ICON (icon), "dialog-warning"); mx_label_set_text (MX_LABEL (label), "a"); break; case 3: mx_icon_set_icon_name (MX_ICON (icon), "dialog-error"); mx_label_set_text (MX_LABEL (label), "menu"); break; } } /* Create description */ description = mx_label_new_with_text ("Here you could put a very " "long description of whatever " "is above it. Or you could put " "another focusable widget here " "and it'd be navigable, like " "the menu on the right. Whoo!"); clutter_text_set_line_wrap ((ClutterText *)mx_label_get_clutter_text ( MX_LABEL (description)), TRUE); drawer = mex_expander_box_new (); mex_expander_box_set_important_on_focus (MEX_EXPANDER_BOX (drawer), TRUE); drawer2 = mex_expander_box_new (); mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (drawer2), MEX_EXPANDER_BOX_RIGHT); mex_expander_box_set_important (MEX_EXPANDER_BOX (drawer2), TRUE); tile = mex_tile_new_with_label (file); mex_tile_set_important (MEX_TILE (tile), TRUE); mx_bin_set_child (MX_BIN (tile), texture); clutter_container_add (CLUTTER_CONTAINER (drawer2), tile, menu, NULL); clutter_container_add (CLUTTER_CONTAINER (drawer), drawer2, description, NULL); g_signal_connect (drawer, "notify::open", G_CALLBACK (sync_drawer2_cb), drawer2); clutter_container_add_actor (CLUTTER_CONTAINER (box), drawer); clutter_actor_set_reactive (texture, TRUE); g_signal_connect (texture, "enter-event", G_CALLBACK (texture_enter_cb), drawer); g_signal_connect (texture, "leave-event", G_CALLBACK (texture_leave_cb), drawer); g_signal_connect (texture, "button-press-event", G_CALLBACK (texture_clicked_cb), drawer); g_free (file); files = g_list_delete_link (files, files); } }
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 dawati_bt_request_init (DawatiBtRequest *request) { ClutterActor *title_box, *close_btn, *btn_box; DawatiBtRequestPrivate *priv = GET_PRIVATE (request); mx_box_layout_set_orientation (MX_BOX_LAYOUT (request), MX_ORIENTATION_VERTICAL); mx_stylable_set_style_class (MX_STYLABLE (request), "BtRequest"); priv->request = DAWATI_BT_REQUEST_TYPE_PIN; /* FIXME: this should maybe not be instance-specific */ priv->uuid_strings = _new_uiid_strings (); title_box = mx_box_layout_new (); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (request), title_box, -1, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); priv->title = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->title), "BtTitle"); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (title_box), priv->title, -1, "expand", TRUE, "x-fill", TRUE, "x-align", MX_ALIGN_START, NULL); close_btn = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (close_btn), "BtCloseButton"); mx_bin_set_child (MX_BIN (close_btn), mx_icon_new ()); mx_box_layout_add_actor (MX_BOX_LAYOUT (title_box), close_btn, -1); g_signal_connect (close_btn, "clicked", G_CALLBACK (_close_clicked_cb), request); priv->request_label = mx_label_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->request_label), "BtLabel"); mx_label_set_line_wrap (MX_LABEL (priv->request_label), TRUE); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (request), priv->request_label, -1, "expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_START, NULL); btn_box = mx_box_layout_new (); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (request), btn_box, -1, "expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_END, NULL); priv->request_entry = mx_entry_new (); mx_box_layout_add_actor (MX_BOX_LAYOUT (btn_box), priv->request_entry, -1); priv->request_always_btn = mx_button_new (); /* TRANSLATORS: request button label */ mx_button_set_label (MX_BUTTON (priv->request_always_btn), _("Always grant")); mx_box_layout_add_actor (MX_BOX_LAYOUT (btn_box), priv->request_always_btn, -1); g_signal_connect (priv->request_always_btn, "clicked", G_CALLBACK (_always_clicked_cb), request); priv->request_yes_btn = mx_button_new (); mx_box_layout_add_actor (MX_BOX_LAYOUT (btn_box), priv->request_yes_btn, -1); g_signal_connect (priv->request_yes_btn, "clicked", G_CALLBACK (_yes_clicked_cb), request); }
static ClutterActor * mex_menu_item_new (MexMenu *self, MxAction *action, MexMenuActionType type) { ClutterActor *button, *layout, *icon, *vbox, *label, *arrow = NULL; button = mx_button_new (); mx_button_set_is_toggle (MX_BUTTON (button), TRUE); mx_stylable_set_style_class (MX_STYLABLE (button), "Item"); layout = mx_box_layout_new (); mx_bin_set_child (MX_BIN (button), layout); mx_bin_set_fill (MX_BIN (button), TRUE, FALSE); if (type == MEX_MENU_LEFT) { arrow = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (arrow), "Left"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), arrow); } vbox = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL); label = mx_label_new (); mx_label_set_fade_out (MX_LABEL (label), TRUE); mx_stylable_set_style_class (MX_STYLABLE (label), "Action"); g_object_bind_property (action, "display-name", label, "text", G_BINDING_SYNC_CREATE); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label); label = mx_label_new (); mx_label_set_fade_out (MX_LABEL (label), TRUE); mx_stylable_set_style_class (MX_STYLABLE (label), "Detail"); clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label); clutter_actor_hide (label); g_object_set_data (G_OBJECT (button), "detail-label", label); clutter_container_add_actor (CLUTTER_CONTAINER (layout), vbox); clutter_container_child_set (CLUTTER_CONTAINER (layout), vbox, "expand", TRUE, "x-fill", FALSE, "x-align", MX_ALIGN_START, "y-fill", FALSE, NULL); icon = mx_icon_new (); g_object_bind_property (action, "icon", icon, "icon-name", G_BINDING_SYNC_CREATE); clutter_container_add_actor (CLUTTER_CONTAINER (layout), icon); if (type == MEX_MENU_RIGHT) { arrow = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (arrow), "Right"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), arrow); } else if (type == MEX_MENU_TOGGLE) { ClutterActor *toggle = mx_icon_new (); mx_stylable_set_style_class (MX_STYLABLE (toggle), "Toggle"); clutter_container_add_actor (CLUTTER_CONTAINER (layout), toggle); g_object_set_data (G_OBJECT (button), "toggle-icon", toggle); } if (arrow) clutter_container_child_set (CLUTTER_CONTAINER (layout), arrow, "expand", FALSE, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, NULL); g_signal_connect (button, "clicked", G_CALLBACK (mex_menu_item_clicked_cb), action); g_object_weak_ref (G_OBJECT (button), (GWeakNotify)mex_menu_item_destroyed_cb, self); /* Set the item qdata on the button to mark that we created it */ g_object_set_qdata (G_OBJECT (button), mex_menu_item_quark, GINT_TO_POINTER (TRUE)); return button; }