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); }
static void _update_presence_message (MnbPeoplePanel *self) { MnbPeoplePanelPrivate *priv = GET_PRIVATE (self); gchar *message; tp_account_manager_get_most_available_presence (priv->am, NULL, &message); mx_label_set_text (MX_LABEL (priv->presence_message), message); g_free (message); }
static void update_elapsed (ClutterActor *label, RBShellPlayer *player, guint elapsed) { long duration; char *str; duration = rb_shell_player_get_playing_song_duration (player); str = rb_make_elapsed_time_string (elapsed, duration, FALSE); mx_label_set_text (MX_LABEL (label), str); g_free (str); }
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_queue_button_update (MexQueueButton *button) { MexQueueButtonPrivate *priv = button->priv; if (mex_content_get_metadata (priv->content, MEX_CONTENT_METADATA_QUEUED)) { mx_label_set_text (MX_LABEL (priv->label), _("Remove from queue")); g_signal_handlers_block_by_func (button, _queue_button_notify_toggled_cb, button); mx_button_set_toggled (MX_BUTTON (button), TRUE); g_signal_handlers_unblock_by_func (button, _queue_button_notify_toggled_cb, button); } else { mx_label_set_text (MX_LABEL (priv->label), _("Add to queue")); g_signal_handlers_block_by_func (button, _queue_button_notify_toggled_cb, button); mx_button_set_toggled (MX_BUTTON (button), FALSE); g_signal_handlers_unblock_by_func (button, _queue_button_notify_toggled_cb, button); } if (mx_spinner_get_animating (MX_SPINNER (button->priv->spinner))) { mx_label_set_text (MX_LABEL (button->priv->label), _("Adding to queue")); clutter_actor_hide (button->priv->icon); clutter_actor_show (button->priv->spinner); } else { clutter_actor_hide (button->priv->spinner); clutter_actor_show (button->priv->icon); } }
static void dawati_bt_device_set_name (DawatiBtDevice *device, const char *name) { DawatiBtDevicePrivate *priv = GET_PRIVATE (device); char* label; g_free (priv->name); priv->name = g_strdup (name); label = g_strdup_printf (_("Connected to %s"), priv->name); mx_label_set_text (MX_LABEL (priv->label), label); g_free (label); }
static void dawati_bt_request_update_strings (DawatiBtRequest *request) { DawatiBtRequestPrivate *priv = GET_PRIVATE (request); const char *name = NULL; char *msg = NULL; const char *yes = ""; switch (priv->request) { case DAWATI_BT_REQUEST_TYPE_AUTH: if (priv->request_data) { name = g_hash_table_lookup (priv->uuid_strings, priv->request_data); if (name) { /* TRANSLATORS: request message. Will appear just below a device name */ msg = g_strdup_printf (_("Wants access to %s service"), name); } else { g_debug ("Unrecognised service '%s' requested", priv->request_data); /* TRANSLATORS: request message. Will appear just below a device name */ msg = g_strdup (_("wants access to a service")); } /* TRANSLATORS: request button label */ yes = _("Grant this time"); } break; case DAWATI_BT_REQUEST_TYPE_PIN: case DAWATI_BT_REQUEST_TYPE_PASSKEY: /* TRANSLATORS: request message. Will appear just below a device name */ msg = g_strdup (_("Wants to pair with this computer. " "Please enter the PIN mentioned on the device")); /* TRANSLATORS: request button label */ yes = _("OK"); break; case DAWATI_BT_REQUEST_TYPE_CONFIRM: /* TRANSLATORS: request message. Will appear just below a device name */ msg = g_strdup_printf (_("Wants to pair with this computer. " "Please confirm whether the PIN '%s' matches the one on the device"), priv->request_data); /* TRANSLATORS: request button label */ yes = _("Matches"); break; default: break; } mx_label_set_text (MX_LABEL (priv->request_label), msg); mx_button_set_label (MX_BUTTON (priv->request_yes_btn), yes); g_free (msg); }
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"); } }
/** * mpl_content_pane_set_title: * @self: #MplContentPane * @title: title * * Sets the title of the pane to the given string. */ void mpl_content_pane_set_title (MplContentPane *self, char const *title) { MplContentPanePrivate *priv = GET_PRIVATE (self); bool do_notify; g_return_if_fail (MPL_IS_CONTENT_PANE (self)); do_notify = g_strcmp0 (title, mx_label_get_text (priv->title)); mx_label_set_text (priv->title, title); if (do_notify) g_object_notify ((GObject *) self, "title"); }
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 mex_media_controls_notify_progress_cb (ClutterMedia *media, GParamSpec *pspec, MexMediaControls *self) { MexMediaControlsPrivate *priv = self->priv; MxLabel *label; gchar *text; gdouble length, progress_s; gfloat progress; gint len_h, len_m, len_s, pos_h, pos_m, pos_s; if (priv->show_description) return; progress = clutter_media_get_progress (media); length = clutter_media_get_duration (media); len_h = length / 3600; len_m = (length - (len_h * 3600)) / 60; len_s = (length - (len_h * 3600) - (len_m * 60)); progress_s = length * progress; pos_h = progress_s / 3600; pos_m = (progress_s - (pos_h * 3600)) / 60; pos_s = (progress_s - (pos_h * 3600) - (pos_m * 60)); g_signal_handlers_block_by_func (priv->slider, slider_value_changed_cb, self); mx_slider_set_value (MX_SLIDER (priv->slider), progress); g_signal_handlers_unblock_by_func (priv->slider, slider_value_changed_cb, self); if (len_h > 0) text = g_strdup_printf ("%02d:%02d:%02d / %02d:%02d:%02d", pos_h, pos_m, pos_s, len_h, len_m, len_s); else text = g_strdup_printf ("%02d:%02d / %02d:%02d", pos_m, pos_s, len_m, len_s); label = (MxLabel*) clutter_script_get_object (priv->script, "progress-label"); mx_label_set_text (label, text); g_free (text); }
static void mx_label_set_property (GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec) { MxLabel *label = MX_LABEL (gobject); switch (prop_id) { case PROP_TEXT: mx_label_set_text (label, g_value_get_string (value)); break; case PROP_USE_MARKUP: mx_label_set_use_markup (label, g_value_get_boolean (value)); break; case PROP_Y_ALIGN: mx_label_set_y_align (label, g_value_get_enum (value)); break; case PROP_X_ALIGN: mx_label_set_x_align (label, g_value_get_enum (value)); break; case PROP_LINE_WRAP: mx_label_set_line_wrap (label, g_value_get_boolean (value)); break; case PROP_FADE_OUT: mx_label_set_fade_out (label, g_value_get_boolean (value)); break; case PROP_SHOW_TOOLTIP: mx_label_set_show_tooltip (label, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; } }
void mpd_storage_device_tile_show_message_full (MpdStorageDeviceTile *self, char const *message, bool replace_buttons, unsigned int timeout_s, GSourceFunc function, void *data) { MpdStorageDeviceTilePrivate *priv = GET_PRIVATE (self); g_return_if_fail (MPD_IS_STORAGE_DEVICE_TILE (self)); if (priv->message == NULL) { ClutterText *text; priv->message = mx_label_new_with_text (message); mx_stylable_set_style_class (MX_STYLABLE (priv->message), "message"); text = (ClutterText *) mx_label_get_clutter_text (MX_LABEL (priv->message)); clutter_text_set_line_wrap (text, true); clutter_text_set_line_wrap_mode (text, PANGO_WRAP_WORD); clutter_text_set_single_line_mode (text, false); clutter_text_set_ellipsize (text, PANGO_ELLIPSIZE_NONE); mx_box_layout_add_actor_with_properties (MX_BOX_LAYOUT (self), priv->message, 2, "x-align", MX_ALIGN_MIDDLE, NULL); } if (replace_buttons) { mx_widget_set_disabled (MX_WIDGET (priv->open), true); mx_widget_set_disabled (MX_WIDGET (priv->eject), true); clutter_container_remove_actor (CLUTTER_CONTAINER (self), priv->import); } mx_label_set_text (MX_LABEL (priv->message), message); if (timeout_s) { g_timeout_add_seconds (timeout_s, function, data); } }
static gboolean mex_clock_update_cb (MexClockBin *self) { gchar text[100]; struct tm *current_time; time_t now_t = time (NULL); MexClockBinPrivate *priv = self->priv; current_time = localtime (&now_t); strftime (text, 100, "%l:%M %p", current_time); mx_label_set_text (MX_LABEL (priv->time_label), text); priv->update_source = g_timeout_add_seconds (60 - current_time->tm_sec, (GSourceFunc)mex_clock_update_cb, self); return FALSE; }
static void mex_music_player_update_progress (MexMusicPlayer *player) { MexMusicPlayerPrivate *priv = player->priv; ClutterActor *label, *slider; gchar *text; gdouble progress, duration; progress = clutter_media_get_progress (priv->player); duration = clutter_media_get_duration (priv->player); label = mex_script_get_actor (priv->script, "progress-label"); slider = mex_script_get_actor (priv->script, "progress-slider"); g_signal_handler_block (slider, priv->slider_notify_id); mx_slider_set_value (MX_SLIDER (slider), progress); g_signal_handler_unblock (slider, priv->slider_notify_id); text = mex_metadata_utils_create_progress_string (progress, duration); mx_label_set_text (MX_LABEL (label), text); g_free (text); }
MxWidget * mnb_launcher_button_new (const gchar *icon_name, const gchar *icon_file, gint icon_size, const gchar *title, const gchar *category, const gchar *description, const gchar *executable, const gchar *desktop_file_path) { MnbLauncherButton *self; self = g_object_new (MNB_TYPE_LAUNCHER_BUTTON, NULL); self->priv->icon_name = g_strdup (icon_name); mnb_launcher_button_set_icon (self, icon_file, icon_size); if (title) mx_label_set_text (self->priv->title, title); if (category) self->priv->category = g_strdup (category); if (description) { self->priv->description = g_strdup (description); /* NO tooltip due to ugly ness and length of description * mx_widget_set_tooltip_text (MX_WIDGET (self), self->priv->description); */ } if (executable) self->priv->executable = g_strdup (executable); if (desktop_file_path) self->priv->desktop_file_path = g_strdup (desktop_file_path); return MX_WIDGET (self); }
static void mex_media_controls_update_header (MexMediaControls *self) { MexMediaControlsPrivate *priv = self->priv; ClutterActor *label, *image; const gchar *logo_url; GError *err = NULL; label = (ClutterActor*) clutter_script_get_object (priv->script, "title-label"); image = (ClutterActor*) clutter_script_get_object (priv->script, "logo"); mx_label_set_text (MX_LABEL (label), mex_content_get_metadata (priv->content, MEX_CONTENT_METADATA_TITLE)); logo_url = mex_content_get_metadata (priv->content, MEX_CONTENT_METADATA_STATION_LOGO); if (!logo_url) { clutter_actor_hide (image); } else { clutter_actor_show (image); if (g_str_has_prefix (logo_url, "file://")) logo_url = logo_url + 7; mx_image_set_from_file (MX_IMAGE (image), logo_url, &err); if (err) { g_warning ("Could not load logo: %s", err->message); g_clear_error (&err); } } }
static void penge_interesting_tile_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { PengeInterestingTilePrivate *priv = GET_PRIVATE (object); GError *error = NULL; const gchar *path; switch (property_id) { case PROP_BODY: if (priv->body) { clutter_container_remove_actor (CLUTTER_CONTAINER (priv->inner_table), priv->body); } priv->body = g_value_get_object (value); if (!priv->body) return; mx_table_add_actor_with_properties (MX_TABLE (priv->inner_table), priv->body, 0, 0, "y-align", MX_ALIGN_START, "x-align", MX_ALIGN_START, "y-fill", TRUE, "y-expand", TRUE, NULL); break; case PROP_ICON_PATH: path = g_value_get_string (value); if (path && !clutter_texture_set_from_file (CLUTTER_TEXTURE (priv->icon), path, &error)) { g_critical (G_STRLOC ": error setting icon texture from file: %s", error->message); g_clear_error (&error); } if (path) { clutter_actor_show (priv->icon); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), priv->primary_text, "column", 1, NULL); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), priv->secondary_text, "column", 1, NULL); } else { clutter_actor_hide (priv->icon); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), priv->primary_text, "column", 0, NULL); clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay), priv->secondary_text, "column", 0, NULL); } break; case PROP_PRIMARY_TEXT: mx_label_set_text (MX_LABEL (priv->primary_text), g_value_get_string (value)); break; case PROP_SECONDARY_TEXT: mx_label_set_text (MX_LABEL (priv->secondary_text), g_value_get_string (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
void mex_column_view_set_label (MexColumnView *column, const gchar *label) { g_return_if_fail (MEX_IS_COLUMN_VIEW (column)); mx_label_set_text (MX_LABEL (column->priv->label), label ? label : ""); }
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), ""); } }
static void ntf_tray_notification_closed_cb (NtfNotification *ntf, NtfTray *tray) { NtfTrayPrivate *priv = tray->priv; ClutterActor *ntfa = CLUTTER_ACTOR (ntf); ClutterAnimation *anim; priv->n_notifiers--; if (priv->n_notifiers < 0) { g_warning ("Bug in notifier accounting, attempting to fix"); priv->n_notifiers = 0; } /* fade out closed notifier */ if (ntfa == priv->active_notifier) { anim = clutter_actor_animate (CLUTTER_ACTOR (ntfa), CLUTTER_EASE_IN_SINE, FADE_DURATION, "opacity", 0, NULL); g_signal_connect_after (anim, "completed", G_CALLBACK (ntf_tray_hide_ntf_completed_cb), tray); } else { clutter_actor_destroy (ntfa); } /* Fade in newer notifier from below stack */ if (ntfa == priv->active_notifier && priv->n_notifiers > 0) { gint prev_height, new_height; GList *notifiers; prev_height = clutter_actor_get_height (ntfa); notifiers = clutter_container_get_children (CLUTTER_CONTAINER (priv->notifiers)); priv->active_notifier = notifiers->next != NULL ? (ClutterActor *) notifiers->next->data : NULL; g_list_free (notifiers); if (priv->active_notifier) { clutter_actor_set_opacity (priv->active_notifier, 0); clutter_actor_show (CLUTTER_ACTOR (priv->active_notifier)); clutter_actor_animate (CLUTTER_ACTOR (priv->active_notifier), CLUTTER_EASE_IN_SINE, FADE_DURATION, "opacity", 0xff, NULL); new_height = clutter_actor_get_height (priv->active_notifier); if (prev_height != new_height && priv->n_notifiers > 1) { gfloat new_y; new_y = clutter_actor_get_y (priv->control) - (prev_height - new_height); clutter_actor_animate (priv->control, CLUTTER_EASE_IN_SINE, FADE_DURATION, "y", new_y, NULL); } } } if (priv->n_notifiers == 0) { priv->active_notifier = NULL; #pragma TODO /* mnb_notification_gtk_hide (); */ } else if (priv->n_notifiers == 1) { /* slide the control out of view */ ClutterAnimation *anim; anim = clutter_actor_animate (priv->control, CLUTTER_EASE_IN_SINE, FADE_DURATION, "opacity", 0x0, "y", clutter_actor_get_height (priv->active_notifier) - clutter_actor_get_height (priv->control), NULL); g_signal_connect_after (anim, "completed", G_CALLBACK (ntf_tray_control_hide_completed_cb), tray); } else { /* Just Update control text */ gchar *msg; msg = g_strdup_printf (_("%i pending messages"), priv->n_notifiers); mx_label_set_text (MX_LABEL (priv->control_text), msg); g_free (msg); } }
static void add_pictures (ClutterActor *box) { GList *files = get_pictures (); while (files) { gint w, h, i; ClutterActor *drawer, *drawer2, *tile, *texture, *menu, *description; gchar *file = files->data; /* Create texture */ texture = clutter_texture_new_from_file (file, NULL); clutter_texture_get_base_size (CLUTTER_TEXTURE (texture), &w, &h); clutter_actor_set_size (texture, 300, 300.0/w * h); /* Create menu */ menu = mx_box_layout_new (); mx_box_layout_set_orientation (MX_BOX_LAYOUT (menu), MX_ORIENTATION_VERTICAL); for (i = 0; i < 4; i++) { ClutterActor *button, *layout, *icon, *label; button = mx_button_new (); layout = mx_box_layout_new (); icon = mx_icon_new (); label = mx_label_new (); mx_box_layout_set_spacing (MX_BOX_LAYOUT (layout), 8); mx_icon_set_icon_size (MX_ICON (icon), 16); clutter_actor_set_size (icon, 16, 16); clutter_container_add (CLUTTER_CONTAINER (layout), icon, label, NULL); mx_bin_set_child (MX_BIN (button), layout); mx_bin_set_alignment (MX_BIN (button), MX_ALIGN_START, MX_ALIGN_MIDDLE); clutter_container_add_actor (CLUTTER_CONTAINER (menu), button); mx_box_layout_child_set_x_fill (MX_BOX_LAYOUT (menu), button, TRUE); switch (i) { case 0: mx_icon_set_icon_name (MX_ICON (icon), "dialog-information"); mx_label_set_text (MX_LABEL (label), "This"); break; case 1: mx_icon_set_icon_name (MX_ICON (icon), "dialog-question"); mx_label_set_text (MX_LABEL (label), "is"); break; case 2: mx_icon_set_icon_name (MX_ICON (icon), "dialog-warning"); mx_label_set_text (MX_LABEL (label), "a"); break; case 3: mx_icon_set_icon_name (MX_ICON (icon), "dialog-error"); mx_label_set_text (MX_LABEL (label), "menu"); break; } } /* Create description */ description = mx_label_new_with_text ("Here you could put a very " "long description of whatever " "is above it. Or you could put " "another focusable widget here " "and it'd be navigable, like " "the menu on the right. Whoo!"); clutter_text_set_line_wrap ((ClutterText *)mx_label_get_clutter_text ( MX_LABEL (description)), TRUE); drawer = mex_expander_box_new (); mex_expander_box_set_important_on_focus (MEX_EXPANDER_BOX (drawer), TRUE); drawer2 = mex_expander_box_new (); mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (drawer2), MEX_EXPANDER_BOX_RIGHT); mex_expander_box_set_important (MEX_EXPANDER_BOX (drawer2), TRUE); tile = mex_tile_new_with_label (file); mex_tile_set_important (MEX_TILE (tile), TRUE); mx_bin_set_child (MX_BIN (tile), texture); clutter_container_add (CLUTTER_CONTAINER (drawer2), tile, menu, NULL); clutter_container_add (CLUTTER_CONTAINER (drawer), drawer2, description, NULL); g_signal_connect (drawer, "notify::open", G_CALLBACK (sync_drawer2_cb), drawer2); clutter_container_add_actor (CLUTTER_CONTAINER (box), drawer); clutter_actor_set_reactive (texture, TRUE); g_signal_connect (texture, "enter-event", G_CALLBACK (texture_enter_cb), drawer); g_signal_connect (texture, "leave-event", G_CALLBACK (texture_leave_cb), drawer); g_signal_connect (texture, "button-press-event", G_CALLBACK (texture_clicked_cb), drawer); g_free (file); files = g_list_delete_link (files, files); } }
void ntf_tray_add_notification (NtfTray *tray, NtfNotification *ntf) { NtfTrayPrivate *priv; ClutterActor *ntfa; MetaPlugin *plugin; g_return_if_fail (NTF_IS_TRAY (tray) && NTF_IS_NOTIFICATION (ntf)); priv = tray->priv; ntfa = CLUTTER_ACTOR (ntf); plugin = dawati_netbook_get_plugin_singleton (); if (dawati_netbook_compositor_disabled (plugin)) { #pragma TODO /* mnb_notification_gtk_show (); */ } g_signal_connect (ntf, "closed", G_CALLBACK (ntf_tray_notification_closed_cb), tray); clutter_actor_add_child (priv->notifiers, ntfa); priv->n_notifiers++; if (priv->n_notifiers == 1) { /* May have been previously hidden */ clutter_actor_show (CLUTTER_ACTOR (tray)); /* show just the single notification */ priv->active_notifier = ntfa; clutter_actor_set_opacity (ntfa, 0); clutter_actor_animate (ntfa, CLUTTER_EASE_IN_SINE, FADE_DURATION, "opacity", 0xff, NULL); } else if (priv->n_notifiers == 2) { /* slide the control into view */ mx_label_set_text (MX_LABEL(priv->control_text), _("1 pending message")); clutter_actor_show (priv->control); clutter_actor_set_opacity (priv->control, 0); clutter_actor_set_y (priv->control, clutter_actor_get_height (priv->active_notifier) - clutter_actor_get_height (priv->control) - 30); clutter_actor_animate (priv->control, CLUTTER_EASE_IN_SINE, FADE_DURATION, "opacity", 0xff, "y", clutter_actor_get_height (priv->active_notifier)- 30, NULL); } else { /* simply update the control */ gchar *msg; msg = g_strdup_printf (_("%i pending messages"), priv->n_notifiers-1); mx_label_set_text (MX_LABEL (priv->control_text), msg); g_free (msg); } }
/* * Volume is a value from 0.0 to 1.0 */ static void update_volume_label (MpdVolumeTile *self, double volume) { MpdVolumeTilePrivate *priv = GET_PRIVATE (self); char *old_level; float label_width; float slider_width; float x; g_return_if_fail (0.0 <= volume && volume <= 1.0); old_level = g_strdup (mx_label_get_text (MX_LABEL (priv->volume_label))); /* Label text */ if (volume == 1.0) mx_label_set_text (MX_LABEL (priv->volume_label), _("Turned up to 11")); else if (volume >= 0.90) mx_label_set_text (MX_LABEL (priv->volume_label), _("Very loud")); else if (volume >= 0.75) mx_label_set_text (MX_LABEL (priv->volume_label), _("Loud")); else if (volume > 0.50) mx_label_set_text (MX_LABEL (priv->volume_label), _("Fairly loud")); else if (volume == 0.50) mx_label_set_text (MX_LABEL (priv->volume_label), _("Middle of the road")); else if (volume >= 0.25) mx_label_set_text (MX_LABEL (priv->volume_label), _("Fairly quiet")); else if (volume >= 0.10) mx_label_set_text (MX_LABEL (priv->volume_label), _("Quiet")); else if (volume > 0.0) mx_label_set_text (MX_LABEL (priv->volume_label), _("Very quiet")); else mx_label_set_text (MX_LABEL (priv->volume_label), _("Silent")); /* Label position */ label_width = clutter_actor_get_width (priv->volume_label); slider_width = clutter_actor_get_width (priv->volume_slider); x = slider_width * volume - label_width / 2; x = CLAMP (x, 0.0, slider_width - label_width); clutter_actor_set_x (priv->volume_label, x); /* Notification */ if (0 != g_strcmp0 (old_level, mx_label_get_text (MX_LABEL (priv->volume_label)))) { gint res; ca_proplist *proplist; ca_context *context; if (g_atomic_int_get (&priv->playing_event_sound) > 0) return; context = ca_gtk_context_get (); ca_proplist_create (&proplist); ca_proplist_sets (proplist, CA_PROP_EVENT_ID, VOLUME_CHANGED_EVENT); res = ca_context_play_full (context, 1, proplist, (ca_finish_callback_t )_play_sound_completed_cb, self); ca_proplist_destroy (proplist); if (res != CA_SUCCESS) { g_warning ("%s: Error playing test sound: %s", G_STRLOC, ca_strerror (res)); } else { g_atomic_int_inc (&priv->playing_event_sound); } } g_free (old_level); }