G_MODULE_EXPORT gint test_text_main (gint argc, gchar **argv) { ClutterActor *stage; ClutterActor *text; ClutterColor text_color = { 0x33, 0xff, 0x33, 0xff }; ClutterColor cursor_color = { 0xff, 0x33, 0x33, 0xff }; ClutterColor background_color = { 0x00, 0x00, 0x00, 0xff }; clutter_init (&argc, &argv); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color); text = clutter_text_new_full (FONT, "·", &text_color); clutter_container_add (CLUTTER_CONTAINER (stage), text, NULL); clutter_actor_set_position (text, 40, 30); clutter_actor_set_width (text, 1024); clutter_text_set_line_wrap (CLUTTER_TEXT (text), TRUE); clutter_actor_set_reactive (text, TRUE); clutter_stage_set_key_focus (CLUTTER_STAGE (stage), text); clutter_text_set_editable (CLUTTER_TEXT (text), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (text), TRUE); clutter_text_set_cursor_color (CLUTTER_TEXT (text), &cursor_color); if (argv[1]) { GError *error = NULL; gchar *utf8; g_file_get_contents (argv[1], &utf8, NULL, &error); if (error) { utf8 = g_strconcat ("Unable to open '", argv[1], "':\n", error->message, NULL); g_error_free (error); } clutter_text_set_text (CLUTTER_TEXT (text), utf8); } else clutter_text_set_text (CLUTTER_TEXT (text), runes); clutter_actor_set_size (stage, 1024, 768); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
/** * mx_combo_box_set_index: * @box: A #MxComboBox * @index: the index of the list item to set * * Set the current combo box text from the item at @index in the list. * */ void mx_combo_box_set_index (MxComboBox *box, gint index) { MxComboBoxPrivate *priv; GSList *item; MxAction *action; const gchar *icon_name; g_return_if_fail (MX_IS_COMBO_BOX (box)); priv = box->priv; item = g_slist_nth (box->priv->actions, index); if (!item) { box->priv->index = -1; clutter_text_set_text ((ClutterText*) box->priv->label, NULL); return; } box->priv->index = index; action = (MxAction *)item->data; clutter_text_set_text ((ClutterText*) box->priv->label, mx_action_get_display_name (action)); if (priv->icon) { clutter_actor_remove_child (CLUTTER_ACTOR (box), priv->icon); priv->icon = NULL; } icon_name = mx_action_get_icon (item->data); if (icon_name) { MxIconTheme *icon_theme; icon_theme = mx_icon_theme_get_default (); if (mx_icon_theme_has_icon (icon_theme, icon_name)) { priv->icon = mx_icon_new (); mx_icon_set_icon_name (MX_ICON (priv->icon), icon_name); clutter_actor_add_child (CLUTTER_ACTOR (box), priv->icon); } } g_object_notify (G_OBJECT (box), "index"); g_object_notify (G_OBJECT (box), "active-text"); g_object_notify (G_OBJECT (box), "active-icon-name"); }
static gboolean on_event (ClutterStage *stage, ClutterEvent *event, gpointer user_data) { switch (event->type) { case CLUTTER_BUTTON_PRESS: { ClutterActor *actor; gfloat xu2, yu2; gfloat x, y; clutter_event_get_coords (event, &x, &y); actor = clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_ALL, x, y); if (clutter_actor_transform_stage_point (actor, x, y, &xu2, &yu2)) { gchar *txt; if (actor == test_rectangle) txt = g_strdup_printf ("Click on rectangle\n" "Screen coords: [%d, %d]\n" "Local coords : [%d, %d]", (int) x, (int) y, (int) xu2, (int) yu2); else txt = g_strdup_printf ("Click on stage\n" "Screen coords: [%d, %d]\n" "Local coords : [%d, %d]", (int) x, (int) y, (int) xu2, (int) yu2); clutter_text_set_text (CLUTTER_TEXT (label), txt); g_free (txt); } else clutter_text_set_text (CLUTTER_TEXT (label), "Unprojection failed."); } break; default: break; } return FALSE; }
static VALUE rbclt_text_initialize (int argc, VALUE *argv, VALUE self) { VALUE font_name, text, color; gchar *font_name_s = NULL, *text_s = NULL; ClutterColor *color_s = NULL; ClutterActor *actor; rb_scan_args (argc, argv, "03", &font_name, &text, &color); if (!NIL_P (font_name)) font_name_s = StringValuePtr (font_name); if (!NIL_P (text)) text_s = StringValuePtr (text); if (!NIL_P (color)) color_s = (ClutterColor *) RVAL2BOXED (color, CLUTTER_TYPE_COLOR); actor = clutter_text_new (); if (font_name_s) clutter_text_set_font_name (CLUTTER_TEXT (actor), font_name_s); if (text_s) clutter_text_set_text (CLUTTER_TEXT (actor), text_s); if (color_s) clutter_text_set_color (CLUTTER_TEXT (actor), color_s); rbclt_initialize_unowned (self, actor); return Qnil; }
/** * st_entry_set_text: * @entry: a #StEntry * @text: (allow-none): text to set the entry to * * Sets the text displayed on the entry */ void st_entry_set_text (StEntry *entry, const gchar *text) { StEntryPrivate *priv; g_return_if_fail (ST_IS_ENTRY (entry)); priv = entry->priv; /* set a hint if we are blanking the entry */ if (priv->hint && text && !strcmp ("", text) && !HAS_FOCUS (priv->entry)) { text = priv->hint; priv->hint_visible = TRUE; st_widget_add_style_pseudo_class (ST_WIDGET (entry), "indeterminate"); } else { st_widget_remove_style_pseudo_class (ST_WIDGET (entry), "indeterminate"); priv->hint_visible = FALSE; } clutter_text_set_text (CLUTTER_TEXT (priv->entry), text); g_object_notify (G_OBJECT (entry), "text"); }
/*I have to do it, because implement po in script load need lots of time, for me. */ static void gnome_app_script_preload (ClutterScript *script) { GList *l; ClutterActor *actor; const gchar *raw; const gchar *real; for (l = clutter_script_list_objects (script); l; l = l->next) { actor = CLUTTER_ACTOR (l->data); if (CLUTTER_IS_TEXT (actor)) { raw = clutter_text_get_text (CLUTTER_TEXT (actor)); /* * Bad, all because of script did not recognize the po file. * set_text will finalize the content of clutter_text first * if we set_text by get_text, * the pointer will be 'wide'... * so does gtk_label_set_label. * * It is the bug of clutter and gtk, * altough it may not worth to fix it .. */ if (raw && raw [0]) { real = _(raw); if (raw != real) clutter_text_set_text (CLUTTER_TEXT (actor), real); } } } }
static void clutter_text_focus_in_cb (ClutterText *text, ClutterActor *actor) { StEntry *entry = ST_ENTRY (actor); StEntryPrivate *priv = entry->priv; GdkKeymap *keymap; /* remove the hint if visible */ if (priv->hint && priv->hint_visible) { priv->hint_visible = FALSE; clutter_text_set_text (text, ""); } keymap = gdk_keymap_get_for_display (gdk_display_get_default ()); keymap_state_changed (keymap, entry); g_signal_connect (keymap, "state-changed", G_CALLBACK (keymap_state_changed), entry); st_widget_remove_style_pseudo_class (ST_WIDGET (actor), "indeterminate"); st_widget_add_style_pseudo_class (ST_WIDGET (actor), "focus"); clutter_text_set_cursor_visible (text, TRUE); }
static void draw_marker (ChamplainMarker *marker) { BixiMarkerPrivate *priv = BIXI_MARKER (marker)->priv; ClutterText *label; gfloat width = 0, height = 0; gint radius = 10 + priv->value / 3; g_free (priv->text); priv->text = g_strdup_printf ("%u", priv->value); if (priv->text_actor == NULL) { priv->text_actor = clutter_text_new_with_text ("Sans 11", priv->text); g_object_ref (priv->text_actor); } label = CLUTTER_TEXT (priv->text_actor); clutter_text_set_font_name (label, "Sans 11"); clutter_text_set_text (label, priv->text); clutter_actor_get_size (CLUTTER_ACTOR (label), &width, &height); clutter_actor_set_position (CLUTTER_ACTOR (label), radius - width / 2, radius - height / 2); clutter_text_set_color (CLUTTER_TEXT (priv->text_actor), &default_text_color); if (clutter_actor_get_parent (priv->text_actor) == NULL) clutter_container_add_actor (CLUTTER_CONTAINER (marker), priv->text_actor); draw_shadow (BIXI_MARKER (marker), radius); draw_background (BIXI_MARKER (marker), radius); clutter_actor_raise (priv->text_actor, priv->background); clutter_actor_set_anchor_point (CLUTTER_ACTOR (marker), radius, radius); }
static void update_name_text (ShellStatusMenu *status) { ShellStatusMenuPrivate *priv = status->priv; clutter_text_set_text (priv->name, gdm_user_get_real_name (GDM_USER (priv->user))); }
void file_selector_notify_unset (FileSelector *selector) { if (file_selector_is_set (selector) == TRUE) return; clutter_text_set_text (CLUTTER_TEXT (selector), "You need to choose a file to upload"); g_timeout_add_seconds (2, reset_notification, selector); }
void on_timeline_new_frame (ClutterTimeline *timeline, gint frame_msecs, App *app) { if (frame_msecs > clutter_timeline_get_duration (timeline)/2) clutter_text_set_text (CLUTTER_TEXT(app->label), ItemDetails[app->selected_index].title); }
/** * mx_expander_set_label: * @expander: A #MxExpander * @label: string to set as the expander label * * Sets the text displayed as the title of the expander */ void mx_expander_set_label (MxExpander *expander, const gchar *label) { g_return_if_fail (MX_IS_EXPANDER (expander)); g_return_if_fail (label != NULL); clutter_text_set_text (CLUTTER_TEXT (expander->priv->label), label); }
static gboolean reset_notification (gpointer sel) { FileSelector *selector; selector = (FileSelector*) sel; if (selector->priv->is_standby == TRUE) clutter_text_set_text (CLUTTER_TEXT (selector), STANDBY_TEXT); return FALSE; }
void mex_tile_set_secondary_label (MexTile *tile, const gchar *label) { g_return_if_fail (MEX_IS_TILE (tile)); clutter_text_set_text (CLUTTER_TEXT (tile->priv->secondary_label), (label) ? label : ""); g_object_notify (G_OBJECT (tile), "secondary-label"); }
static gboolean on_button_press (ClutterActor *actor, ClutterButtonEvent *event, ClutterActor *rectangle) { if (event->button == 3) { gchar *text; gfloat stage_width, stage_height; gfloat label_width, label_height; current_mode = (current_mode + 1 < n_easing_modes) ? current_mode + 1 : 0; text = g_strdup_printf ("Easing mode: %s (%d of %d)\n" "Right click to change the easing mode", easing_modes[current_mode].name, current_mode + 1, n_easing_modes); clutter_text_set_text (CLUTTER_TEXT (easing_mode_label), text); g_free (text); clutter_actor_get_size (main_stage, &stage_width, &stage_height); clutter_actor_get_size (easing_mode_label, &label_width, &label_height); clutter_actor_set_position (easing_mode_label, stage_width - label_width - 10, stage_height - label_height - 10); } else if (event->button == 1) { ClutterAnimation *animation; ClutterAnimationMode cur_mode; cur_mode = easing_modes[current_mode].mode; animation = clutter_actor_animate (rectangle, cur_mode, duration * 1000, "x", event->x, "y", event->y, NULL); if (recenter) g_signal_connect_after (animation, "completed", G_CALLBACK (on_animation_completed), rectangle); } return TRUE; }
G_MODULE_EXPORT int test_easing_main (int argc, char *argv[]) { ClutterActor *stage, *rect, *label; ClutterColor stage_color = { 0x88, 0x88, 0xdd, 0xff }; ClutterColor rect_color = { 0xee, 0x33, 0, 0xff }; gchar *text; gfloat stage_width, stage_height; gfloat label_width, label_height; clutter_init_with_args (&argc, &argv, NULL, test_easing_entries, NULL, NULL); stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); main_stage = stage; clutter_actor_get_size (stage, &stage_width, &stage_height); rect = make_bouncer (&rect_color, 50, 50); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); clutter_actor_set_position (rect, stage_width / 2, stage_height / 2); text = g_strdup_printf ("Easing mode: %s (%d of %d)\n" "Right click to change the easing mode", easing_modes[current_mode].name, current_mode + 1, n_easing_modes); label = clutter_text_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), label); clutter_text_set_font_name (CLUTTER_TEXT (label), "Sans 18px"); clutter_text_set_text (CLUTTER_TEXT (label), text); clutter_actor_get_size (label, &label_width, &label_height); clutter_actor_set_position (label, stage_width - label_width - 10, stage_height - label_height - 10); easing_mode_label = label; g_free (text); g_signal_connect (stage, "button-press-event", G_CALLBACK (on_button_press), rect); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
void mex_tile_set_label (MexTile *tile, const gchar *label) { MexTilePrivate *priv; g_return_if_fail (MEX_IS_TILE (tile)); priv = tile->priv; clutter_text_set_text (CLUTTER_TEXT (priv->label), (label) ? label : ""); g_object_notify (G_OBJECT (tile), "label"); }
gboolean interface_load_uri (UserInterface * ui, gchar * uri) { ui->fileuri = uri; ui->filename = g_path_get_basename (ui->fileuri); if (ui->stage != NULL) { clutter_stage_set_title (CLUTTER_STAGE (ui->stage), ui->filename); clutter_text_set_text (CLUTTER_TEXT (ui->control_title), ui->filename); } }
void mx_combo_box_set_active_text (MxComboBox *box, const gchar *text) { g_return_if_fail (MX_IS_COMBO_BOX (box)); box->priv->index = -1; clutter_text_set_text ((ClutterText*) box->priv->label, text); g_object_notify (G_OBJECT (box), "index"); g_object_notify (G_OBJECT (box), "active-text"); }
static void show_dialog (ClutterActor *actor, gpointer useless) { gchar *filename; FileSelector *selector; selector = FILE_SELECTOR (actor); if (gtk_dialog_run (GTK_DIALOG (selector->priv->dialog)) == GTK_RESPONSE_ACCEPT) { filename = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (selector->priv->dialog)); clutter_text_set_text (CLUTTER_TEXT (selector), filename); g_free (filename); selector->priv->is_standby = FALSE; } gtk_widget_hide (selector->priv->dialog); }
static gboolean progress_update_text (gpointer data) { UserInterface *ui = (UserInterface *) data; if (ui->controls_showing) { gchar *duration_str; gint64 pos; pos = query_position (ui->engine); duration_str = g_strdup_printf (" %s/%s", position_ns_to_str (pos), ui->duration_str); clutter_text_set_text (CLUTTER_TEXT (ui->control_pos), duration_str); } return TRUE; }
/** * mx_tooltip_set_text: * @tooltip: a #MxTooltip * @text: text to set the label to * * Sets the text displayed on the tooltip */ void mx_tooltip_set_text (MxTooltip *tooltip, const gchar *text) { MxTooltipPrivate *priv; g_return_if_fail (MX_IS_TOOLTIP (tooltip)); priv = tooltip->priv; clutter_text_set_text (CLUTTER_TEXT (priv->label), text); if (CLUTTER_ACTOR_IS_VISIBLE (tooltip)) mx_tooltip_update_position (tooltip); g_object_notify (G_OBJECT (tooltip), "text"); }
static void set_next_gravity (ClutterActor *actor) { ClutterGravity gravity = gravities[gindex]; GEnumClass *eclass; GEnumValue *evalue; clutter_actor_move_anchor_point_from_gravity (actor, gravities[gindex]); eclass = g_type_class_ref (CLUTTER_TYPE_GRAVITY); evalue = g_enum_get_value (eclass, gravity); clutter_text_set_text (CLUTTER_TEXT (label), evalue->value_nick); g_type_class_unref (eclass); if (++gindex >= G_N_ELEMENTS (gravities)) gindex = 0; }
/** * mx_label_set_text: * @label: a #MxLabel * @text: text to set the label to * * Sets the text displayed on the label */ void mx_label_set_text (MxLabel *label, const gchar *text) { MxLabelPrivate *priv; g_return_if_fail (MX_IS_LABEL (label)); g_return_if_fail (text != NULL); priv = label->priv; if (clutter_text_get_use_markup (CLUTTER_TEXT (priv->label))) clutter_text_set_markup (CLUTTER_TEXT (priv->label), text); else clutter_text_set_text (CLUTTER_TEXT (priv->label), text); g_object_notify (G_OBJECT (label), "text"); }
static void changed_cb (ClutterActor *actor, GParamSpec *pspec, ClutterActor *text) { ClutterActorAlign x_align, y_align; ClutterActor *box; ClutterLayoutManager *layout; ClutterLayoutMeta *meta; gboolean x_expand, y_expand; gchar *label; gint left, top, width, height; box = clutter_actor_get_parent (actor); layout = clutter_actor_get_layout_manager (box); meta = clutter_layout_manager_get_child_meta (layout, CLUTTER_CONTAINER (box), actor); g_object_get (actor, "x-align", &x_align, "y-align", &y_align, "x-expand", &x_expand, "y-expand", &y_expand, NULL); g_object_get (meta, "left-attach", &left, "top-attach", &top, "width", &width, "height", &height, NULL); label = g_strdup_printf ("attach: %d,%d\n" "span: %d,%d\n" "expand: %d,%d\n" "align: %s,%s", left, top, width, height, x_expand, y_expand, get_align_name (x_align), get_align_name (y_align)); clutter_text_set_text (CLUTTER_TEXT (text), label); g_free (label); }
void call_deactivate (App *app) { int i; ClutterAnimation *anim; ClutterAlpha *alpha; /* stop the flashing text */ clutter_timeline_stop (app->dialing_timeline); /* clear dialpad entry ready */ clutter_text_set_text (CLUTTER_TEXT(app->dpy_entry), ""); /* rotate screen_dial, and hide it at mid-animation */ clutter_actor_set_rotation (app->screen_dial, CLUTTER_Y_AXIS, 0.0, 0.0, 0.0, 0.0); anim = clutter_actor_animate (app->screen_dial, CLUTTER_LINEAR, 150, "rotation-angle-y", -180.0, "visible", FALSE, NULL); alpha = clutter_animation_get_alpha (anim); /* reset positions of dialer actors, needed back for flip */ for (i=0; i<12; i++) { clutter_actor_set_position (app->buttons[i]->actor, app->buttons[i]->sx, app->buttons[i]->sy); clutter_actor_set_opacity (app->buttons[i]->actor, 0xff); } clutter_actor_set_position (app->dpy, app->dpyx, app->dpyy); /* rotate hidden screen_dialpad, and show it at mid-animation */ clutter_actor_set_rotation (app->screen_dialpad, CLUTTER_Y_AXIS, 180.0, 0.0, 0.0, 0.0); clutter_actor_animate_with_alpha (app->screen_dialpad, alpha, "rotation-angle-y", 0.0, "visible", TRUE, "signal-after::completed", G_CALLBACK(on_call_deactivate_complete), app, NULL); app->dialing_state = FALSE; }
void gmc_button_set_label (GmcButton *self, const gchar *label) { GmcButtonPrivate *priv; ClutterColor *color; priv = GMC_BUTTON_GET_PRIVATE (self); if (priv->label) { if (g_strcmp0 (label, clutter_text_get_text (CLUTTER_TEXT (priv->label))) == 0) return; clutter_text_set_text (CLUTTER_TEXT (priv->label), label); return; } color = clutter_color_new (0x80, 0x80, 0x80, 0xff); priv->label = clutter_text_new_full ("Comic Sans MS 12", label, color); clutter_actor_set_parent (priv->label, CLUTTER_ACTOR (self)); clutter_color_free (color); }
/** * st_button_set_label: * @button: a #Stbutton * @text: text to set the label to * * Sets the text displayed on the button */ void st_button_set_label (StButton *button, const gchar *text) { StButtonPrivate *priv; ClutterActor *label; g_return_if_fail (ST_IS_BUTTON (button)); priv = button->priv; g_free (priv->text); if (text) priv->text = g_strdup (text); else priv->text = g_strdup (""); label = st_bin_get_child (ST_BIN (button)); if (label && CLUTTER_IS_TEXT (label)) { clutter_text_set_text (CLUTTER_TEXT (label), priv->text); } else { label = g_object_new (CLUTTER_TYPE_TEXT, "text", priv->text, "line-alignment", PANGO_ALIGN_CENTER, "ellipsize", PANGO_ELLIPSIZE_END, "use-markup", TRUE, NULL); st_bin_set_child (ST_BIN (button), label); } /* Fake a style change so that we reset the style properties on the label */ st_widget_style_changed (ST_WIDGET (button)); g_object_notify (G_OBJECT (button), "label"); }
/** * mx_button_set_action: * @button: A #MxButton * @action: A #MxAction * * Sets @action as the action for @button. @Button will take its label and * icon from @action. * * Since: 1.2 */ void mx_button_set_action (MxButton *button, MxAction *action) { MxButtonPrivate *priv; const gchar *display_name; g_return_if_fail (MX_IS_BUTTON (button)); g_return_if_fail (MX_IS_ACTION (action)); priv = button->priv; if (priv->action) g_object_unref (priv->action); if (priv->action_label_binding) g_object_unref (priv->action_label_binding); if (priv->action_icon_binding) g_object_unref (priv->action_icon_binding); priv->action = g_object_ref_sink (action); display_name = mx_action_get_display_name (action); mx_icon_set_icon_name (MX_ICON (priv->icon), mx_action_get_icon (action)); clutter_text_set_text (CLUTTER_TEXT (priv->label), (display_name) ? display_name : ""); /* bind action properties to button properties */ priv->action_label_binding = g_object_bind_property (action, "display-name", priv->label, "text", 0); priv->action_icon_binding = g_object_bind_property (action, "icon", priv->icon, "icon-name", 0); mx_button_update_contents (button); }
/** * mx_button_set_label: * @button: a #MxButton * @text: text to set the label to * * Sets the text displayed on the button */ void mx_button_set_label (MxButton *button, const gchar *text) { MxButtonPrivate *priv; g_return_if_fail (MX_IS_BUTTON (button)); priv = button->priv; g_free (priv->text); if (text) priv->text = g_strdup (text); else priv->text = g_strdup (""); clutter_text_set_text (CLUTTER_TEXT (priv->label), priv->text); mx_button_update_contents (button); g_object_notify (G_OBJECT (button), "label"); }