static void mex_media_controls_init (MexMediaControls *self) { ClutterActor *actor; ClutterScript *script; GError *err = NULL; MxAdjustment *adjustment; ClutterActor *related_box; gchar *tmp; MexMediaControlsPrivate *priv = self->priv = MEDIA_CONTROLS_PRIVATE (self); priv->script = script = clutter_script_new (); tmp = g_build_filename (mex_get_data_dir (), "json", "media-controls.json", NULL); clutter_script_load_from_file (script, tmp, &err); g_free (tmp); if (err) g_error ("Could not load media controls interface: %s", err->message); priv->vbox = (ClutterActor*) clutter_script_get_object (script, "media-controls"); clutter_actor_set_parent (priv->vbox, CLUTTER_ACTOR (self)); /* add shadow to media controls box */ actor = (ClutterActor *) clutter_script_get_object (script, "media-controls-box"); clutter_actor_add_effect (actor, CLUTTER_EFFECT (mex_shadow_new ())); /* vertical fade effect */ priv->vertical_effect = mx_fade_effect_new (); clutter_actor_add_effect (priv->vbox, priv->vertical_effect); mx_scrollable_get_adjustments (MX_SCROLLABLE (mx_bin_get_child (MX_BIN (priv->vbox))), NULL, &adjustment); g_signal_connect (adjustment, "changed", G_CALLBACK (notify_vertical_changed_cb), self); g_signal_connect (adjustment, "notify::value", G_CALLBACK (notify_vertical_value_cb), self); /* horizontal fade effect */ priv->horizontal_effect = mx_fade_effect_new (); related_box = (ClutterActor *) clutter_script_get_object (priv->script, "related-box"); clutter_actor_add_effect (related_box, priv->horizontal_effect); mx_scrollable_get_adjustments (MX_SCROLLABLE (related_box), &adjustment, NULL); g_signal_connect (adjustment, "changed", G_CALLBACK (notify_horizontal_changed_cb), self); g_signal_connect (adjustment, "notify::value", G_CALLBACK (notify_horizontal_value_cb), self); /* slider setup */ priv->slider = (ClutterActor*) clutter_script_get_object (script, "slider"); g_signal_connect (priv->slider, "notify::value", G_CALLBACK (slider_value_changed_cb), self); g_signal_connect (priv->slider, "captured-event", G_CALLBACK (slider_captured_event), self); priv->play_pause_action = (MxAction*) clutter_script_get_object (script, "play-pause-action"); priv->stop_action = (MxAction*) clutter_script_get_object (script, "stop-action"); priv->add_to_queue_action = (MxAction*) clutter_script_get_object (script, "add-to-queue-action"); priv->queue_button = (ClutterActor *) clutter_script_get_object (script, "add-to-queue-button"); g_signal_connect (priv->play_pause_action, "activated", G_CALLBACK (mex_media_controls_play_cb), self); g_signal_connect (priv->stop_action, "activated", G_CALLBACK (mex_media_controls_stop_cb), self); #if 0 g_signal_connect (priv->add_to_queue_action, "activated", G_CALLBACK (mex_media_controls_add_to_queue_cb), self); #endif /* proxy setup */ priv->proxy_model = MEX_VIEW_MODEL (mex_view_model_new (NULL)); /* FIXME: Set an arbitrary 200-item limit as we can't handle large * amounts of actors without massive slow-down. */ mex_view_model_set_limit (priv->proxy_model, 200); priv->proxy = mex_content_proxy_new (MEX_MODEL (priv->proxy_model), CLUTTER_CONTAINER (related_box), MEX_TYPE_CONTENT_TILE); g_signal_connect (priv->proxy, "object-created", G_CALLBACK (tile_created_cb), self); priv->is_disabled = TRUE; }
static void mex_search_plugin_init (MexSearchPlugin *self) { MexModel *view_model; MexProxy *suggest_proxy; ClutterActor *icon, *header, *text, *frame, *box, *hbox; MexSearchPluginPrivate *priv = self->priv = SEARCH_PLUGIN_PRIVATE (self); MexModelCategoryInfo search = { "search", _("Search"), "icon-panelheader-search", 0, "" }; /* create a category for search results that is not shown on the home screen */ MexModelCategoryInfo search_results = { "search-results", _("Search"), "icon-panelheader-search", -1, "" }; MexModelManager *manager = mex_model_manager_get_default (); manager = mex_model_manager_get_default (); mex_model_manager_add_category (manager, &search); mex_model_manager_add_category (manager, &search_results); /* Create the history model and models list */ priv->history_model = mex_feed_new (_("Search"), _("Search")); g_object_set (G_OBJECT (priv->history_model), "category", "search", NULL); priv->models = g_list_append (NULL, priv->history_model); /* 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_insert_actor (MX_TABLE (frame), priv->search_entry, 0, 0); mx_table_insert_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); view_model = mex_view_model_new (MEX_MODEL (priv->suggest_model)); suggest_proxy = mex_generic_proxy_new (view_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 (); mx_bin_set_child (MX_BIN (priv->search_page), hbox); clutter_actor_add_child (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); }