static void add_location_clicked_cb (ClutterActor *button, MnpWorldClock *world_clock) { MnpWorldClockPrivate *priv = GET_PRIVATE (world_clock); mx_list_view_set_model (MX_LIST_VIEW (priv->zones_list), NULL); priv->search_text = NULL; g_signal_emit_by_name (priv->zones_model, "filter-changed"); add_location_tile (world_clock, mx_entry_get_text (priv->search_location), FALSE); mx_list_view_set_model (MX_LIST_VIEW (priv->zones_list), priv->zones_model); }
static void mx_list_view_dispose (GObject *object) { MxListViewPrivate *priv = MX_LIST_VIEW (object)->priv; /* This will cause the unref of the model and also disconnect the signals */ mx_list_view_set_model (MX_LIST_VIEW (object), NULL); if (priv->factory) { g_object_unref (priv->factory); priv->factory = NULL; } G_OBJECT_CLASS (mx_list_view_parent_class)->dispose (object); }
static void mx_list_view_finalize (GObject *object) { MxListViewPrivate *priv = MX_LIST_VIEW (object)->priv; if (priv->attributes) { g_slist_foreach (priv->attributes, (GFunc) free_attribute, NULL); g_slist_free (priv->attributes); priv->attributes = NULL; } G_OBJECT_CLASS (mx_list_view_parent_class)->finalize (object); }
static void mx_list_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { MxListViewPrivate *priv = MX_LIST_VIEW (object)->priv; switch (property_id) { case PROP_MODEL: g_value_set_object (value, priv->model); break; case PROP_ITEM_TYPE: g_value_set_gtype (value, priv->item_type); break; case PROP_FACTORY: g_value_set_object (value, priv->factory); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
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 construct_completion (MnpWorldClock *world_clock) { const ClutterColor transparent = { 0x00, 0x00, 0x00, 0x00 }; ClutterActor *frame, *scroll, *view, *stage; MnpWorldClockPrivate *priv = GET_PRIVATE (world_clock); ClutterModel *model; MnpButtonItem *button_item; stage = priv->stage; /* Create an event-box to capture input when the completion list * displays. */ priv->event_box = clutter_rectangle_new_with_color (&transparent); clutter_actor_set_size (priv->event_box, clutter_actor_get_width (stage), clutter_actor_get_height (stage)); clutter_container_add_actor (CLUTTER_CONTAINER (stage), priv->event_box); clutter_actor_set_reactive (priv->event_box, TRUE); clutter_actor_hide (priv->event_box); g_signal_connect (priv->event_box, "button-press-event", G_CALLBACK (event_box_clicked_cb), world_clock); if (!priv->zones_model) { model = mnp_get_world_timezones (); priv->zones_model = model; } else model = priv->zones_model; clutter_model_set_filter (model, filter_zone, world_clock, NULL); priv->search_text = "asd"; frame = mx_frame_new (); clutter_actor_set_name (frame, "CompletionFrame"); mx_bin_set_fill (MX_BIN (frame), TRUE, TRUE); scroll = mx_scroll_view_new (); clutter_actor_set_name (scroll, "CompletionScrollView"); g_object_set (G_OBJECT (scroll), "clip-to-allocation", TRUE, NULL); clutter_actor_set_size (scroll, -1, 300); mx_bin_set_child (MX_BIN (frame), scroll); clutter_container_add_actor ((ClutterContainer *)stage, frame); clutter_actor_raise_top((ClutterActor *) frame); clutter_actor_set_position (frame, 14, 167); clutter_actor_hide (frame); priv->completion = frame; g_signal_connect (priv->completion, "show", G_CALLBACK (completion_show_cb), world_clock); g_signal_connect (priv->completion, "hide", G_CALLBACK (completion_hide_cb), world_clock); view = mx_list_view_new (); clutter_actor_set_name (view, "CompletionListView"); priv->zones_list = (MxListView *)view; clutter_container_add_actor (CLUTTER_CONTAINER (scroll), view); mx_list_view_set_model (MX_LIST_VIEW (view), model); button_item = mnp_button_item_new ((gpointer)world_clock, mnp_completion_done); mx_list_view_set_factory (MX_LIST_VIEW (view), (MxItemFactory *)button_item); mx_list_view_add_attribute (MX_LIST_VIEW (view), "label", 0); }