static gboolean _create_power_dialog (MexInfoBar *self) { MexInfoBarPrivate *priv = self->priv; ClutterActor *dialog, *dialog_label; MxAction *cancel_action, *shutdown_action; dialog = mx_dialog_new (); mx_stylable_set_style_class (MX_STYLABLE (dialog), "MexInfoBarDialog"); dialog_label = mx_label_new_with_text (_("Close Media Explorer?")); mx_stylable_set_style_class (MX_STYLABLE (dialog_label), "DialogHeader"); mx_bin_set_child (MX_BIN (dialog), dialog_label); shutdown_action = mx_action_new_full ("yes", _("Yes"), G_CALLBACK (_close_request_cb), self); cancel_action = mx_action_new_full ("no", _("No"), G_CALLBACK (_close_dialog_cb), self); mx_dialog_add_action (MX_DIALOG (dialog), shutdown_action); mx_dialog_add_action (MX_DIALOG (dialog), cancel_action); priv->power_dialog = g_object_ref (dialog); clutter_actor_show (dialog); return TRUE; }
static void mex_queue_plugin_init (MexQueuePlugin *self) { MexQueuePluginPrivate *priv = GET_PRIVATE (self); MexActionInfo *action_info; MexModelInfo *model_info; MexModel *queue_model; queue_model = mex_queue_model_dup_singleton (); g_object_set (queue_model, "icon-name", "icon-panelheader-queue", NULL); /* * Attention! Fake action .. this then causes MexContentBox to put an * MexQueueButton in its place */ action_info = g_new0 (MexActionInfo, 1); action_info->action = mx_action_new_full ("enqueue", _("Add to queue"), NULL, self); action_info->mime_types = g_strdupv ((gchar **)all_data_mimetypes); action_info->priority = 100; priv->actions = g_list_append (priv->actions, action_info); model_info = mex_model_info_new (queue_model, "queue", 0, NULL); priv->models = g_list_append (priv->models, model_info); }
static MxAction * _action_new_from_desktop_file (const gchar *desktop_file_id) { GDesktopAppInfo *dai; dai = g_desktop_app_info_new (desktop_file_id); if (dai) { MxAction *action; GAppInfo *ai; GIcon *icon; ai = G_APP_INFO (dai); action = mx_action_new_full (g_app_info_get_name (ai), g_app_info_get_display_name (ai), G_CALLBACK (_app_launcher_cb), (gpointer)g_app_info_get_commandline (ai)); icon = g_app_info_get_icon (ai); if (icon) { gchar *icon_name; icon_name = g_icon_to_string (icon); mx_action_set_icon (action, icon_name); g_free (icon_name); } return action; } return NULL; }
static void mex_grid_view_set_model (MexGridView *view, MexModel *model) { MexGridViewPrivate *priv = MEX_GRID_VIEW (view)->priv; gchar *category = NULL; g_return_if_fail (model != NULL); if (model == priv->model) return; if (priv->model) g_object_unref (priv->model); priv->model = g_object_ref (model); g_object_get (model, "category", &category, NULL); /* Add the clear queue option */ if (g_strcmp0 (category, "queue") == 0) { MxAction *clear_queue; clear_queue = mx_action_new_full ("clear-queue", _("Clear queue"), G_CALLBACK (mex_clear_queue_cb), model); mex_menu_add_action (MEX_MENU (priv->menu_layout), clear_queue, MEX_MENU_NONE); } /* set the model on the grid */ mex_grid_set_model (MEX_GRID (priv->grid), model); /* set grid title */ g_object_bind_property (model, "title", priv->grid_title, "text", G_BINDING_SYNC_CREATE); /* set column title and icon */ if (category) { const MexModelCategoryInfo *cat_info; cat_info = mex_model_manager_get_category_info (mex_model_manager_get_default (), category); mx_label_set_text (MX_LABEL (priv->menu_title), cat_info->display_name); } g_free (category); }
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"); }
static gboolean _create_settings_dialog (MexInfoBar *self) { MexInfoBarPrivate *priv = self->priv; ClutterActor *dialog, *network_graphic; ClutterActor *network_tile, *dialog_layout, *dialog_label; ClutterActor *network_button; MxAction *close_dialog, *network_settings; dialog = mx_dialog_new (); mx_stylable_set_style_class (MX_STYLABLE (dialog), "MexInfoBarDialog"); dialog_label = mx_label_new_with_text (_("Settings")); mx_stylable_set_style_class (MX_STYLABLE (dialog_label), "DialogHeader"); /* Create actions for settings dialog */ network_settings = _action_new_from_desktop_file ("mex-networks.desktop"); close_dialog = mx_action_new_full ("close", _("Close"), G_CALLBACK (_close_dialog_cb), self); dialog_layout = mx_table_new (); mx_table_set_column_spacing (MX_TABLE (dialog_layout), 10); mx_table_set_row_spacing (MX_TABLE (dialog_layout), 30); mx_table_insert_actor (MX_TABLE (dialog_layout), CLUTTER_ACTOR (dialog_label), 0, 0); if (network_settings) { gchar *tmp; network_graphic = mx_image_new (); mx_stylable_set_style_class (MX_STYLABLE (network_graphic), "NetworkGraphic"); tmp = g_build_filename (mex_get_data_dir (), "style", "graphic-network.png", NULL); mx_image_set_from_file (MX_IMAGE (network_graphic), tmp, NULL); g_free (tmp); network_tile = mex_tile_new (); mex_tile_set_label (MEX_TILE (network_tile), _("Network")); mex_tile_set_important (MEX_TILE (network_tile), TRUE); network_button = mx_button_new (); mx_button_set_action (MX_BUTTON (network_button), network_settings); mx_bin_set_child (MX_BIN (network_tile), network_button); mx_bin_set_child (MX_BIN (network_button), network_graphic); mx_table_insert_actor (MX_TABLE (dialog_layout), CLUTTER_ACTOR (network_tile), 1, 1); } if (!network_settings) { ClutterActor *no_settings; no_settings = mx_label_new_with_text (_("No settings helpers installed")); clutter_actor_destroy (priv->settings_button); mx_table_insert_actor (MX_TABLE (dialog_layout), CLUTTER_ACTOR (no_settings), 1, 0); } mx_bin_set_child (MX_BIN (dialog), dialog_layout); mx_dialog_add_action (MX_DIALOG (dialog), close_dialog); priv->settings_dialog = g_object_ref (dialog); return TRUE; }
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 void mnb_home_new_widget_dialog_init (MnbHomeNewWidgetDialog *self) { ClutterActor *table, *itemview; MnbHomeNewWidgetDialogItemFactory *factory; MnbHomePluginsEngine *engine; const GList *l; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MNB_TYPE_HOME_NEW_WIDGET_DIALOG, MnbHomeNewWidgetDialogPrivate); /* set up model and view */ self->priv->items = clutter_list_model_new (ITEMS_N_COLUMNS, G_TYPE_STRING, "Module", /* ITEMS_MODULE */ G_TYPE_STRING, "Name", /* ITEMS_NAME */ G_TYPE_STRING, "Icon" /* ITEMS_ICON */); table = mx_table_new (); mx_bin_set_child (MX_BIN (self), table); factory = g_object_new (MNB_TYPE_HOME_NEW_WIDGET_DIALOG_ITEM_FACTORY, NULL); factory->dialog = self; itemview = mx_item_view_new (); mx_table_add_actor (MX_TABLE (table), itemview, 0, 1); mx_item_view_set_model (MX_ITEM_VIEW (itemview), self->priv->items); mx_item_view_set_factory (MX_ITEM_VIEW (itemview), MX_ITEM_FACTORY (factory)); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "module", ITEMS_MODULE); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "label", ITEMS_NAME); mx_item_view_add_attribute (MX_ITEM_VIEW (itemview), "icon", ITEMS_ICON); clutter_actor_show_all (table); /* find plugins */ /* FIXME: should we monitor for new plugins on the fly? */ engine = mnb_home_plugins_engine_dup (); for (l = peas_engine_get_plugin_list (PEAS_ENGINE (engine)); l != NULL; l = g_list_next (l)) { PeasPluginInfo *info = l->data; char *icon; if (!peas_plugin_info_is_available (info, NULL)) continue; icon = g_build_filename ( peas_plugin_info_get_module_dir (info), peas_plugin_info_get_icon_name (info), NULL); clutter_model_append (self->priv->items, ITEMS_MODULE, peas_plugin_info_get_module_name (info), ITEMS_NAME, peas_plugin_info_get_name (info), ITEMS_ICON, icon, -1); g_free (icon); } /* add actions */ mx_dialog_add_action (MX_DIALOG (self), mx_action_new_full ("cancel", _("Cancel"), G_CALLBACK (home_new_widget_dialog_cancel), self)); g_object_unref (engine); g_object_unref (factory); }