diff options
author | Zhang Xianwei <[email protected]> | 2018-11-11 04:23:55 -0500 |
---|---|---|
committer | lukefromdc <[email protected]> | 2018-11-14 21:10:59 +0000 |
commit | 9e7a5675cd0efb6c939ca8ed81eaee96065a7ded (patch) | |
tree | 083d786502c59e86178ad53de27fd6e2388c7295 /plugins | |
parent | ea4ab83ceee857effdf90f79f00ec9335a5181a5 (diff) | |
download | mate-settings-daemon-9e7a5675cd0efb6c939ca8ed81eaee96065a7ded.tar.bz2 mate-settings-daemon-9e7a5675cd0efb6c939ca8ed81eaee96065a7ded.tar.xz |
media-keys: Add labels for the rfkill OSD
Which should hopefully make the icons a bit clearer.
Signed-off-by: Zhang Xianwei <[email protected]>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/media-keys/acme.ui | 12 | ||||
-rw-r--r-- | plugins/media-keys/msd-media-keys-manager.c | 32 | ||||
-rw-r--r-- | plugins/media-keys/msd-media-keys-window.c | 60 | ||||
-rw-r--r-- | plugins/media-keys/msd-media-keys-window.h | 3 | ||||
-rw-r--r-- | plugins/media-keys/test-media-window.c | 9 |
5 files changed, 98 insertions, 18 deletions
diff --git a/plugins/media-keys/acme.ui b/plugins/media-keys/acme.ui index e0457ed..a5d1765 100644 --- a/plugins/media-keys/acme.ui +++ b/plugins/media-keys/acme.ui @@ -18,13 +18,23 @@ </packing> </child> <child> + <object class="GtkLabel" id="acme_label"> + <property name="visible">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> <object class="GtkProgressBar" id="acme_volume_progressbar"> <property name="visible">True</property> </object> <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index c267166..de37532 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -581,7 +581,8 @@ do_eject_action (MsdMediaKeysManager *manager) /* Show the dialogue */ dialog_init (manager); msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), - "media-eject"); + "media-eject", + NULL); dialog_show (manager); /* Clean up the drive selection and exit if no suitable @@ -606,7 +607,8 @@ do_touchpad_osd_action (MsdMediaKeysManager *manager, gboolean state) { dialog_init (manager); msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), - state ? "input-touchpad" : "touchpad-disabled"); + state ? "input-touchpad" : "touchpad-disabled", + NULL); dialog_show (manager); } @@ -844,14 +846,21 @@ set_rfkill_complete (GObject *object, g_debug ("Finished changing rfkill, property %s is now %s", data->property, data->target_state ? "true" : "false"); - if (data->bluetooth) - msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (data->manager->priv->dialog), - data->target_state ? "bluetooth-disabled-symbolic" - : "bluetooth-active-symbolic"); - else - msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (data->manager->priv->dialog), - data->target_state ? "airplane-mode-symbolic" - : "network-wireless-signal-excellent-symbolic"); + if (data->bluetooth){ + if (data->target_state) + msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (data->manager->priv->dialog), + "bluetooth-disabled-symbolic", _("Bluetooth disabled")); + else + msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (data->manager->priv->dialog), + "bluetooth-active-symbolic", _("Bluetooth enabled")); + } else { + if (data->target_state) + msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (data->manager->priv->dialog), + "airplane-mode-symbolic", _("Airplane mode enabled")); + else + msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (data->manager->priv->dialog), + "network-wireless-signal-excellent-symbolic", _("Airplane mode disabled")); + } dialog_show (data->manager); out: g_free (data->property); @@ -880,7 +889,8 @@ do_rfkill_action (MsdMediaKeysManager *manager, if (get_rfkill_property (manager, hw_mode)) { msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), - "airplane-mode-symbolic"); + "airplane-mode-symbolic", + _("Hardware Airplane Mode")); dialog_show (manager); return; } diff --git a/plugins/media-keys/msd-media-keys-window.c b/plugins/media-keys/msd-media-keys-window.c index b1cfdc1..2fd6297 100644 --- a/plugins/media-keys/msd-media-keys-window.c +++ b/plugins/media-keys/msd-media-keys-window.c @@ -38,12 +38,14 @@ struct MsdMediaKeysWindowPrivate { MsdMediaKeysWindowAction action; char *icon_name; + char *description; guint volume_muted : 1; int volume_level; GtkImage *image; GtkWidget *progress; + GtkWidget *label; }; G_DEFINE_TYPE (MsdMediaKeysWindow, msd_media_keys_window, MSD_TYPE_OSD_WINDOW) @@ -63,6 +65,18 @@ volume_controls_set_visible (MsdMediaKeysWindow *window, } static void +description_label_set_visible (MsdMediaKeysWindow *window, + gboolean visible) +{ + if (visible) { + gtk_label_set_text (GTK_LABEL (window->priv->label), window->priv->description); + gtk_widget_show (window->priv->label); + } else { + gtk_widget_hide (window->priv->label); + } +} + +static void window_set_icon_name (MsdMediaKeysWindow *window, const char *name) { @@ -80,6 +94,7 @@ action_changed (MsdMediaKeysWindow *window) switch (window->priv->action) { case MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME: volume_controls_set_visible (window, TRUE); + description_label_set_visible (window, FALSE); if (window->priv->volume_muted) { window_set_icon_name (window, "audio-volume-muted"); @@ -90,6 +105,7 @@ action_changed (MsdMediaKeysWindow *window) break; case MSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM: volume_controls_set_visible (window, FALSE); + description_label_set_visible (window, TRUE); window_set_icon_name (window, window->priv->icon_name); break; default: @@ -147,16 +163,20 @@ msd_media_keys_window_set_action (MsdMediaKeysWindow *window, void msd_media_keys_window_set_action_custom (MsdMediaKeysWindow *window, - const char *icon_name) + const char *icon_name, + const char *description) { g_return_if_fail (MSD_IS_MEDIA_KEYS_WINDOW (window)); g_return_if_fail (icon_name != NULL); if (window->priv->action != MSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM || - g_strcmp0 (window->priv->icon_name, icon_name) != 0) { + g_strcmp0 (window->priv->icon_name, icon_name) != 0 || + g_strcmp0 (window->priv->description, description) != 0) { window->priv->action = MSD_MEDIA_KEYS_WINDOW_ACTION_CUSTOM; g_free (window->priv->icon_name); window->priv->icon_name = g_strdup (icon_name); + g_free (window->priv->description); + window->priv->description = g_strdup (description); action_changed (window); } else { msd_osd_window_update_and_hide (MSD_OSD_WINDOW (window)); @@ -389,6 +409,23 @@ render_speaker (MsdMediaKeysWindow *window, } static void +draw_description_label (MsdMediaKeysWindow *window, + cairo_t *cr, + double _y0, + double width) +{ + cairo_text_extents_t extents; + + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_set_font_size (cr, 14); + + /* centered text */ + cairo_text_extents (cr, window->priv->description, &extents); + cairo_move_to (cr, width / 2 - extents.width / 2, _y0); + cairo_show_text (cr, window->priv->description); +} + +static void draw_volume_boxes (MsdMediaKeysWindow *window, cairo_t *cr, double percentage, @@ -574,15 +611,21 @@ draw_action_custom (MsdMediaKeysWindow *window, double icon_box_height; double icon_box_x0; double icon_box_y0; + double label_box_y0; + double label_box_width; + double label_box_height; gboolean res; gtk_window_get_size (GTK_WINDOW (window), &window_width, &window_height); icon_box_width = round (window_width * 0.65); icon_box_height = round (window_height * 0.65); + label_box_width = round (window_width); + label_box_height = round (window_height * 0.175); icon_box_x0 = (window_width - icon_box_width) / 2; icon_box_y0 = (window_height - icon_box_height) / 2; + label_box_y0 = round (window_height - label_box_height / 2); #if 0 g_message ("icon box: w=%f h=%f _x0=%f _y0=%f", @@ -590,6 +633,10 @@ draw_action_custom (MsdMediaKeysWindow *window, icon_box_height, icon_box_x0, icon_box_y0); + g_message ("label box: w=%f h=%f _x0=0.0 _y0=%f", + label_box_width, + label_box_height, + label_box_y0); #endif res = render_custom (window, @@ -602,6 +649,14 @@ draw_action_custom (MsdMediaKeysWindow *window, icon_box_x0, icon_box_y0, icon_box_width, icon_box_height); } + + if (window->priv->description != NULL) { + /* draw description label meter */ + draw_description_label (window, + cr, + label_box_y0, + label_box_width); + } } static void @@ -650,6 +705,7 @@ msd_media_keys_window_init (MsdMediaKeysWindow *window) window->priv->image = GTK_IMAGE (gtk_builder_get_object (builder, "acme_image")); window->priv->progress = GTK_WIDGET (gtk_builder_get_object (builder, "acme_volume_progressbar")); + window->priv->label = GTK_WIDGET (gtk_builder_get_object (builder, "acme_label")); box = GTK_WIDGET (gtk_builder_get_object (builder, "acme_box")); if (box != NULL) { diff --git a/plugins/media-keys/msd-media-keys-window.h b/plugins/media-keys/msd-media-keys-window.h index 51489ad..228da32 100644 --- a/plugins/media-keys/msd-media-keys-window.h +++ b/plugins/media-keys/msd-media-keys-window.h @@ -63,7 +63,8 @@ GtkWidget * msd_media_keys_window_new (void); void msd_media_keys_window_set_action (MsdMediaKeysWindow *window, MsdMediaKeysWindowAction action); void msd_media_keys_window_set_action_custom (MsdMediaKeysWindow *window, - const char *icon_name); + const char *icon_name, + const char *description); void msd_media_keys_window_set_volume_muted (MsdMediaKeysWindow *window, gboolean muted); void msd_media_keys_window_set_volume_level (MsdMediaKeysWindow *window, diff --git a/plugins/media-keys/test-media-window.c b/plugins/media-keys/test-media-window.c index 40e5b6c..c716c3d 100644 --- a/plugins/media-keys/test-media-window.c +++ b/plugins/media-keys/test-media-window.c @@ -63,19 +63,22 @@ update_state (GtkWidget *window) break; case 4: msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window), - "media-eject"); + "media-eject", + NULL); gtk_widget_show (window); break; case 5: msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window), - "touchpad-disabled"); + "touchpad-disabled", + NULL); gtk_widget_show (window); break; case 6: msd_media_keys_window_set_action_custom (MSD_MEDIA_KEYS_WINDOW (window), - "input-touchpad"); + "input-touchpad", + NULL); gtk_widget_show (window); break; |