Skip to content

Commit

Permalink
GtkBuilder for settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nsz32 committed Apr 28, 2020
1 parent 8702716 commit ecced18
Show file tree
Hide file tree
Showing 8 changed files with 2,029 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ src/.libs/
*.in
*.lo
*.la
src/_resources.c
4 changes: 4 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugin_LTLIBRARIES = libdocklike.la

# List of source files needed to build the library
libdocklike_la_SOURCES = \
_gresources.c \
Theme.cpp Theme.hpp \
AppInfos.cpp AppInfos.hpp \
Settings.cpp Settings.hpp \
Expand Down Expand Up @@ -45,6 +46,9 @@ libdocklike_la_LIBADD = \
$(CAIRO_LIBS) \
$(WNCK_LIBS)

_gresources.c: _gresources.xml _dialogs.xml
glib-compile-resources --generate-source --target _gresources.c _gresources.xml


# Recently (>=2017) dependent libraries seem to require building with
# the C++11 standard (see https://bugzilla.xfce.org/show_bug.cgi?id=13717)
Expand Down
78 changes: 52 additions & 26 deletions src/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,65 @@ namespace SettingsDialog
{
void popup()
{
GtkWidget* dialogWindow = xfce_titled_dialog_new_with_buttons(
"Docklike taskbar",
GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(Plugin::mXfPlugin))),
GTK_DIALOG_DESTROY_WITH_PARENT,
"gtk-close", GTK_RESPONSE_OK, NULL);
/* Hook to make sure GtkBuilder knows are the XfceTitledDialog object */
if (xfce_titled_dialog_get_type() == 0)
return;

gtk_window_set_wmclass(GTK_WINDOW(dialogWindow), "xfce4-panel", "xfce4-panel");
gtk_window_set_icon_name(GTK_WINDOW(dialogWindow), "preferences-system-windows");
xfce_titled_dialog_set_subtitle(XFCE_TITLED_DIALOG(dialogWindow), "‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾");

GtkGrid* grid = (GtkGrid*)gtk_grid_new();
gtk_grid_set_row_homogeneous(grid, false);
gtk_grid_set_column_homogeneous(grid, false);
gtk_grid_set_column_spacing(grid, 10);

gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialogWindow))), GTK_WIDGET(grid));

// No windows list if single

GtkWidget* noWindowsListIfSingle = gtk_check_button_new_with_label("Don't display list for a single window");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(noWindowsListIfSingle), Settings::noWindowsListIfSingle);
gtk_grid_attach(grid, noWindowsListIfSingle, 0, 0, 1, 1);
GtkBuilder* builder = gtk_builder_new_from_resource("/_dialogs.xml");
GtkWidget* dialog = (GtkWidget*)gtk_builder_get_object(builder, "dialog");
gtk_widget_show_all(dialog);

g_signal_connect(
G_OBJECT(noWindowsListIfSingle), "toggled",
gtk_builder_get_object(builder, "b_close"), "clicked",
G_CALLBACK(+[](GtkButton* button, GtkWidget* dialogWindow) {
gtk_widget_hide(dialogWindow);
gtk_dialog_response((GtkDialog*)dialogWindow, 0);
xfce_panel_plugin_unblock_menu(Plugin::mXfPlugin);
}),
dialog);

GObject* noListForSingleWindow = gtk_builder_get_object(builder, "c_noListForSingleWindow");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(noListForSingleWindow), Settings::noWindowsListIfSingle);
g_signal_connect(noListForSingleWindow, "toggled",
G_CALLBACK(+[](GtkToggleButton* noWindowsListIfSingle) {
Settings::noWindowsListIfSingle.set(gtk_toggle_button_get_active(noWindowsListIfSingle));
}),
NULL);

GObject* indicatorStyle = gtk_builder_get_object(builder, "co_indicatorStyle");
gtk_combo_box_set_active(GTK_COMBO_BOX(indicatorStyle), Settings::indicatorStyle);
g_signal_connect(indicatorStyle, "changed",
G_CALLBACK(+[](GtkComboBox* indicatorStyle) {
Settings::indicatorStyle.set(gtk_combo_box_get_active(GTK_COMBO_BOX(indicatorStyle)));
}),
NULL);

