static gboolean _labels_update_tooltip_idle_cb (PengeInterestingTile *tile) { PengeInterestingTilePrivate *priv = GET_PRIVATE (tile); ClutterActor *tmp_text; PangoLayout *layout; tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->primary_text)); layout = clutter_text_get_layout (CLUTTER_TEXT (tmp_text)); if (pango_layout_is_ellipsized (layout)) mx_widget_set_tooltip_text (MX_WIDGET (priv->primary_text), mx_label_get_text (MX_LABEL (priv->primary_text))); else mx_widget_set_tooltip_text (MX_WIDGET (priv->primary_text), NULL); tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->secondary_text)); layout = clutter_text_get_layout (CLUTTER_TEXT (tmp_text)); if (pango_layout_is_ellipsized (layout)) mx_widget_set_tooltip_text (MX_WIDGET (priv->secondary_text), mx_label_get_text (MX_LABEL (priv->secondary_text))); else mx_widget_set_tooltip_text (MX_WIDGET (priv->secondary_text), NULL); priv->tooltip_idle_id = 0; return FALSE; }
static void penge_count_tile_get_property (GObject *gobject, guint prop_id, GValue *value, GParamSpec *pspec) { PengeCountTilePrivate *priv = PENGE_COUNT_TILE (gobject)->priv; switch (prop_id) { case PROP_MESSAGE: g_value_set_string (value, mx_label_get_text (MX_LABEL (priv->message_label))); break; case PROP_ACCOUNT: g_value_set_string (value, mx_label_get_text (MX_LABEL (priv->account_label))); break; case PROP_COUNT: g_value_set_uint (value, priv->count); break; case PROP_COMPACT: g_value_set_boolean (value, priv->compact); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; } }
static void mpl_application_view_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { MplApplicationViewPrivate *priv = APPLICATION_VIEW_PRIVATE (object); switch (property_id) { case PROP_ICON: g_value_set_object (value, priv->icon); break; case PROP_TITLE: g_value_set_string (value, mx_label_get_text (MX_LABEL (priv->title))); break; case PROP_SUBTITLE: g_value_set_string (value, mx_label_get_text (MX_LABEL (priv->subtitle))); break; case PROP_CAN_CLOSE: g_value_set_boolean (value, CLUTTER_ACTOR_IS_VISIBLE (priv->close_button)); break; case PROP_THUMBNAIL: g_value_set_object (value, priv->thumbnail); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void mex_telepathy_channel_on_contact_fetched (TpConnection *connection, guint n_contacts, TpContact *const *contacts, guint n_failed, const TpHandle *failed, const GError *fetched_error, gpointer user_data, GObject *weak_object) { MexTelepathyChannel *self = MEX_TELEPATHY_CHANNEL (user_data); int i = 0; if (self->priv->channel) { for (i = 0; i < n_contacts; ++i) { gchar *text; const gchar *alias; TpContact *current; GFile *file; // Get the contacts. current = contacts[i]; // Connect to alias change signal. // Add the alias to the label. alias = tp_contact_get_alias (current); mx_label_set_text (MX_LABEL (self->priv->title_label), alias); if (tp_channel_get_requested(self->priv->channel)) text = g_strdup_printf ("Calling %s", alias); else text = g_strdup_printf ("Setting up call with %s", alias); mx_label_set_text (MX_LABEL (self->priv->busy_label), text); g_free (text); file = tp_contact_get_avatar_file (current); if (file) { gchar *filename = g_file_get_path (file); GError *error = NULL; MEX_DEBUG ("setting new avatar filename to %s", filename); mx_image_set_from_file (MX_IMAGE(self->priv->avatar_image), filename, &error); if (error) { MEX_ERROR ("ERROR %s loading avatar from file %s\n", error->message, filename); g_clear_error (&error); } if (filename) g_free (filename); } } } }
static void mex_telepathy_channel_create_busy_box (MexTelepathyChannel *self) { MexTelepathyChannelPrivate *priv = MEX_TELEPATHY_CHANNEL (self)->priv; ClutterActor *calling_padding; ClutterActor *calling_box; ClutterActor *spinner; ClutterActor *stack; priv->busy_label = mx_label_new(); mx_label_set_y_align (MX_LABEL (priv->busy_label), MX_ALIGN_MIDDLE); mx_label_set_x_align (MX_LABEL (priv->busy_label), MX_ALIGN_MIDDLE); spinner = mx_spinner_new (); calling_box = mx_box_layout_new (); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (calling_box), priv->busy_label, 0, "expand", TRUE, "x-align", MX_ALIGN_START, "x-fill", TRUE, NULL); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (calling_box), spinner, 1, "expand", TRUE, "x-align", MX_ALIGN_END, "x-fill", FALSE, NULL); priv->busy_box = mx_frame_new (); clutter_actor_set_width (CLUTTER_ACTOR (priv->busy_box), 475); mx_stylable_set_style_class (MX_STYLABLE (priv->busy_box), "CallingFrameBorder"); calling_padding = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (calling_padding), "CallingFrame"); mx_bin_set_child (MX_BIN (priv->busy_box), calling_padding); mx_bin_set_fill (MX_BIN (priv->busy_box), TRUE, TRUE); mx_bin_set_child (MX_BIN (calling_padding), calling_box); mx_bin_set_fill (MX_BIN (calling_padding), TRUE, TRUE); stack = mx_window_get_child (mex_get_main_window ()); clutter_container_add (CLUTTER_CONTAINER (stack), priv->busy_box, NULL); mx_stack_child_set_x_fill (MX_STACK (stack), priv->busy_box, FALSE); mx_stack_child_set_y_fill (MX_STACK (stack), priv->busy_box, FALSE); }
gint mnb_launcher_button_compare (MnbLauncherButton *self, MnbLauncherButton *other) { g_return_val_if_fail (self, 0); g_return_val_if_fail (other, 0); return g_utf8_collate (mx_label_get_text (MX_LABEL (self->priv->title)), mx_label_get_text (MX_LABEL (other->priv->title))); }
static void mpl_application_view_init (MplApplicationView *self) { MplApplicationViewPrivate *priv; ClutterActor *actor = CLUTTER_ACTOR (self); priv = self->priv = APPLICATION_VIEW_PRIVATE (self); /* tile */ clutter_actor_set_reactive (actor, TRUE); mx_stylable_set_style_class (MX_STYLABLE (actor), "switcherTile"); clutter_actor_set_size (actor, TILE_WIDTH, TILE_HEIGHT); g_signal_connect (self, "button-release-event", G_CALLBACK (activate_clicked), NULL); priv->title_box = mx_box_layout_new_with_orientation (MX_ORIENTATION_VERTICAL); clutter_actor_set_parent (priv->title_box, actor); /* title */ priv->title = mx_label_new (); mx_label_set_y_align (MX_LABEL (priv->title), MX_ALIGN_MIDDLE); mx_stylable_set_style_class (MX_STYLABLE (priv->title), "appTitle"); mx_box_layout_add_actor (MX_BOX_LAYOUT (priv->title_box), priv->title, 0); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (priv->title_box), priv->title, TRUE); /* subtitle */ priv->subtitle = mx_label_new (); mx_label_set_y_align (MX_LABEL (priv->subtitle), MX_ALIGN_MIDDLE); mx_stylable_set_style_class (MX_STYLABLE (priv->subtitle), "appSubTitle"); mx_box_layout_add_actor (MX_BOX_LAYOUT (priv->title_box), priv->subtitle, 1); mx_box_layout_child_set_expand (MX_BOX_LAYOUT (priv->title_box), priv->subtitle, FALSE); /* close button */ priv->close_button = mx_button_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->close_button), "appCloseButton"); clutter_actor_set_parent (priv->close_button, actor); g_signal_connect (priv->close_button, "clicked", G_CALLBACK (close_btn_clicked), self); /* frame */ priv->app_frame = mx_frame_new (); clutter_actor_set_size (priv->app_frame, 250, 100); mx_stylable_set_style_class (MX_STYLABLE (priv->app_frame), "appBackground"); clutter_actor_set_parent (priv->app_frame, actor); /* shadow */ priv->shadow = mx_frame_new (); mx_stylable_set_style_class (MX_STYLABLE (priv->shadow), "appShadow"); mx_bin_set_child (MX_BIN (priv->app_frame), priv->shadow); mx_bin_set_fill (MX_BIN (priv->app_frame), FALSE, FALSE); clutter_actor_show_all (actor); }
static void penge_count_tile_update_tooltip (PengeCountTile *self) { PengeCountTilePrivate *priv = self->priv; gchar *tooltip_str; tooltip_str = g_strdup_printf ("%s\n%s", mx_label_get_text (MX_LABEL (priv->message_label)), mx_label_get_text (MX_LABEL (priv->account_label))); mx_widget_set_tooltip_text (MX_WIDGET (self), tooltip_str); g_free (tooltip_str); }
static void mtp_bin_toolbar_free_space_cb (MtpToolbar *toolbar, GParamSpec *pspec, MtpBin *self) { MtpBinPrivate *priv = MTP_BIN (self)->priv; if (!mtp_toolbar_has_free_space (toolbar)) mx_label_set_text (MX_LABEL (priv->message), priv->err_msg); else mx_label_set_text (MX_LABEL (priv->message), priv->normal_msg); }
/* content view */ static void mex_music_player_set_content (MexContentView *player, MexContent *content) { MexMusicPlayerPrivate *priv = MEX_MUSIC_PLAYER (player)->priv; gchar *album_artist; const gchar *uri, *album, *artist, *title; ClutterActorIter iter; ClutterActor *child, *container; if (priv->content) g_object_unref (priv->content); priv->content = content; if (!content) return; g_object_ref (content); /* title */ title = mex_content_get_metadata (content, MEX_CONTENT_METADATA_TITLE); mx_label_set_text (MX_LABEL (priv->title_label), title); /* subtitle (album, artist) */ album = mex_content_get_metadata (content, MEX_CONTENT_METADATA_ALBUM); artist = mex_content_get_metadata (content, MEX_CONTENT_METADATA_ARTIST); album_artist = g_strconcat (album, ", ", artist , NULL); mx_label_set_text (MX_LABEL (priv->subtitle_label), album_artist); g_free (album_artist); /* uri */ uri = mex_content_get_metadata (content, MEX_CONTENT_METADATA_STREAM); clutter_media_set_uri (priv->player, uri); /* find the item in the list */ container = mex_script_get_actor (priv->script, "tracks"); clutter_actor_iter_init (&iter, container); while (clutter_actor_iter_next (&iter, &child)) { MexContent *button_content; button_content = g_object_get_data (G_OBJECT (child), "content"); mx_button_set_toggled (MX_BUTTON (child), (button_content == content)); } }
static void mpd_folder_button_set_label (MpdFolderButton *self, char const *text) { MpdFolderButtonPrivate *priv = GET_PRIVATE (self); g_return_if_fail (MPD_IS_FOLDER_BUTTON (self)); if (0 != g_strcmp0 (text, mx_label_get_text (MX_LABEL (priv->label)))) { mx_label_set_text (MX_LABEL (priv->label), text); g_object_notify (G_OBJECT (self), "label"); } }
static void mx_label_get_preferred_width (ClutterActor *actor, gfloat for_height, gfloat *min_width_p, gfloat *natural_width_p) { MxLabelPrivate *priv = MX_LABEL (actor)->priv; MxPadding padding = { 0, }; mx_widget_get_padding (MX_WIDGET (actor), &padding); for_height -= padding.top + padding.bottom; clutter_actor_get_preferred_width (priv->label, for_height, min_width_p, natural_width_p); /* If we're fading out, make sure our minimum width is zero */ if (priv->fade_out && min_width_p) *min_width_p = 0; if (min_width_p) *min_width_p += padding.left + padding.right; if (natural_width_p) *natural_width_p += padding.left + padding.right; }
static void mex_queue_button_init (MexQueueButton *self) { ClutterActor *temp_text; self->priv = QUEUE_BUTTON_PRIVATE (self); self->priv->inner_box = mx_box_layout_new (); self->priv->icon = mx_icon_new (); self->priv->label = mx_label_new_with_text ("Unknown queue state"); self->priv->spinner = mx_spinner_new (); self->priv->queue_model = mex_queue_model_dup_singleton (); g_signal_connect (self->priv->spinner, "looped", (GCallback)_spinner_looped_cb, self); clutter_container_add (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->label, self->priv->icon, self->priv->spinner, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->label, "expand", TRUE, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->icon, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, "x-align", MX_ALIGN_END, NULL); clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box), self->priv->spinner, "y-align", MX_ALIGN_MIDDLE, "y-fill", FALSE, "x-align", MX_ALIGN_END, NULL); clutter_actor_hide (self->priv->spinner); mx_bin_set_child (MX_BIN (self), self->priv->inner_box); mx_bin_set_fill (MX_BIN (self), TRUE, FALSE); temp_text = mx_label_get_clutter_text (MX_LABEL (self->priv->label)); clutter_text_set_ellipsize (CLUTTER_TEXT (temp_text), PANGO_ELLIPSIZE_NONE); g_signal_connect (self, "notify::toggled", (GCallback)_queue_button_notify_toggled_cb, self); mx_button_set_is_toggle (MX_BUTTON (self), TRUE); }
static void penge_event_tile_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { PengeEventTilePrivate *priv = GET_PRIVATE (object); switch (property_id) { case PROP_EVENT: g_value_set_object (value, priv->event); break; case PROP_TIME: g_value_set_object (value, priv->time); break; case PROP_STORE: g_value_set_object (value, priv->store); break; case PROP_MULTILINE_SUMMARY: { ClutterActor *tmp_text; tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->summary_label)); g_value_set_boolean (value, !clutter_text_get_single_line_mode (CLUTTER_TEXT (tmp_text))); } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void streaming_title_notify_cb (RhythmDB *db, RhythmDBEntry *entry, const char *field, GValue *metadata, ClutterActor *label) { if (G_VALUE_HOLDS_STRING (metadata)) { update_track_info_lock (MX_LABEL (label), db, entry, g_value_get_string (metadata)); } }
static void dawati_bt_request_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { DawatiBtRequestPrivate *priv = GET_PRIVATE (object); switch (property_id) { case PROP_NAME: mx_label_set_text (MX_LABEL (priv->title), g_value_get_string (value)); break; case PROP_DEVICE_PATH: g_free (priv->device_path); priv->device_path = g_value_dup_string (value); break; case PROP_REQUEST_TYPE: dawati_bt_request_set_request_type (DAWATI_BT_REQUEST (object), g_value_get_uint (value)); break; case PROP_REQUEST_DATA: dawati_bt_request_set_request_data (DAWATI_BT_REQUEST (object), g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
static void mx_label_dispose (GObject *actor) { MxLabelPrivate *priv = MX_LABEL (actor)->priv; if (priv->fade_timeline) { clutter_timeline_stop (priv->fade_timeline); g_object_unref (priv->fade_timeline); priv->fade_timeline = NULL; } if (priv->fade_alpha) { g_object_unref (priv->fade_alpha); priv->fade_alpha = NULL; } if (priv->label) { clutter_actor_destroy (priv->label); priv->label = NULL; } G_OBJECT_CLASS (mx_label_parent_class)->dispose (actor); }
static void mpd_disk_tile_init (MpdDiskTile *self) { MpdDiskTilePrivate *priv = GET_PRIVATE (self); mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL); mx_box_layout_set_spacing (MX_BOX_LAYOUT (self), 5); priv->label = mx_label_new (); clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->label); clutter_text_set_ellipsize (CLUTTER_TEXT (mx_label_get_clutter_text ( MX_LABEL (priv->label))), PANGO_ELLIPSIZE_NONE); priv->meter = mx_progress_bar_new (); clutter_actor_set_height (priv->meter, 12); clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->meter); /* Display size of the volume $HOME is on. */ priv->storage = mpd_storage_device_new (g_get_home_dir ()); g_signal_connect (priv->storage, "notify::size", G_CALLBACK (_storage_size_notify_cb), self); g_signal_connect (priv->storage, "notify::available-size", G_CALLBACK (_storage_size_notify_cb), self); update (self); }
static ClutterActor * _make_notification_actor (MexNotification *notification) { ClutterActor *box; ClutterActor *label, *icon; box = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_HORIZONTAL); if (notification->icon) { icon = mx_icon_new (); clutter_actor_set_size (icon, 26, 26); mx_icon_set_icon_name (MX_ICON (icon), notification->icon); clutter_container_add_actor (CLUTTER_CONTAINER (box), icon); mx_box_layout_child_set_y_align (MX_BOX_LAYOUT (box), icon, MX_ALIGN_MIDDLE); } label = mx_label_new_with_text (notification->message); mx_label_set_y_align (MX_LABEL (label), MX_ALIGN_MIDDLE); clutter_container_add_actor (CLUTTER_CONTAINER (box), label); return box; }
static void update_float_prop_label (FloatProp *prop, float value) { char *value_text = g_strdup_printf ("%.2f", value); mx_label_set_text (MX_LABEL (prop->label), value_text); g_free (value_text); }
static void penge_count_tile_set_count (PengeCountTile *self, guint count) { PengeCountTilePrivate *priv = self->priv; gchar *count_str; priv->count = count; /* min-width does not seem to work, so we workaround adding padding spaced * around the number for 1 digit version */ if (count < 10) count_str = g_strdup_printf (" %u ", count); else count_str = g_strdup_printf ("%u", count); mx_label_set_text (MX_LABEL (priv->count_label), count_str); g_free (count_str); if (count == 0) mx_stylable_set_style_class (MX_STYLABLE (priv->count_label), "PengeZeroCountLabel"); else mx_stylable_set_style_class (MX_STYLABLE (priv->count_label), "PengeCountLabel"); if (priv->compact) penge_count_tile_update_tooltip (self); }
static char const * mpd_folder_button_get_label (MpdFolderButton *self) { MpdFolderButtonPrivate *priv = GET_PRIVATE (self); g_return_val_if_fail (MPD_IS_FOLDER_BUTTON (self), NULL); return mx_label_get_text (MX_LABEL (priv->label)); }
static void playing_song_changed_cb (RBShellPlayer *player, RhythmDBEntry *entry, ClutterActor *label) { RhythmDB *db; g_object_get (player, "db", &db, NULL); update_track_info_lock (MX_LABEL (label), db, entry, NULL); g_object_unref (db); }
static void update_prop_comp_label (ColorPropComp *prop_comp, guint8 value) { char *label_text; label_text = g_strdup_printf ("%i", value); mx_label_set_text (MX_LABEL (prop_comp->label), label_text); g_free (label_text); }
static void mx_label_style_changed (MxWidget *self, MxStyleChangedFlags flags) { MxLabelPrivate *priv = MX_LABEL (self)->priv; mx_stylable_apply_clutter_text_attributes (MX_STYLABLE (self), CLUTTER_TEXT (priv->label)); }
static void mx_label_map (ClutterActor *actor) { MxLabelPrivate *priv = MX_LABEL (actor)->priv; CLUTTER_ACTOR_CLASS (mx_label_parent_class)->map (actor); clutter_actor_map (priv->label); }
void mpl_application_view_set_subtitle (MplApplicationView *view, const gchar *text) { MplApplicationViewPrivate *priv; g_return_if_fail (MPL_IS_APPLICATION_VIEW (view)); priv = view->priv; mx_label_set_text (MX_LABEL (priv->subtitle), text); if (!strcmp (mx_label_get_text (MX_LABEL (priv->title)), mx_label_get_text (MX_LABEL (priv->subtitle)))) clutter_actor_hide (priv->subtitle); else clutter_actor_show (priv->subtitle); }
static void mnb_launcher_button_init (MnbLauncherButton *self) { ClutterActor *label; self->priv = MNB_LAUNCHER_BUTTON_GET_PRIVATE (self); g_signal_connect (self, "leave-event", G_CALLBACK (_leave_event_cb), NULL); g_signal_connect (self, "key-focus-out", G_CALLBACK (_leave_event_cb), NULL); g_signal_connect (self, "enter-event", G_CALLBACK (_enter_event_cb), NULL); self->priv->icon = NULL; mx_stylable_set_style_class (MX_STYLABLE (self), "contentTile"); /* "app" label */ self->priv->title = (MxLabel *) mx_label_new (); mx_label_set_x_align (MX_LABEL (self->priv->title), MX_ALIGN_MIDDLE); clutter_actor_set_reactive (CLUTTER_ACTOR (self->priv->title), FALSE); mx_table_insert_actor_with_properties (MX_TABLE (self), CLUTTER_ACTOR (self->priv->title), 1, 0, "x-align", MX_ALIGN_MIDDLE, "x-expand", TRUE, "x-fill", TRUE, "y-align", MX_ALIGN_MIDDLE, "y-expand", TRUE, "y-fill", TRUE, NULL); label = mx_label_get_clutter_text (self->priv->title); clutter_text_set_ellipsize (CLUTTER_TEXT (label), PANGO_ELLIPSIZE_END); clutter_text_set_line_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER); clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE); clutter_text_set_line_wrap_mode (CLUTTER_TEXT (label), PANGO_WRAP_WORD_CHAR); /* "fav app" toggle */ self->priv->fav_toggle = g_object_ref_sink (CLUTTER_ACTOR (mx_button_new ())); mx_button_set_is_toggle (MX_BUTTON (self->priv->fav_toggle), TRUE); clutter_actor_set_name (CLUTTER_ACTOR (self->priv->fav_toggle), "mnb-launcher-button-fav-toggle"); clutter_actor_set_size (self->priv->fav_toggle, FAV_TOGGLE_SIZE, FAV_TOGGLE_SIZE); mx_table_insert_actor (MX_TABLE (self), CLUTTER_ACTOR (self->priv->fav_toggle), 0, 0); g_signal_connect (self->priv->fav_toggle, "notify::toggled", G_CALLBACK (fav_button_notify_toggled_cb), self); clutter_actor_set_reactive ((ClutterActor *) self, TRUE); }
static void penge_count_tile_set_account (PengeCountTile *self, const gchar *account) { PengeCountTilePrivate *priv = self->priv; mx_label_set_text (MX_LABEL (priv->account_label), account); if (priv->compact) penge_count_tile_update_tooltip (self); }
static void penge_count_tile_set_message (PengeCountTile *self, const gchar *message) { PengeCountTilePrivate *priv = self->priv; mx_label_set_text (MX_LABEL (priv->message_label), message); if (priv->compact) penge_count_tile_update_tooltip (self); }