diff --git a/panel-plugin/buttons/wckbuttons-dialogs.glade b/panel-plugin/buttons/wckbuttons-dialogs.glade index 1df09277e4eba6525ebe47a51da4e94a65f84d70..0885c66b0f3a30d1e36238265a25de2a9f4a8cd1 100644 --- a/panel-plugin/buttons/wckbuttons-dialogs.glade +++ b/panel-plugin/buttons/wckbuttons-dialogs.glade @@ -117,7 +117,7 @@ <property name="spacing">6</property> <child> <object class="GtkCheckButton" id="sync_wm_theme"> - <property name="label" translatable="yes">Sync it with the window manager theme.</property> + <property name="label" translatable="yes">Get in sync with the window manager theme.</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> diff --git a/panel-plugin/title/windowck-dialogs.c b/panel-plugin/title/windowck-dialogs.c index 213771cced1023184e6cb1e07d11011f88992d48..7e31db5c6f9b1a04d0f5a5e4bed771cfd9ba6121 100644 --- a/panel-plugin/title/windowck-dialogs.c +++ b/panel-plugin/title/windowck-dialogs.c @@ -168,26 +168,29 @@ static void on_show_window_menu_toggled(GtkToggleButton *show_window_menu, Windo } -static void on_custom_font_toggled(GtkToggleButton *custom_font, WindowckPlugin *wckp) +static void on_sync_wm_font_toggled(GtkToggleButton *sync_wm_font, WindowckPlugin *wckp) { - GtkWidget *title_font; - - title_font = GTK_WIDGET (gtk_builder_get_object (wckp->prefs->builder, "title_font")); - - wckp->prefs->custom_font = gtk_toggle_button_get_active (custom_font); - if (wckp->prefs->custom_font) - gtk_widget_set_sensitive(title_font, TRUE ); - else - gtk_widget_set_sensitive(title_font, FALSE ); + GtkFontButton *title_font; - update_font(wckp); + wckp->prefs->sync_wm_font = gtk_toggle_button_get_active (sync_wm_font); + init_title (wckp); + title_font = GTK_FONT_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "title_font")); + gtk_font_button_set_font_name(title_font, wckp->prefs->title_font); } static void on_title_font_font_set(GtkFontButton *title_font, WindowckPlugin *wckp) { + PangoFontDescription *font; + wckp->prefs->title_font = g_strdup(gtk_font_button_get_font_name(title_font)); - update_font(wckp); + + font = pango_font_description_from_string(wckp->prefs->title_font); + gtk_widget_modify_font(GTK_WIDGET(wckp->title), font); + pango_font_description_free(font); + + if (wckp->prefs->sync_wm_font) + xfconf_channel_set_string (wckp->wm_channel, "/general/title_font", wckp->prefs->title_font); } static void on_title_alignment_changed (GtkComboBox *title_alignment, WindowckPlugin *wckp) @@ -233,7 +236,7 @@ static GtkWidget * build_properties_area(WindowckPlugin *wckp, const gchar *buff GObject *area = NULL; GtkSpinButton *titlesize, *title_padding; GtkComboBox *size_mode, *title_alignment; - GtkToggleButton *custom_font; + GtkToggleButton *sync_wm_font; GtkRadioButton *only_maximized, *active_window; GtkToggleButton *show_on_desktop, *full_name; GtkToggleButton *show_app_icon, *icon_on_right, *show_window_menu; @@ -328,19 +331,22 @@ static GtkWidget * build_properties_area(WindowckPlugin *wckp, const gchar *buff DBG("No widget with the name \"titlesize\" found"); } - custom_font = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "custom_font")); + sync_wm_font = GTK_TOGGLE_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "sync_wm_font")); title_font = GTK_FONT_BUTTON(gtk_builder_get_object(wckp->prefs->builder, "title_font")); - if (!wckp->prefs->custom_font) - gtk_widget_set_sensitive(GTK_WIDGET(title_font), FALSE ); - - if (G_LIKELY (custom_font != NULL)) + if (G_LIKELY (sync_wm_font != NULL)) { - gtk_toggle_button_set_active(custom_font, wckp->prefs->custom_font); - g_signal_connect(custom_font, "toggled", G_CALLBACK(on_custom_font_toggled), wckp); + if (wckp->wm_channel) + { + gtk_toggle_button_set_active(sync_wm_font, wckp->prefs->sync_wm_font); + g_signal_connect(sync_wm_font, "toggled", G_CALLBACK(on_sync_wm_font_toggled), wckp); + } + else { + gtk_widget_set_sensitive (GTK_WIDGET(sync_wm_font), FALSE); + } } else { - DBG("No widget with the name \"custom_font\" found"); + DBG("No widget with the name \"sync_wm_font\" found"); } if (G_LIKELY (title_font != NULL)) diff --git a/panel-plugin/title/windowck-dialogs.glade b/panel-plugin/title/windowck-dialogs.glade index d6defcd6a98fc45d520a99273efb1eeb0b822c2d..cad883dce7b55ff0eec8efefd710ac87d3bb27e0 100644 --- a/panel-plugin/title/windowck-dialogs.glade +++ b/panel-plugin/title/windowck-dialogs.glade @@ -183,6 +183,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="xalign">0</property> + <property name="xpad">2</property> <property name="label" translatable="yes">Width:</property> <attributes> <attribute name="weight" value="normal"/> @@ -258,49 +259,6 @@ </child> <child> <object class="GtkHBox" id="hbox2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">4</property> - <child> - <object class="GtkLabel" id="title_alignment_label"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Alignment:</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="title_alignment"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="model">title_alignment_list</property> - <child> - <object class="GtkCellRendererText" id="cellrenderertext1"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">5</property> - </packing> - </child> - <child> - <object class="GtkHBox" id="hbox3"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">5</property> @@ -309,6 +267,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="xalign">0</property> + <property name="xpad">2</property> <property name="label" translatable="yes">Padding:</property> </object> <packing> @@ -357,22 +316,21 @@ <packing> <property name="expand">True</property> <property name="fill">True</property> - <property name="position">6</property> + <property name="position">5</property> </packing> </child> <child> - <object class="GtkHBox" id="hbox4"> + <object class="GtkHBox" id="hbox3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">5</property> + <property name="spacing">4</property> <child> - <object class="GtkLabel" id="title_font_label"> + <object class="GtkLabel" id="title_alignment_label"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="xalign">0</property> - <property name="ypad">1</property> - <property name="label" translatable="yes">Font style:</property> - <property name="justify">fill</property> + <property name="xpad">2</property> + <property name="label" translatable="yes">Alignment:</property> </object> <packing> <property name="expand">False</property> @@ -381,13 +339,16 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="custom_font"> - <property name="label" translatable="yes">custom</property> + <object class="GtkComboBox" id="title_alignment"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> + <property name="can_focus">False</property> + <property name="model">title_alignment_list</property> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> </object> <packing> <property name="expand">False</property> @@ -395,18 +356,68 @@ <property name="position">1</property> </packing> </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">6</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="font"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">out</property> <child> - <object class="GtkFontButton" id="title_font"> + <object class="GtkAlignment" id="alignment3"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="font_name">sans 10</property> + <property name="can_focus">False</property> + <property name="left_padding">12</property> + <child> + <object class="GtkVBox" id="vbox3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="sync_wm_font"> + <property name="label" translatable="yes">Get in sync with the window manager.</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFontButton" id="title_font"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="font_name">sans 10</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="font_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Font</property> + <property name="use_markup">True</property> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> </child> </object> <packing> diff --git a/panel-plugin/title/windowck-title.c b/panel-plugin/title/windowck-title.c index 070c2d5ab2ad972df693c215ec55d8f5f22e794a..5c18cb851e4ef47fe7f4738bf13d50ea1ff1e588 100644 --- a/panel-plugin/title/windowck-title.c +++ b/panel-plugin/title/windowck-title.c @@ -40,21 +40,6 @@ void reload_wnck_title (WindowckPlugin *wckp) } -void update_font(WindowckPlugin *wckp) -{ - PangoFontDescription *font; - if (wckp->prefs->custom_font) - { - font = pango_font_description_from_string(wckp->prefs->title_font); - gtk_widget_modify_font(GTK_WIDGET(wckp->title), font); - pango_font_description_free(font); - } - else { - gtk_widget_modify_font(GTK_WIDGET(wckp->title), NULL); - } -} - - static void on_icon_changed(WnckWindow *controlwindow, WindowckPlugin *wckp) { GdkPixbuf *pixbuf = NULL; @@ -132,10 +117,7 @@ static void on_name_changed (WnckWindow *controlwindow, WindowckPlugin *wckp) title_color = wckp->prefs->inactive_text_color; } - if (wckp->prefs->custom_font) title_font = wckp->prefs->title_font; - else - title_font = ""; /* Set tooltips */ if (wckp->prefs->show_tooltips) @@ -344,6 +326,20 @@ static void set_title_colors(WindowckPlugin *wckp) } +static void apply_wm_settings (WindowckPlugin *wckp) +{ + const gchar *wm_theme = xfconf_channel_get_string (wckp->wm_channel, "/general/theme", NULL); + + if (G_LIKELY(wm_theme)) + { + const gchar *wm_title_font = xfconf_channel_get_string (wckp->wm_channel, "/general/title_font", wckp->prefs->title_font); + wckp->prefs->title_font = g_strdup (wm_title_font); + + on_name_changed (wckp->win->controlwindow, wckp); + } +} + + static void on_x_chanel_property_changed (XfconfChannel *x_channel, const gchar *property_name, const GValue *value, WindowckPlugin *wckp) { @@ -367,6 +363,33 @@ on_x_chanel_property_changed (XfconfChannel *x_channel, const gchar *property_na } +static void on_xfwm_channel_property_changed (XfconfChannel *wm_channel, const gchar *property_name, const GValue *value, WindowckPlugin *wckp) +{ + if (g_str_has_prefix(property_name, "/general/") == TRUE) + { + const gchar *name = &property_name[9]; + switch (G_VALUE_TYPE(value)) + { + case G_TYPE_STRING: + if (!strcmp (name, "title_font") + || !strcmp (name, "show_app_icon")) + { + apply_wm_settings (wckp); + } + else if (!strcmp (name, "theme")) + { + init_title(wckp); + reload_wnck_title (wckp); + } + break; + default: + g_warning("The property '%s' is not supported", property_name); + break; + } + } +} + + void init_title (WindowckPlugin *wckp) { set_title_colors(wckp); @@ -378,6 +401,16 @@ void init_title (WindowckPlugin *wckp) if (wckp->prefs->size_mode != SHRINK) gtk_misc_set_alignment(GTK_MISC(wckp->title), wckp->prefs->title_alignment / 10.0, 0.5); + /* get the xfwm4 chanel */ + wckp->wm_channel = wck_properties_get_channel (G_OBJECT (wckp->plugin), "xfwm4"); + + /* try to set title settings from the xfwm4 theme */ + if (wckp->wm_channel && wckp->prefs->sync_wm_font) + { + apply_wm_settings (wckp); + g_signal_connect (wckp->wm_channel, "property-changed", G_CALLBACK (on_xfwm_channel_property_changed), wckp); + } + gtk_alignment_set_padding(GTK_ALIGNMENT(wckp->alignment), 0, 0, wckp->prefs->title_padding, wckp->prefs->title_padding); gtk_box_set_spacing (GTK_BOX(wckp->hvbox), wckp->prefs->title_padding); diff --git a/panel-plugin/title/windowck.c b/panel-plugin/title/windowck.c index 59c82606f222da774d701d0fe8e4b7b2231f15f6..410d1868693831666f234363a8625ee0f5ab76b5 100644 --- a/panel-plugin/title/windowck.c +++ b/panel-plugin/title/windowck.c @@ -47,7 +47,7 @@ #define DEFAULT_TITLE_SIZE 80 #define DEFAULT_TITLE_ALIGNMENT CENTER #define DEFAULT_TITLE_PADDING 3 -#define DEFAULT_CUSTOM_FONT FALSE +#define DEFAULT_sync_wm_font TRUE #define DEFAULT_TITLE_FONT "sans 10" #define DEFAULT_INACTIVE_TEXT_ALPHA 60 #define DEFAULT_INACTIVE_TEXT_SHADE 110 @@ -88,7 +88,7 @@ void windowck_save(XfcePanelPlugin *plugin, WindowckPlugin *wckp) xfce_rc_write_bool_entry(rc, "show_tooltips", wckp->prefs->show_tooltips); xfce_rc_write_int_entry(rc, "size_mode", wckp->prefs->size_mode); xfce_rc_write_int_entry(rc, "title_size", wckp->prefs->title_size); - xfce_rc_write_bool_entry(rc, "custom_font", wckp->prefs->custom_font); + xfce_rc_write_bool_entry(rc, "sync_wm_font", wckp->prefs->sync_wm_font); if (wckp->prefs->title_font) xfce_rc_write_entry(rc, "title_font", wckp->prefs->title_font); @@ -136,7 +136,7 @@ static void windowck_read(WindowckPlugin *wckp) wckp->prefs->show_tooltips = xfce_rc_read_bool_entry(rc, "show_tooltips", DEFAULT_SHOW_TOOLTIPS); wckp->prefs->size_mode = xfce_rc_read_int_entry (rc, "size_mode", DEFAULT_SIZE_MODE); wckp->prefs->title_size = xfce_rc_read_int_entry(rc, "title_size", DEFAULT_TITLE_SIZE); - wckp->prefs->custom_font = xfce_rc_read_bool_entry(rc, "custom_font", DEFAULT_CUSTOM_FONT); + wckp->prefs->sync_wm_font = xfce_rc_read_bool_entry(rc, "sync_wm_font", DEFAULT_sync_wm_font); title_font = xfce_rc_read_entry(rc, "title_font", DEFAULT_TITLE_FONT); wckp->prefs->title_font = g_strdup(title_font); wckp->prefs->title_alignment = xfce_rc_read_int_entry(rc, "title_alignment", DEFAULT_TITLE_ALIGNMENT); @@ -165,7 +165,7 @@ static void windowck_read(WindowckPlugin *wckp) wckp->prefs->show_tooltips = DEFAULT_SHOW_TOOLTIPS; wckp->prefs->size_mode = DEFAULT_SIZE_MODE; wckp->prefs->title_size = DEFAULT_TITLE_SIZE; - wckp->prefs->custom_font = DEFAULT_CUSTOM_FONT; + wckp->prefs->sync_wm_font = DEFAULT_sync_wm_font; wckp->prefs->title_font = DEFAULT_TITLE_FONT; wckp->prefs->title_alignment = DEFAULT_TITLE_ALIGNMENT; wckp->prefs->title_padding = DEFAULT_TITLE_PADDING; @@ -176,7 +176,7 @@ static void windowck_read(WindowckPlugin *wckp) void create_symbol (gboolean show_app_icon, WindowckPlugin *wckp) { - if (wckp->icon->symbol) + if (GTK_IS_WIDGET (wckp->icon->symbol)) gtk_widget_destroy (wckp->icon->symbol); if (wckp->prefs->show_window_menu) @@ -389,12 +389,12 @@ static void windowck_construct(XfcePanelPlugin *plugin) refresh = show_refresh_item (plugin); g_signal_connect (G_OBJECT (refresh), "activate", G_CALLBACK (on_refresh_item_activated), wckp); - /* start tracking title size */ - init_title(wckp); - /* start tracking title text */ wckp->win = g_slice_new0 (WckUtils); init_wnck(wckp->win, wckp->prefs->only_maximized, wckp); + + /* start tracking title size */ + init_title(wckp); } diff --git a/panel-plugin/title/windowck.h b/panel-plugin/title/windowck.h index e43e336fd2bde104b1e3c846346428ee08f9fca8..0f96bbe8aa24e01c159008638664657583f9c92b 100644 --- a/panel-plugin/title/windowck.h +++ b/panel-plugin/title/windowck.h @@ -64,19 +64,18 @@ typedef struct { gboolean full_name; // [T/F] Show full name gboolean show_tooltips; // [T/F] Show tooltips - SizeMode size_mode; // Size mode : Length=[MINIMAL,FIXE,EXPAND] + SizeMode size_mode; // Size mode : Length=[MINIMAL,FIXE,EXPAND] - gint title_size; // Title size in chars - gint title_padding; // Title padding + gint title_size; // Title size in chars + gint title_padding; // Title padding - gboolean custom_font; // [T/F] Use custom font - gchar *title_font; // Custom title font + gboolean sync_wm_font; // [T/F] Try to use xfwm4 active theme if possible. + gchar *title_font; // Custom title font + gint title_alignment; // Title alignment [LEFT, CENTER, RIGHT] gint inactive_text_alpha; // Title inactive alpha gint inactive_text_shade; // Title inactive shade gchar *active_text_color; // active text color gchar *inactive_text_color; // inactive text color - - gint title_alignment; // Title alignment [0=left, 5=center, 10=right] } WCKPreferences; /* plugin structure */ @@ -93,10 +92,11 @@ typedef struct { WCKPreferences *prefs; WckUtils *win; - gulong cnh; // controled window name handler id - gulong cih; // controled window icon handler id + gulong cnh; // controled window name handler id + gulong cih; // controled window icon handler id - XfconfChannel *x_channel; // xsettings chanel + XfconfChannel *wm_channel; // window manager chanel + XfconfChannel *x_channel; // xsettings chanel } WindowckPlugin; void windowck_save(XfcePanelPlugin *plugin, WindowckPlugin *wckp);