GObject* iconSize = gtk_builder_get_object(builder, "e_iconSize");
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(iconSize))), std::to_string(Settings::iconSize).c_str());
gtk_widget_set_sensitive(GTK_WIDGET(iconSize), Settings::forceIconSize);
g_signal_connect(iconSize, "changed",
G_CALLBACK(+[](GtkComboBox* iconSize) {
GtkEntry* entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(iconSize)));
std::string value = Help::String::numericOnly(gtk_entry_get_text(entry));
gtk_entry_set_text(entry, value.c_str());
Settings::iconSize.set(std::stoi("0" + value));
}),
NULL);

GObject* forceIconSize = gtk_builder_get_object(builder, "c_forceIconSize");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(forceIconSize), Settings::forceIconSize);
g_signal_connect(forceIconSize, "toggled",
G_CALLBACK(+[](GtkToggleButton* forceIconSize, GtkWidget* iconSize) {
Settings::forceIconSize.set(gtk_toggle_button_get_active(forceIconSize));
gtk_widget_set_sensitive(GTK_WIDGET(iconSize), Settings::forceIconSize);
}),
iconSize);

return;

// Indicator style

GtkWidget* label = gtk_label_new("Indicator style : ");
/*GtkWidget* label = gtk_label_new("Indicator style : ");
gtk_grid_attach(grid, label, 0, 1, 1, 1);
GtkWidget* indicatorStyle = gtk_combo_box_text_new();
Expand All @@ -51,7 +77,7 @@ namespace SettingsDialog
}),
NULL);
gtk_grid_attach(grid, indicatorStyle, 2, 1, 1, 1);
gtk_grid_attach(grid, indicatorStyle, 1, 1, 1, 1);
// Force icon size
Expand Down Expand Up @@ -85,7 +111,7 @@ namespace SettingsDialog
}),
NULL);
gtk_grid_attach(grid, iconSizeValue, 2, 2, 1, 1);
gtk_grid_attach(grid, iconSizeValue, 1, 2, 1, 1);
// ------------------
Expand All @@ -100,6 +126,6 @@ namespace SettingsDialog
gtk_widget_hide(dialogWindow);
xfce_panel_plugin_unblock_menu(Plugin::mXfPlugin);
}),
dialogWindow);
dialogWindow);*/
}
} // namespace SettingsDialog
2 changes: 2 additions & 0 deletions src/SettingsDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ extern "C"
namespace SettingsDialog
{
void popup();

void close();
} // namespace SettingsDialog

#endif // SETTINGS_HPP
206 changes: 206 additions & 0 deletions src/_dialogs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<interface>
<requires lib="gtk+" version="3.0" />
<requires lib="libxfce4ui-2" version="4.20" />
<object class="GtkImage" id="i_close">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">window-close</property>
</object>
<object class="XfceTitledDialog" id="dialog">
<property name="can_focus">False</property>
<property name="title">Docklike Taskbar</property>
<property name="icon_name">preferences-system-windows</property>
<property name="type_hint">normal</property>
<property name="subtitle">‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<property name="margin_right">18</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="b_close">
<property name="label" translatable="yes">_Close</property>
<property name="image">i_close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">6</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">6</property>
<property name="label" translatable="yes">Behavior</property>
<attributes>
<attribute name="weight" value="bold" />
</attributes>
</object>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">18</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkCheckButton" id="c_noListForSingleWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Don't show list for a single window</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">6</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_bottom">6</property>
<property name="label" translatable="yes">Appearence</property>
<attributes>
<attribute name="weight" value="bold" />
</attributes>
</object>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">18</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Indicator style :</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="co_indicatorStyle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<items>
<item translatable="yes">Bars</item>
<item translatable="yes">Dots</item>
</items>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="c_forceIconSize">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Force icons size :</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="e_iconSize">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<items>
<item translatable="no">16</item>
<item translatable="no">24</item>
<item translatable="no">32</item>
<item translatable="no">48</item>
<item translatable="no">64</item>
<item translatable="no">96</item>
<item translatable="no">256</item>
</items>
<child internal-child="entry">
<object class="GtkEntry">
<property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
Loading

0 comments on commit ecced18

Please sign in to comment.