static void update (MpdStorageDeviceTile *self) { MpdStorageDeviceTilePrivate *priv = GET_PRIVATE (self); char *markup; int64_t size = -1; int64_t available_size = -1; markup = mpd_storage_device_tile_get_title (self); clutter_text_set_markup (GET_CLUTTER_TEXT (priv->label), markup); g_free (markup); if (priv->storage) { g_object_get (priv->storage, "size", &size, "available-size", &available_size, NULL); } if (size > -1 && available_size > -1) { unsigned int percentage = 100 - (double) available_size / size * 100; mx_progress_bar_set_progress (MX_PROGRESS_BAR (priv->meter), percentage / 100.); } else { g_object_set (priv->meter, "visible", false, NULL); mx_table_child_set_row_span (MX_TABLE (priv->table), priv->label, 2); } }
void xfdashboard_text_box_set_text(XfdashboardTextBox *self, const gchar *inMarkupText) { XfdashboardTextBoxPrivate *priv; const gchar *text; g_return_if_fail(XFDASHBOARD_IS_TEXT_BOX(self)); priv=self->priv; /* Set value if changed */ if(g_strcmp0(clutter_text_get_text(CLUTTER_TEXT(priv->actorTextBox)), inMarkupText)!=0) { clutter_text_set_markup(CLUTTER_TEXT(priv->actorTextBox), inMarkupText); text=clutter_text_get_text(CLUTTER_TEXT(priv->actorTextBox)); if((text==NULL || *text==0) && priv->isEditable) { clutter_actor_show(priv->actorHintLabel); } else { clutter_actor_hide(priv->actorHintLabel); } clutter_actor_queue_relayout(CLUTTER_ACTOR(self)); /* Notify about property change */ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardTextBoxProperties[PROP_TEXT]); } }
static void set_info_text (const gchar *name) { gchar *title; title = g_strdup_printf ("<b>File:</b> %s", name); clutter_text_set_markup (CLUTTER_TEXT (info_text), title); g_free (title); }
static void set_info_text (void) { gchar *title; title = g_strdup_printf ("<b>Current View:</b> %s\n<b>Threshold:</b> %d", SHOW_SKELETON ? "Skeleton" : "Point Cloud", THRESHOLD_END); clutter_text_set_markup (CLUTTER_TEXT (info_text), title); g_free (title); }
static void update_name_text (ShellStatusMenu *status) { ShellStatusMenuPrivate *priv = status->priv; char *markup; markup = g_markup_printf_escaped("<b>%s</b>", gdm_user_get_real_name (GDM_USER (priv->user))); clutter_text_set_markup (priv->name, markup); g_free (markup); }
static ClutterActor * create_instructions (void) { ClutterActor *text; text = clutter_text_new (); clutter_text_set_markup (CLUTTER_TEXT (text), "<b>Instructions:</b>\n" "\tTake shot and save: \tSpace bar\n" "\tSet tilt angle: \t\t\t\tUp/Down Arrows\n" "\tIncrease threshold: \t\t\t+/-"); return text; }
static ClutterActor * create_instructions (void) { ClutterActor *text; text = clutter_text_new (); clutter_text_set_markup (CLUTTER_TEXT (text), "<b>Instructions:</b>\n" "\tChange between skeleton\n" "\t tracking and threshold view: \tSpace bar\n" "\tSet tilt angle: \t\t\t\tUp/Down Arrows\n" "\tIncrease threshold: \t\t\t+/-"); return text; }
static void update_track_info (MxLabel *label, RhythmDB *db, RhythmDBEntry *entry, const char *streaming_title) { const char *title; ClutterActor *text; GString *str; text = mx_label_get_clutter_text (label); str = g_string_sized_new (100); if (entry == NULL) { g_string_append_printf (str, "<big>%s</big>", _("Not Playing")); } else { title = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE); if (streaming_title) { str_append_printf_escaped (str, "<big>%s</big>\n", streaming_title); str_append_printf_escaped (str, _("from <i>%s</i>"), title); } else { const char *artist_template = NULL; const char *album_template = NULL; const char *artist; const char *album; gboolean space = FALSE; artist = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST); album = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM); get_artist_album_templates (artist, album, &artist_template, &album_template); str_append_printf_escaped (str, "<big>%s</big>\n", title); if (album != NULL && album[0] != '\0') { str_append_printf_escaped (str, album_template, album); space = TRUE; } if (artist != NULL && artist[0] != '\0') { if (space) { g_string_append_c (str, ' '); } str_append_printf_escaped (str, artist_template, artist); } } } /* tiny bit of extra padding */ g_string_append (str, " "); clutter_text_set_markup (CLUTTER_TEXT (text), str->str); clutter_text_set_ellipsize (CLUTTER_TEXT (text), PANGO_ELLIPSIZE_NONE); g_string_free (str, TRUE); }
static ClutterActor * create_label (const ClutterColor *color, const gchar *text) { ClutterActor *retval = clutter_text_new (); clutter_text_set_color (CLUTTER_TEXT (retval), color); clutter_text_set_markup (CLUTTER_TEXT (retval), text); clutter_text_set_editable (CLUTTER_TEXT (retval), FALSE); clutter_text_set_selectable (CLUTTER_TEXT (retval), FALSE); clutter_text_set_single_line_mode (CLUTTER_TEXT (retval), TRUE); clutter_text_set_ellipsize (CLUTTER_TEXT (retval), PANGO_ELLIPSIZE_END); return retval; }
static void set_info_text (void) { gchar *title; title = g_strdup_printf ("<b>Current View:</b> %s\t\t\t" "<b>Threshold:</b> %d\n" "<b>Smoothing Enabled:</b> %s\t\t\t" "<b>Smoothing Level:</b> %.2f", SHOW_SKELETON ? "Skeleton" : "Point Cloud", THRESHOLD_END, ENABLE_SMOOTHING ? "Yes" : "No", SMOOTHING_FACTOR); clutter_text_set_markup (CLUTTER_TEXT (info_text), title); g_free (title); }
/** * 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"); }
void xfdashboard_text_box_set_hint_text(XfdashboardTextBox *self, const gchar *inMarkupText) { XfdashboardTextBoxPrivate *priv; gboolean newHintTextSet; g_return_if_fail(XFDASHBOARD_IS_TEXT_BOX(self)); priv=self->priv; newHintTextSet=FALSE; /* Freeze notification */ g_object_freeze_notify(G_OBJECT(self)); /* Set value if changed */ if(g_strcmp0(clutter_text_get_text(CLUTTER_TEXT(priv->actorHintLabel)), inMarkupText)!=0) { /* Set value */ clutter_text_set_markup(CLUTTER_TEXT(priv->actorHintLabel), inMarkupText); clutter_actor_queue_relayout(CLUTTER_ACTOR(self)); /* Notify about property change */ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardTextBoxProperties[PROP_HINT_TEXT]); } /* Check if a hint text was set and if read-only property changes. * Note: NULL string will unset "hint-text-set" property (set to FALSE) */ if(inMarkupText) newHintTextSet=TRUE; if(newHintTextSet!=priv->hintTextSet) { /* Set flag */ priv->hintTextSet=newHintTextSet; /* Notify about property change */ g_object_notify_by_pspec(G_OBJECT(self), XfdashboardTextBoxProperties[PROP_HINT_TEXT_SET]); } /* Thaw notification */ g_object_thaw_notify(G_OBJECT(self)); }
static void set_info_text (gint seconds) { gchar *title, *threshold; gchar *record_status = NULL; threshold = g_strdup_printf ("<b>Threshold:</b> %d", THRESHOLD_END); if (seconds == 0) { record_status = g_strdup (" <b>SAVING DEPTH FILE!</b>"); } else if (seconds > 0) { record_status = g_strdup_printf (" <b>Taking shot in:</b> %d seconds", seconds); } title = g_strconcat (threshold, record_status, NULL); clutter_text_set_markup (CLUTTER_TEXT (info_text), title); g_free (title); g_free (threshold); g_free (record_status); }
static void update (MpdDiskTile *self) { MpdDiskTilePrivate *priv = GET_PRIVATE (self); char *markup; char *size_text; uint64_t size; uint64_t available_size; unsigned int percentage; g_object_get (priv->storage, "size", &size, "available-size", &available_size, NULL); percentage = 100 - (double) available_size / size * 100; /* We don't want to display 0% used, we still have *something* installed */ if (percentage == 0) percentage++; size_text = g_format_size (size); markup = g_strdup_printf (_("You are using %d%% of %s"), percentage, size_text); clutter_text_set_markup (CLUTTER_TEXT (mx_label_get_clutter_text ( MX_LABEL (priv->label))), markup); g_free (markup); g_free (size_text); /* The progress bar does not look good if the percentage < 3%. We cheat * and always display a minimum of 3% */ mx_progress_bar_set_progress (MX_PROGRESS_BAR (priv->meter), MAX (.03, percentage / 100.)); }
static void set_up_stage (CalibArea *calib_area, ClutterActor *stage) { ClutterPoint anchor; ClutterColor color; ClutterContent *success_content; gfloat height; gchar *markup; calib_area->stage = stage; calib_area->action_layer = clutter_actor_new (); calib_area->clock = cc_clock_actor_new (); calib_area->target = cc_target_actor_new (); calib_area->text_title_holder = clutter_actor_new (); calib_area->helper_text_title = clutter_text_new (); calib_area->text_body_holder = clutter_actor_new (); calib_area->helper_text_body = clutter_text_new (); calib_area->error_text = clutter_text_new (); calib_area->success_image = clutter_actor_new (); clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE); clutter_actor_hide (calib_area->target); /* bind the action layer's geometry to the stage's */ clutter_actor_add_constraint (calib_area->action_layer, clutter_bind_constraint_new (stage, CLUTTER_BIND_SIZE, 0)); clutter_actor_add_child (stage, calib_area->action_layer); g_signal_connect (stage, "allocation-changed", G_CALLBACK (on_allocation_changed), calib_area); clutter_color_from_string (&color, "#000"); color.alpha = WINDOW_OPACITY * 255; clutter_actor_set_background_color (stage, &color); clutter_actor_add_child (calib_area->action_layer, calib_area->clock); clutter_actor_add_constraint (calib_area->clock, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5)); clutter_actor_add_child (calib_area->action_layer, calib_area->target); /* set the helper text */ anchor.x = 0; g_object_set (calib_area->text_title_holder, "pivot-point", &anchor, NULL); clutter_actor_add_child (calib_area->action_layer, calib_area->text_title_holder); clutter_actor_add_child (calib_area->text_title_holder, calib_area->helper_text_title); height = clutter_actor_get_height (calib_area->clock); clutter_actor_add_constraint (calib_area->text_title_holder, clutter_bind_constraint_new (calib_area->clock, CLUTTER_BIND_Y, height * 1.5)); clutter_actor_add_constraint (calib_area->text_title_holder, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, .5)); clutter_text_set_line_alignment (CLUTTER_TEXT (calib_area->helper_text_title), PANGO_ALIGN_CENTER); color.red = COLOR_GRAY; color.green = COLOR_GRAY; color.blue = COLOR_GRAY; color.alpha = 255; markup = g_strdup_printf ("<big><b>%s</b></big>", _(HELP_TEXT_TITLE)); clutter_text_set_markup (CLUTTER_TEXT (calib_area->helper_text_title), markup); clutter_text_set_color (CLUTTER_TEXT (calib_area->helper_text_title), &color); g_free (markup); g_object_set (calib_area->text_body_holder, "pivot-point", &anchor, NULL); clutter_actor_add_child (calib_area->action_layer, calib_area->text_body_holder); clutter_actor_add_child (calib_area->text_body_holder, calib_area->helper_text_body); height = clutter_actor_get_height (calib_area->helper_text_title); clutter_actor_add_constraint (calib_area->text_body_holder, clutter_bind_constraint_new (calib_area->text_title_holder, CLUTTER_BIND_Y, height * 1.2)); clutter_actor_add_constraint (calib_area->text_body_holder, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, .5)); clutter_text_set_line_alignment (CLUTTER_TEXT (calib_area->helper_text_body), PANGO_ALIGN_CENTER); markup = g_strdup_printf ("<span foreground=\"white\"><big>%s</big></span>", _(HELP_TEXT_MAIN)); clutter_text_set_markup (CLUTTER_TEXT (calib_area->helper_text_body), markup); g_free (markup); /* set the error text */ g_object_set (calib_area->error_text, "pivot-point", &anchor, NULL); clutter_actor_add_child (calib_area->action_layer, calib_area->error_text); height = clutter_actor_get_height (calib_area->helper_text_body); clutter_actor_add_constraint (calib_area->error_text, clutter_bind_constraint_new (calib_area->text_title_holder, CLUTTER_BIND_Y, height * 3)); clutter_actor_add_constraint (calib_area->error_text, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, .5)); clutter_text_set_line_alignment (CLUTTER_TEXT (calib_area->error_text), PANGO_ALIGN_CENTER); markup = g_strdup_printf ("<span foreground=\"white\"><big>" "<b>%s</b></big></span>", ERROR_MESSAGE); clutter_text_set_markup (CLUTTER_TEXT (calib_area->error_text), markup); g_free (markup); clutter_actor_hide (calib_area->error_text); /* configure success image */ success_content = clutter_image_new (); clutter_actor_set_content (calib_area->success_image, success_content); g_object_unref (success_content); clutter_actor_add_child (stage, calib_area->success_image); clutter_actor_add_constraint (calib_area->success_image, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, .5)); /* animate clock */ calib_area->clock_timeline = clutter_property_transition_new ("angle"); clutter_timeline_set_progress_mode (CLUTTER_TIMELINE (calib_area->clock_timeline), CLUTTER_LINEAR); clutter_timeline_set_duration (CLUTTER_TIMELINE (calib_area->clock_timeline), MAX_TIME); clutter_transition_set_animatable (calib_area->clock_timeline, CLUTTER_ANIMATABLE (calib_area->clock)); clutter_transition_set_from (calib_area->clock_timeline, G_TYPE_FLOAT, .0); clutter_transition_set_to (calib_area->clock_timeline, G_TYPE_FLOAT, 360.0); clutter_timeline_set_repeat_count (CLUTTER_TIMELINE (calib_area->clock_timeline), -1); clutter_timeline_start (CLUTTER_TIMELINE (calib_area->clock_timeline)); g_signal_connect (CLUTTER_TIMELINE (calib_area->clock_timeline), "completed", G_CALLBACK (on_timeout), calib_area); g_signal_connect (stage, "button-press-event", G_CALLBACK (on_button_press_event), calib_area); g_signal_connect (stage, "key-release-event", G_CALLBACK (on_key_release_event), calib_area); }
static void penge_event_tile_update (PengeEventTile *tile) { PengeEventTilePrivate *priv = GET_PRIVATE (tile); gchar *time_str; gchar *summary_str; JanaTime *t; gchar *p; if (!priv->event) return; if (priv->time) { t = jana_event_get_start (priv->event); /* Translate this time into local time */ jana_time_set_offset (t, jana_time_get_offset (priv->time)); if (jana_time_get_day (priv->time) != jana_time_get_day (t)) { gchar *tmp_str; gchar *day_str; ClutterActor *tmp_text; tmp_str = jana_utils_strftime (t, "%a"); day_str = g_utf8_strup (tmp_str, -1); g_free (tmp_str); time_str = jana_utils_strftime (t, "%H:%M"); tmp_str = g_strdup_printf ("%s <span size=\"xx-small\">%s</span>", time_str, day_str); g_free (time_str); g_free (day_str); tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->time_label)); clutter_text_set_markup (CLUTTER_TEXT (tmp_text), tmp_str); g_free (tmp_str); } else { time_str = jana_utils_strftime (t, "%H:%M"); mx_label_set_text (MX_LABEL (priv->time_label), time_str); g_free (time_str); } if (jana_time_get_day (priv->time) != jana_time_get_day (t)) { mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->time_label), "past"); } else { mx_stylable_set_style_pseudo_class (MX_STYLABLE (priv->time_label), NULL); } g_object_unref (t); } summary_str = jana_event_get_summary (priv->event); if (summary_str) { /* this hack is courtesy of Chris Lord, we look for a new line character * and if we find it replace it with \0. We need this because otherwise * new lines in our labels look funn */ p = strchr (summary_str, '\n'); if (p) *p = '\0'; mx_label_set_text (MX_LABEL (priv->summary_label), summary_str); g_free (summary_str); } else { mx_label_set_text (MX_LABEL (priv->summary_label), ""); } }