diff options
author | Étienne Deparis <[email protected]> | 2019-04-29 13:52:20 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-05-10 10:18:54 +0200 |
commit | 818039f9d1d53121f38477872d909a54075fd8cf (patch) | |
tree | a917aabf4da714ed220bb9bc10635f3b0f0b3d84 /mate-window-picker-applet | |
parent | 01abe1ac0db047a07f4f5a71352a422d17d4c31d (diff) | |
download | mate-netbook-818039f9d1d53121f38477872d909a54075fd8cf.tar.bz2 mate-netbook-818039f9d1d53121f38477872d909a54075fd8cf.tar.xz |
Add an option to disable the bold face of the window title in applet
Diffstat (limited to 'mate-window-picker-applet')
-rw-r--r-- | mate-window-picker-applet/applet.c | 37 | ||||
-rw-r--r-- | mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in | 5 | ||||
-rw-r--r-- | mate-window-picker-applet/task-title.c | 57 |
3 files changed, 92 insertions, 7 deletions
diff --git a/mate-window-picker-applet/applet.c b/mate-window-picker-applet/applet.c index 8f06693..34408c0 100644 --- a/mate-window-picker-applet/applet.c +++ b/mate-window-picker-applet/applet.c @@ -41,6 +41,7 @@ #define APPLET_SCHEMA "org.mate.panel.applet.mate-window-picker-applet" #define SHOW_WIN_KEY "show-all-windows" #define SHOW_HOME_TITLE_KEY "show-home-title" +#define BOLD_WINDOW_TITLE_KEY "bold-window-title" typedef struct { @@ -104,6 +105,20 @@ on_show_home_title_changed (GSettings *settings, g_object_set (app->title, "show_home_title", show_home, NULL); } +static void +on_bold_window_title_changed (GSettings *settings, + gchar *key, + gpointer data) +{ + WinPickerApp *app; + gboolean bold_win = TRUE; + + app = (WinPickerApp*)data; + + bold_win = g_settings_get_boolean (settings, BOLD_WINDOW_TITLE_KEY); + g_object_set (app->title, "bold_window_title", bold_win, NULL); +} + static inline void force_no_focus_padding (GtkWidget *widget) { @@ -171,6 +186,8 @@ cw_applet_fill (MatePanelApplet *applet, G_CALLBACK (on_show_all_windows_changed), app); g_signal_connect (app->settings, "changed::" SHOW_HOME_TITLE_KEY, G_CALLBACK (on_show_home_title_changed), app); + g_signal_connect (app->settings, "changed::" BOLD_WINDOW_TITLE_KEY, + G_CALLBACK (on_bold_window_title_changed), app); app->applet = GTK_WIDGET (applet); force_no_focus_padding (GTK_WIDGET (applet)); @@ -190,6 +207,7 @@ cw_applet_fill (MatePanelApplet *applet, on_show_all_windows_changed (app->settings, SHOW_WIN_KEY, app); on_show_home_title_changed (app->settings, SHOW_HOME_TITLE_KEY, app); + on_bold_window_title_changed (app->settings, BOLD_WINDOW_TITLE_KEY, app); action_group = gtk_action_group_new ("MateWindowPicker Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); @@ -266,6 +284,16 @@ on_show_home_title_checkbox_toggled (GtkToggleButton *check, gpointer null) } static void +on_bold_window_title_checkbox_toggled (GtkToggleButton *check, gpointer null) +{ + gboolean is_active; + + is_active = gtk_toggle_button_get_active (check); + + g_settings_set_boolean (mainapp->settings, BOLD_WINDOW_TITLE_KEY, is_active); +} + +static void display_prefs_dialog (GtkAction *action, WinPickerApp *applet) { @@ -307,6 +335,15 @@ display_prefs_dialog (GtkAction *action, g_signal_connect (check, "toggled", G_CALLBACK (on_show_home_title_checkbox_toggled), NULL); + check = gtk_check_button_new_with_label (_("Bold windows title")); + gtk_widget_set_tooltip_text (GTK_WIDGET (check), + _("Show windows title with a bold face.")); + gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), + g_settings_get_boolean (mainapp->settings, BOLD_WINDOW_TITLE_KEY)); + g_signal_connect (check, "toggled", + G_CALLBACK (on_bold_window_title_checkbox_toggled), NULL); + check = gtk_label_new (" "); gtk_box_pack_start (GTK_BOX (vbox), check, TRUE, TRUE, 0); diff --git a/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in b/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in index f3af64c..ca69d62 100644 --- a/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in +++ b/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in @@ -10,5 +10,10 @@ <summary>Show desktop title and logout button</summary> <description>Show a title for the desktop when no window is selected, and append a logout button.</description> </key> + <key name="bold-window-title" type="b"> + <default>true</default> + <summary>Bold windows title</summary> + <description>Show windows title with a bold face.</description> + </key> </schema> </schemalist> diff --git a/mate-window-picker-applet/task-title.c b/mate-window-picker-applet/task-title.c index 15c4247..1f0ed7c 100644 --- a/mate-window-picker-applet/task-title.c +++ b/mate-window-picker-applet/task-title.c @@ -45,13 +45,15 @@ struct _TaskTitlePrivate GdkPixbuf *quit_icon; gboolean show_home_title; + gboolean bold_window_title; gboolean mouse_in_close_button; }; enum { PROP_0, - PROP_SHOW_HOME_TITLE + PROP_SHOW_HOME_TITLE, + PROP_BOLD_WINDOW_TITLE }; static void disconnect_window (TaskTitle *title); @@ -431,6 +433,29 @@ task_title_set_show_home_title (TaskTitle *title, gboolean show_home_title) } static void +task_title_set_bold_window_title (TaskTitle *title, gboolean bold_window_title) +{ + TaskTitlePrivate *priv = title->priv; + + priv->bold_window_title = bold_window_title; + + g_debug ("Bold window title: %s", bold_window_title ? "true" : "false"); + + PangoAttribute *attr; + PangoAttrList *attr_list = pango_attr_list_new (); + if (priv->bold_window_title) + { + attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); + } + else + { + attr = pango_attr_weight_new (PANGO_WEIGHT_NORMAL); + } + pango_attr_list_insert (attr_list, attr); + gtk_label_set_attributes (GTK_LABEL (priv->label), attr_list); +} + +static void task_title_get_property (GObject *object, guint prop_id, GValue *value, @@ -447,6 +472,9 @@ task_title_get_property (GObject *object, case PROP_SHOW_HOME_TITLE: g_value_set_boolean (value, priv->show_home_title); break; + case PROP_BOLD_WINDOW_TITLE: + g_value_set_boolean (value, priv->bold_window_title); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -467,6 +495,9 @@ task_title_set_property (GObject *object, case PROP_SHOW_HOME_TITLE: task_title_set_show_home_title (title, g_value_get_boolean (value)); break; + case PROP_BOLD_WINDOW_TITLE: + task_title_set_bold_window_title (title, g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -503,6 +534,14 @@ task_title_class_init (TaskTitleClass *klass) FALSE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (obj_class, + PROP_BOLD_WINDOW_TITLE, + g_param_spec_boolean ("bold_window_title", + "Bold Window Title", + "Show windows title with a bold face", + TRUE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + wid_class->draw = on_draw; g_type_class_add_private (obj_class, sizeof (TaskTitlePrivate)); @@ -525,6 +564,7 @@ task_title_init (TaskTitle *title) // Default values priv->show_home_title = FALSE; + priv->bold_window_title = TRUE; gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK); @@ -542,12 +582,15 @@ task_title_init (TaskTitle *title) gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END); gtk_widget_set_halign (priv->label, GTK_ALIGN_START); gtk_widget_set_valign (priv->label, GTK_ALIGN_CENTER); - - PangoAttrList *attr_list = pango_attr_list_new (); - PangoAttribute *attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); - pango_attr_list_insert (attr_list, attr); - gtk_label_set_attributes (GTK_LABEL (priv->label), attr_list); - + + if (priv->bold_window_title) + { + PangoAttrList *attr_list = pango_attr_list_new (); + PangoAttribute *attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); + pango_attr_list_insert (attr_list, attr); + gtk_label_set_attributes (GTK_LABEL (priv->label), attr_list); + } + gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0); gtk_widget_show (priv->label); |