static void mex_grid_view_timeline_complete_cb (ClutterTimeline *timeline, MexGridView *view) { MexGridViewPrivate *priv = MEX_GRID_VIEW (view)->priv; if (priv->state == STATE_CLOSING_STAGE1) { GList *l, *actions; /* move to stage 2 of the close animation */ clutter_timeline_rewind (timeline); clutter_timeline_start (timeline); priv->state = STATE_CLOSING_STAGE2; /* remove the actions from the menu */ actions = mex_menu_get_actions (MEX_MENU (priv->menu_layout), 0); for (l = actions; l; l = g_list_next (l)) mex_menu_remove_action (MEX_MENU (priv->menu_layout), mx_action_get_name (l->data)); g_list_free (actions); return; } else if (priv->state == STATE_CLOSING_STAGE2) { priv->state = STATE_CLOSED; CLUTTER_ACTOR_CLASS (mex_grid_view_parent_class)->hide (CLUTTER_ACTOR (view)); } else if (priv->state == STATE_OPENING) { priv->state = STATE_OPEN; clutter_actor_show (priv->grid); clutter_actor_animate (priv->grid, CLUTTER_LINEAR, 250, "opacity", 255, NULL); } if (priv->callback) { g_object_ref (G_OBJECT (view)); priv->callback (CLUTTER_ACTOR (view), priv->userdata); priv->callback = NULL; priv->userdata = NULL; g_object_unref (G_OBJECT (view)); } }
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_menu_map (ClutterActor *actor) { MxFocusManager *manager; MexMenu *self = MEX_MENU (actor); CLUTTER_ACTOR_CLASS (mex_menu_parent_class)->map (actor); manager = mx_focus_manager_get_for_stage ((ClutterStage *) clutter_actor_get_stage (actor)); if (manager) { g_signal_connect (manager, "notify::focused", G_CALLBACK (mex_menu_notify_focused_cb), self); mex_menu_notify_focused_cb (manager, NULL, self); } }
static void mex_menu_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { MexMenu *self = MEX_MENU (object); switch (property_id) { case PROP_MIN_WIDTH: mex_menu_set_min_width (self, g_value_get_float (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void mex_menu_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { MexMenuPrivate *priv = MEX_MENU (object)->priv; switch (property_id) { case PROP_DEPTH: g_value_set_int (value, priv->depth); break; case PROP_MIN_WIDTH: g_value_set_float (value, priv->min_width); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void mex_menu_finalize (GObject *object) { MexMenuPrivate *priv = MEX_MENU (object)->priv; if (priv->action_to_item) { GHashTableIter iter; gpointer key, value; g_hash_table_iter_init (&iter, priv->action_to_item); while (g_hash_table_iter_next (&iter, &key, &value)) { g_object_weak_unref (G_OBJECT (value), (GWeakNotify)mex_menu_item_destroyed_cb, object); } g_hash_table_unref (priv->action_to_item); priv->action_to_item = NULL; } G_OBJECT_CLASS (mex_menu_parent_class)->finalize (object); }
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); }