aboutsummaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rw-r--r--patches/button-menu-icons.c451
-rw-r--r--patches/dialogs.c451
-rw-r--r--patches/icon-sizes.c325
-rw-r--r--patches/no-emojis.c61
-rw-r--r--patches/persistent-mnemonics.c100
-rw-r--r--patches/smaller-widgets.c262
6 files changed, 1650 insertions, 0 deletions
diff --git a/patches/button-menu-icons.c b/patches/button-menu-icons.c
new file mode 100644
index 0000000..471a0d0
--- /dev/null
+++ b/patches/button-menu-icons.c
@@ -0,0 +1,451 @@
+/* Button / Menu Icons:
+ * (from gtk3-classic patch 'appearance__buttons-menus-icons.patch')
+ *
+ * Applies appropriate icons to buttons and menus as if they were stock buttons
+ * or menu items.
+ *
+ * Enable the icons by adding to your settings.ini file:
+ *
+ * gtk-button-images = 1
+ * gtk-menu-images = 1
+ *
+ * Some desktop environments may set these properties via their own appearance
+ * preferences configuration tool; check for such an option or set of options
+ * first.
+ */
+
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <gtk3-classic.h>
+
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "Gtk3-Classic::Button-Menu-Icons"
+
+
+/*
+ * Most of the button / menu labels and their associated icons listed herein
+ * are taken from the gtkstock.h header file which comes with GTK, with the
+ * exception that most of the GTK-specific icon names have been replaced with
+ * their generic FreeDesktop equivalents. Other entries in this table may have
+ * been extracted from the original patch from gtk3-classic.
+ */
+
+#define ICON(_label, _icon_name) \
+ { .label = _label, .icon_name = _icon_name }
+
+typedef struct
+{
+ const char * label;
+ const char * translated_label;
+ const char * icon_name;
+} Icon;
+
+static int icons_list_length;
+static Icon icons[] =
+{
+ ICON ("_About", "help-about"),
+ ICON ("_Add", "list-add"),
+ ICON ("_Apply", "gtk-apply"),
+ ICON ("_Ascending", "view-sort-ascending"),
+ ICON ("Authentication", "dialog-authentication"),
+ ICON ("_Back", "back"),
+ ICON ("Best _Fit", "zoom-fit-best"),
+ ICON ("_Bold", "format-text-bold"),
+ ICON ("_Bottom", "bottom"),
+ ICON ("_Cancel", "gtk-cancel"),
+ ICON ("_CD-ROM", "media-optical"),
+ ICON ("_Center", "format-justify-center"),
+ ICON ("_Clear", "edit-clear"),
+ ICON ("_Close", "window-close"),
+ ICON ("_Color", "gtk-select-color"),
+ ICON ("Color Selection","gtk-select-color"),
+ ICON ("_Connect", "gtk-connect"),
+ ICON ("_Convert", "gtk-convert"),
+ ICON ("_Copy", "edit-copy"),
+ ICON ("Copy _Link Address", "edit-copy"),
+ ICON ("Copy URL", "edit-copy"),
+ ICON ("_Credits", "help-about"),
+ ICON ("C_ustomize", "gtk-edit"),
+ ICON ("Cu_t", "edit-cut"),
+ ICON ("_Delete", "edit-delete"),
+ ICON ("_Descending", "view-sort-descending"),
+ ICON ("_Discard", "edit-delete"),
+ ICON ("_Disconnect", "gtk-disconnect"),
+ ICON ("_Down", "down"),
+ ICON ("_Edit", "gtk-edit"),
+ ICON ("Error", "dialog-error"),
+ ICON ("_Execute", "gtk-execute"),
+ ICON ("_File", "text-x-generic"),
+ ICON ("_Fill", "format-justify-fill"),
+ ICON ("_Find", "edit-find"),
+ ICON ("Find and _Replace", "edit-find-replace"),
+ ICON ("_First", "go-first"),
+ ICON ("Fol_der", "folder"),
+ ICON ("_Font", "gtk-select-font"),
+ ICON ("Font Selection","gtk-select-font"),
+ ICON ("_Forward", "forward"),
+ ICON ("_Fullscreen", "view-fullscreen"),
+ ICON ("_Hard Disk", "media-harddisk"),
+ ICON ("_Help", "help-contents"),
+ ICON ("_Home", "go-home"),
+ ICON ("Image", "image-x-generic"),
+ ICON ("Indent", "format-indent-more"),
+ ICON ("_Info", "dialog-information"),
+ ICON ("_Information", "dialog-information"),
+ ICON ("Insert _Emoji", "face-smile"),
+ ICON ("_Italic", "format-text-italic"),
+ ICON ("_Jump to", "go-jump"),
+ ICON ("Landscape", "gtk-orientation-landscape"),
+ ICON ("_Last", "go-last"),
+ ICON ("_Leave Fullscreen", "view-restore"),
+ ICON ("_Left", "format-justify-left"),
+ ICON ("_License", "text-x-generic"),
+ ICON ("Lock", "changes-prevent"),
+ ICON ("_Network", "network"),
+ ICON ("Networks", "network"),
+ ICON ("_New", "document-new"),
+ ICON ("_Next", "forward"),
+ ICON ("_No", "gtk-no"),
+ ICON ("_Normal Size", "zoom-original"),
+ ICON ("_OK", "gtk-ok"),
+ ICON ("_Open", "document-open"),
+ ICON ("_Open Link", "go-jump"),
+ ICON ("Page Set_up", "document-page-setup"),
+ ICON ("_Password", "dialog-authentication"),
+ ICON ("_Paste", "edit-paste"),
+ ICON ("P_ause", "media-playback-pause"),
+ ICON ("Pick a Color", "gtk-select-color"),
+ ICON ("Pick a Font", "gtk-select-font"),
+ ICON ("_Play", "media-playback-play"),
+ ICON ("Portrait", "gtk-orientation-portrait"),
+ ICON ("_Preferences", "preferences-system"),
+ ICON ("Pre_view", "document-print-preview"),
+ ICON ("Pre_vious", "back"),
+ ICON ("_Print", "document-print"),
+ ICON ("Print Pre_view", "document-print-preview"),
+ ICON ("_Properties", "document-properties"),
+ ICON ("_Question", "dialog-question"),
+ ICON ("_Quit", "application-exit"),
+ ICON ("_Record", "media-record"),
+ ICON ("_Redo", "edit-redo"),
+ ICON ("_Refresh", "view-refresh"),
+ ICON ("_Remove", "list-remove"),
+ ICON ("_Replace", "edit-find-replace"),
+ ICON ("Reverse landscape", "gtk-orientation-reverse-landscape"),
+ ICON ("Reverse portrait", "gtk-orientation-reverse-portrait"),
+ ICON ("_Revert", "document-revert"),
+ ICON ("R_ewind", "media-seek-backward"),
+ ICON ("_Right", "format-justify-right"),
+ ICON ("_Save", "document-save"),
+ ICON ("Save _As", "document-save-as"),
+ ICON ("Search", "system-search"),
+ ICON ("_Select", "gtk-ok"),
+ ICON ("Select _All", "edit-select-all"),
+ ICON ("Select a Color", "gtk-select-color"),
+ ICON ("Select a Font", "gtk-select-font"),
+ ICON ("_Spell Check", "tools-check-spelling"),
+ ICON ("_Stop", "process-stop"),
+ ICON ("_Strikethrough", "format-text-strikethrough"),
+ ICON ("_Top", "top"),
+ ICON ("_Undelete", "gtk-undelete"),
+ ICON ("_Underline", "format-text-underline"),
+ ICON ("_Undo", "edit-undo"),
+ ICON ("Unindent", "format-indent-less"),
+ ICON ("Unlock", "changes-allow"),
+ ICON ("_Up", "up"),
+ ICON ("Warning", "dialog-warning"),
+ ICON ("_Yes", "gtk-yes"),
+ ICON ("Zoom _In", "zoom-in"),
+ ICON ("Zoom _Out", "zoom-out"),
+ { NULL, NULL, NULL }
+};
+
+static int sort_icon_labels (const void * icon1, const void * icon2);
+static int search_icon_labels (const void * key, const void * icon);
+
+
+INTERCEPTED_CLASS_METHOD (gtk_button, notify,
+ (GObject * object,
+ GParamSpec * pspec),
+ void)
+
+
+INTERCEPTED_CLASS_METHOD (gtk_menu_item, constructor,
+ (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_params),
+ GObject *)
+
+INTERCEPTED_CLASS_METHOD (gtk_image_menu_item, parent_set,
+ (GtkWidget * widget,
+ GtkWidget * previous_parent),
+ void)
+
+INTERCEPTED_CLASS_METHOD (gtk_image_menu_item, set_label,
+ (GtkMenuItem * menu_item,
+ const gchar * label),
+ void)
+
+
+void button_menu_icons_init ()
+{
+ {
+ GtkButtonClass * gtk_button_class =
+ g_type_class_ref (GTK_TYPE_BUTTON);
+
+ INTERCEPT_CLASS_METHOD (gtk_button, G_OBJECT_CLASS, notify)
+
+ g_type_class_unref (gtk_button_class);
+ }
+
+
+ {
+ GtkMenuItemClass * gtk_menu_item_class =
+ g_type_class_ref (GTK_TYPE_MENU_ITEM);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ GtkImageMenuItemClass * gtk_image_menu_item_class =
+ g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+
+ INTERCEPT_CLASS_METHOD (
+ gtk_menu_item, G_OBJECT_CLASS, constructor)
+ INTERCEPT_CLASS_METHOD (
+ gtk_image_menu_item, GTK_WIDGET_CLASS, parent_set)
+ INTERCEPT_CLASS_METHOD (
+ gtk_image_menu_item, GTK_MENU_ITEM_CLASS, set_label)
+
+ g_type_class_unref (gtk_menu_item_class);
+ g_type_class_unref (gtk_image_menu_item_class);
+ }
+
+
+ for (icons_list_length = 0;
+ icons[icons_list_length].label != NULL;
+ icons_list_length++)
+ {
+ icons[icons_list_length].translated_label =
+ g_dgettext (GTK_GETTEXT_DOMAIN,
+ icons[icons_list_length].label);
+ }
+
+ qsort (icons, icons_list_length, sizeof (Icon), sort_icon_labels);
+}
+
+
+static void
+new_gtk_button_notify
+(GObject * object,
+ GParamSpec * pspec)
+{
+ GtkSettings * settings;
+ gboolean buttons_have_icons;
+ GtkButton * button;
+ GtkWidget * image;
+ const char * label_text;
+ Icon * icon;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_button, notify, (object, pspec));
+
+ if (strcmp (pspec->name, "label") != 0)
+ return;
+
+ button = GTK_BUTTON (object);
+ label_text = gtk_button_get_label (button);
+ image = gtk_button_get_image (button);
+ if (! label_text || image)
+ return;
+
+ settings = gtk_widget_get_settings (GTK_WIDGET (object));
+ g_object_get (settings,
+ "gtk-button-images", &buttons_have_icons,
+ NULL);
+ if (! buttons_have_icons)
+ return;
+
+ icon = bsearch (label_text, icons,
+ icons_list_length, sizeof (Icon),
+ search_icon_labels);
+ if (icon)
+ {
+ image = gtk_image_new_from_icon_name (icon->icon_name,
+ GTK_ICON_SIZE_BUTTON);
+ gtk_button_set_image (button, image);
+ }
+}
+
+
+static GObject *
+new_gtk_menu_item_constructor
+(GType type,
+ guint n_construct_properties,
+ GObjectConstructParam * construct_params)
+{
+ if (type == GTK_TYPE_MENU_ITEM)
+ {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ type = GTK_TYPE_IMAGE_MENU_ITEM;
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ }
+
+ return CALL_ORIGINAL_CLASS_METHOD_UNCHECKED (gtk_menu_item,
+ constructor,
+ (type,
+ n_construct_properties,
+ construct_params))
+}
+
+
+static void
+new_gtk_image_menu_item_parent_set
+(GtkWidget * widget,
+ GtkWidget * previous_parent)
+
+{
+ GtkWidget * parent;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_image_menu_item, parent_set,
+ (widget, previous_parent));
+
+
+ parent = gtk_widget_get_parent (widget);
+ if (parent && GTK_IS_MENU_BAR (parent))
+ {
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (widget),
+ NULL);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ }
+}
+
+
+static void
+new_gtk_image_menu_item_set_label
+(GtkMenuItem * menu_item,
+ const gchar * label)
+
+{
+ GtkWidget * widget;
+ GtkImageMenuItem * image_menu_item;
+ GtkWidget * parent;
+ GtkSettings * settings;
+ gboolean menus_have_icons;
+ Icon * icon;
+ GtkWidget * image;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_image_menu_item, set_label,
+ (menu_item, label));
+
+
+ widget = GTK_WIDGET (menu_item);
+ parent = gtk_widget_get_parent (widget);
+ if (parent && GTK_IS_MENU_BAR (parent))
+ return;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
+ image = gtk_image_menu_item_get_image (image_menu_item);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ if (! label || image)
+ return;
+
+ settings = gtk_widget_get_settings (widget);
+ g_object_get (settings,
+ "gtk-menu-images", &menus_have_icons,
+ NULL);
+ if (! menus_have_icons)
+ return;
+
+ icon = bsearch (label, icons,
+ icons_list_length, sizeof (Icon),
+ search_icon_labels);
+ if (icon)
+ {
+ image = gtk_image_new_from_icon_name (icon->icon_name,
+ GTK_ICON_SIZE_MENU);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ gtk_image_menu_item_set_image (image_menu_item, image);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ }
+}
+
+
+/* Helper functions */
+
+static int sort_icon_labels (const void * icon1, const void * icon2)
+{
+ const char * s1 = ((Icon *) icon1)->translated_label;
+ const char * s2 = ((Icon *) icon2)->translated_label;
+ int i;
+ int j;
+
+
+ i = 0;
+ j = 0;
+ do
+ {
+ if (s1[i] == '_')
+ i++;
+ if (s2[j] == '_')
+ j++;
+
+ if (s1[i] != s2[j])
+ return s1[i] - s2[j];
+
+ if (s1[i] == '\0')
+ break;
+
+ i++;
+ j++;
+ }
+ while (1);
+
+
+ return 0;
+}
+
+
+static int search_icon_labels (const void * key, const void * icon)
+{
+ const char * key_string = key;
+ const char * label = ((Icon *) icon)->translated_label;
+ int k;
+ int l;
+
+ k = 0;
+ l = 0;
+ do
+ {
+ if (key_string[k] == '_')
+ k++;
+ if (label[l] == '_')
+ l++;
+
+ if (key_string[k] != label[l])
+ return key_string[k] - label[l];
+
+ if (key_string[k] == '\0')
+ break;
+
+ k++;
+ l++;
+
+ /* Ignore ellipses following the label text, so that buttons /
+ * menu items such as 'Open...' will be themed as well.
+ */
+ if (strcmp (&key_string[k], "...") == 0)
+ break;
+ }
+ while (1);
+
+
+ return 0;
+}
diff --git a/patches/dialogs.c b/patches/dialogs.c
new file mode 100644
index 0000000..5118fc3
--- /dev/null
+++ b/patches/dialogs.c
@@ -0,0 +1,451 @@
+/* Dialogs:
+ * From gtk3-classic patches:
+ * appearance__message-dialogs.patch
+ * appearance__file-chooser.patch
+ * appearance__print-dialog.patch
+ * fixes__wayland_dialogs_header_setting.patch
+ * file-chooser__eject-button.patch
+ * file-chooser__typeahead.patch
+ *
+ * Restores the classic appearance of message, print, and file dialogs.
+ * Forces dialogs to use the traditional action area for their buttons,
+ * instead of putting the buttons in a headerbar -- even on Wayland.
+ * Also makes some behavioural changes to file chooser widgets (and thus
+ * by extension file dialogs).
+ */
+
+
+#include <gtk/gtk.h>
+#include <gtk/gtkunixprint.h>
+#include <gdk/gdk.h>
+#include <glib.h>
+
+#include <string.h>
+
+#include <gtk3-classic.h>
+
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "Gtk3-Classic::Dialogs"
+
+
+#define MESSAGE_DIALOG_CSS \
+ "messagedialog > *,\n" \
+ "messagedialog buttonbox.dialog-action-area,\n" \
+ "messagedialog box.dialog-action-box\n" \
+ "{\n" \
+ " margin: 0;\n" \
+ " margin-top: 0;\n" \
+ " padding: 0;\n" \
+ "}\n"
+
+#define PRINT_DIALOG_CSS \
+ "printdialog box.dialog-action-box\n" \
+ "{\n" \
+ " margin: 0;\n" \
+ "}\n"
+
+#define FILE_CHOOSER_CSS \
+ "/* Prefer full-color icons to symbolic ones */\n" \
+ "filechooser .sidebar-icon,\n" \
+ "filechooser .path-bar,\n" \
+ "filechooser .path-bar + button\n" \
+ "{\n" \
+ " opacity: 1;\n" \
+ " -gtk-icon-style: regular;\n" \
+ "}\n" \
+ "\n" \
+ "/* Hide the Eject / Unmount buttons next to volumes in the sidebar */\n" \
+ "filechooser .sidebar-button\n" \
+ "{\n" \
+ " opacity: 0;\n" \
+ "}\n"
+
+
+static void apply_dialog_css (GtkWidget * dialog);
+static GtkWidget * find_widget_by_name (GtkWidget * start,
+ const char * name);
+
+
+INTERCEPTED_CLASS_METHOD (gtk_settings, constructed,
+ (GObject * object),
+ void)
+
+
+INTERCEPTED_CLASS_METHOD (gtk_message_dialog, constructed,
+ (GObject * object),
+ void)
+
+INTERCEPTED_CLASS_METHOD (gtk_message_dialog, notify,
+ (GObject * object,
+ GParamSpec * pspec),
+ void)
+
+
+INTERCEPTED_CLASS_METHOD (gtk_print_unix_dialog, constructed,
+ (GObject * object),
+ void)
+
+
+INTERCEPTED_CLASS_METHOD (gtk_file_chooser_widget, constructed,
+ (GObject * object),
+ void)
+
+static void
+filechooser_treeview_search_column_changed (GObject * object,
+ GParamSpec * pspec,
+ gpointer data);
+
+static void
+filechooser_search_entry_map (GtkWidget * widget,
+ gpointer data);
+
+static void
+filechooser_search_entry_unmap (GtkWidget * widget,
+ gpointer data);
+
+
+void dialogs_init ()
+{
+ {
+ GtkSettingsClass * gtk_settings_class =
+ g_type_class_ref (GTK_TYPE_SETTINGS);
+
+ INTERCEPT_CLASS_METHOD (gtk_settings, G_OBJECT_CLASS,
+ constructed)
+
+ g_type_class_unref (gtk_settings_class);
+ }
+
+
+ {
+ GtkMessageDialogClass * gtk_message_dialog_class =
+ g_type_class_ref (GTK_TYPE_MESSAGE_DIALOG);
+
+ INTERCEPT_CLASS_METHOD (gtk_message_dialog, G_OBJECT_CLASS,
+ constructed)
+ INTERCEPT_CLASS_METHOD (gtk_message_dialog, G_OBJECT_CLASS,
+ notify);
+
+ g_type_class_unref (gtk_message_dialog_class);
+ }
+
+
+ {
+ GtkPrintUnixDialogClass * gtk_print_unix_dialog_class =
+ g_type_class_ref (GTK_TYPE_PRINT_UNIX_DIALOG);
+
+ INTERCEPT_CLASS_METHOD (gtk_print_unix_dialog, G_OBJECT_CLASS,
+ constructed)
+
+ g_type_class_unref (gtk_print_unix_dialog_class);
+ }
+
+
+ {
+ GtkFileChooserWidgetClass * gtk_file_chooser_widget_class =
+ g_type_class_ref (GTK_TYPE_FILE_CHOOSER_WIDGET);
+
+ INTERCEPT_CLASS_METHOD (gtk_file_chooser_widget,
+ G_OBJECT_CLASS, constructed)
+
+ g_type_class_unref (gtk_file_chooser_widget_class);
+ }
+}
+
+
+static void
+new_gtk_settings_constructed
+(GObject * object)
+{
+ CALL_ORIGINAL_CLASS_METHOD (gtk_settings, constructed, (object));
+
+ g_object_set (object, "gtk-dialogs-use-header", FALSE, NULL);
+}
+
+
+static void
+new_gtk_message_dialog_constructed
+(GObject * object)
+{
+ GtkWidget * internal_vbox;
+ GtkWidget * box;
+ GtkWidget * message_area;
+ GtkWidget * label;
+ GtkWidget * secondary_label;
+ GtkWidget * action_area;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_message_dialog, constructed, (object));
+
+ apply_dialog_css (GTK_WIDGET (object));
+
+ gtk_container_set_border_width (GTK_CONTAINER (object), 5);
+
+ internal_vbox = find_widget_by_name (GTK_WIDGET (object),
+ "dialog-vbox1");
+ gtk_container_set_border_width (GTK_CONTAINER (internal_vbox), 2);
+ gtk_box_set_spacing (GTK_BOX (internal_vbox), 8);
+
+ box = find_widget_by_name (internal_vbox, "box");
+ gtk_widget_set_margin_start (box, 2);
+ gtk_widget_set_margin_end (box, 2);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 5);
+ gtk_box_set_spacing (GTK_BOX (box), 12);
+
+ message_area = find_widget_by_name (box, "message_area");
+ gtk_box_set_spacing (GTK_BOX (message_area), 12);
+
+ label = find_widget_by_name (message_area, "label");
+ secondary_label = find_widget_by_name (message_area,
+ "secondary_label");
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
+ gtk_label_set_xalign (GTK_LABEL (label), 0);
+ gtk_label_set_xalign (GTK_LABEL (secondary_label), 0);
+
+ action_area = find_widget_by_name (GTK_WIDGET (object), "action_area");
+ gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+ gtk_box_set_spacing (GTK_BOX (action_area), 6);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (action_area),
+ GTK_BUTTONBOX_END);
+}
+
+
+static void
+new_gtk_message_dialog_notify
+(GObject * object,
+ GParamSpec * pspec)
+{
+ GtkMessageType message_type;
+ const char * icon_name;
+ GtkWidget * image;
+ GtkMessageType image_message_type;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_message_dialog,
+ notify, (object, pspec));
+
+
+ if (strcmp (pspec->name, "message-type") != 0)
+ return;
+
+ g_object_get (object, "message-type", &message_type, NULL);
+ g_object_get (object, "image", &image, NULL);
+
+ if (image != NULL)
+ {
+ image_message_type = GPOINTER_TO_INT (
+ g_object_get_data (G_OBJECT (image), "message-type")) - 1;
+ if (image_message_type == message_type)
+ return;
+ }
+
+ switch (message_type)
+ {
+ case GTK_MESSAGE_INFO:
+ icon_name = "dialog-information";
+ break;
+ case GTK_MESSAGE_WARNING:
+ icon_name = "dialog-warning";
+ break;
+ case GTK_MESSAGE_QUESTION:
+ icon_name = "dialog-question";
+ break;
+ case GTK_MESSAGE_ERROR:
+ icon_name = "dialog-error";
+ break;
+ default:
+ return;
+ }
+
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
+ gtk_widget_show (image);
+ g_object_set_data (G_OBJECT (image), "message-type",
+ GINT_TO_POINTER (message_type + 1));
+
+ g_object_freeze_notify (object);
+ g_object_set (object, "image", image, NULL);
+ g_object_set (object, "message-type", message_type, NULL);
+ g_object_thaw_notify (object);
+}
+
+
+static void
+new_gtk_print_unix_dialog_constructed
+(GObject * object)
+{
+ GtkWidget * internal_vbox;
+ GtkWidget * box;
+ GtkWidget * notebook;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_print_unix_dialog,
+ constructed, (object));
+
+ apply_dialog_css (GTK_WIDGET (object));
+
+ gtk_container_set_border_width (GTK_CONTAINER (object), 5);
+
+ internal_vbox = find_widget_by_name (GTK_WIDGET (object),
+ "dialog-vbox1");
+ gtk_container_set_border_width (GTK_CONTAINER (internal_vbox), 2);
+
+ box = find_widget_by_name (internal_vbox, "box1");
+ gtk_container_set_border_width (GTK_CONTAINER (box), 5);
+
+ notebook = find_widget_by_name (box, "notebook");
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), TRUE);
+}
+
+
+static void
+new_gtk_file_chooser_widget_constructed
+(GObject * object)
+{
+ GtkWidget * treeview;
+ GtkWidget * search_entry;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_file_chooser_widget,
+ constructed, (object));
+
+
+ apply_dialog_css (GTK_WIDGET (object));
+
+
+ treeview = find_widget_by_name (GTK_WIDGET (object),
+ "browse_files_tree_view");
+
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview), TRUE);
+
+ g_signal_connect (G_OBJECT (treeview), "notify::search-column",
+ G_CALLBACK (filechooser_treeview_search_column_changed), NULL);
+
+ search_entry = find_widget_by_name (GTK_WIDGET (object),
+ "search_entry");
+
+ g_signal_connect (G_OBJECT (search_entry), "map",
+ G_CALLBACK (filechooser_search_entry_map),
+ treeview);
+
+ g_signal_connect (G_OBJECT (search_entry), "unmap",
+ G_CALLBACK (filechooser_search_entry_unmap),
+ treeview);
+}
+
+
+static void
+filechooser_treeview_search_column_changed
+(GObject * object,
+ GParamSpec * pspec,
+ gpointer data)
+{
+ (void) pspec;
+ (void) data;
+
+
+ if (gtk_tree_view_get_search_column (GTK_TREE_VIEW (object)) == -1)
+ gtk_tree_view_set_search_column (GTK_TREE_VIEW (object), 0);
+}
+
+
+static void filechooser_search_entry_map
+(GtkWidget * widget,
+ gpointer data)
+{
+ (void) widget;
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (data), FALSE);
+}
+
+static void filechooser_search_entry_unmap
+(GtkWidget * widget,
+ gpointer data)
+{
+ (void) widget;
+ gtk_tree_view_set_enable_search (GTK_TREE_VIEW (data), TRUE);
+}
+
+
+/* Helper functions */
+
+static void apply_dialog_css (GtkWidget * dialog)
+{
+ GdkScreen * screen;
+ gboolean dialog_css_applied;
+ GtkCssProvider * provider;
+
+
+ screen = gtk_widget_get_screen (dialog);
+ dialog_css_applied =
+ GPOINTER_TO_INT (g_object_get_data (G_OBJECT (screen),
+ "dialog-css-applied"));
+ if (! dialog_css_applied)
+ {
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,
+ MESSAGE_DIALOG_CSS
+ PRINT_DIALOG_CSS
+ FILE_CHOOSER_CSS,
+ -1, NULL);
+ gtk_style_context_add_provider_for_screen (screen,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
+ g_object_set_data (G_OBJECT (screen),
+ "dialog-css-applied",
+ GINT_TO_POINTER (TRUE));
+ }
+}
+
+
+static void add_widget_to_list (GtkWidget * widget, gpointer data)
+{
+ GSList ** list = data;
+
+
+ *list = g_slist_append (*list, widget);
+}
+
+
+static GtkWidget *
+find_widget_by_name
+(GtkWidget * start,
+ const char * name)
+{
+ const char * widget_name;
+ GtkWidget * widget;
+ GSList * list;
+ GSList * list_iter;
+
+
+ if (GTK_IS_BUILDABLE (start))
+ {
+ widget_name = gtk_buildable_get_name (GTK_BUILDABLE (start));
+ if (widget_name != NULL && strcmp (widget_name, name) == 0)
+ return start;
+ }
+
+ if (GTK_IS_CONTAINER (start))
+ {
+ list = NULL;
+ gtk_container_forall (GTK_CONTAINER (start),
+ add_widget_to_list,
+ &list);
+ for (list_iter = list;
+ list_iter != NULL;
+ list_iter = list_iter->next)
+ {
+ widget =
+ find_widget_by_name (GTK_WIDGET (list_iter->data),
+ name);
+ if (widget != NULL)
+ break;
+ }
+
+ g_slist_free (list);
+ return widget;
+ }
+
+
+ return NULL;
+}
diff --git a/patches/icon-sizes.c b/patches/icon-sizes.c
new file mode 100644
index 0000000..8ea8a0f
--- /dev/null
+++ b/patches/icon-sizes.c
@@ -0,0 +1,325 @@
+/* Icon Sizes:
+ *
+ * Allows for the configuration of stock icon sizes via the GTK setting
+ * 'gtk-icon-sizes'. GTK (2) used to allow themes to choose the sizes of
+ * stock icons for various purposes; by default, button icons were 20x20 pixels
+ * (in reality, 24x24 icons usually were what GTK ended up using), whereas
+ * menu items used 16x16 icons. Some themes overrode these defaults with the
+ * 'gtk-icon-sizes' setting. Now, GTK ignores this setting entirely, and
+ * always uses 16x16 icons for buttons, which may not be such a bad thing if
+ * the icons weren't so small as to be nearly incomprehensible.
+ *
+ * You can change the size of the icons by adding to your settings.ini file:
+ *
+ * gtk-icon-sizes = gtk-button=24,24
+ *
+ * More details regarding the exact syntax of this setting are available in
+ * the GTK Settings documentation, currently available at:
+ * https://docs.gtk.org/gtk3/property.Settings.gtk-icon-sizes.html
+ */
+
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <gtk3-classic.h>
+
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "Gtk3-Classic::Icon-Sizes"
+
+
+static GQuark icon_sizes_table_quark;
+
+
+static void free_icon_sizes_table (gpointer data);
+static void parse_icon_sizes_string (char * icon_sizes_string,
+ int * icon_sizes_table);
+
+
+INTERCEPTED_CLASS_METHOD (gtk_settings, notify,
+ (GObject * object,
+ GParamSpec * pspec),
+ void)
+
+
+INTERCEPTED_CLASS_METHOD (gtk_image, notify,
+ (GObject * object,
+ GParamSpec * pspec),
+ void)
+
+
+void icon_sizes_init ()
+{
+ {
+ GtkSettingsClass * gtk_settings_class =
+ g_type_class_ref (GTK_TYPE_SETTINGS);
+
+ INTERCEPT_CLASS_METHOD (gtk_settings, G_OBJECT_CLASS, notify)
+
+ g_type_class_unref (gtk_settings_class);
+ }
+
+
+ {
+ GtkImageClass * gtk_image_class =
+ g_type_class_ref (GTK_TYPE_IMAGE);
+
+ INTERCEPT_CLASS_METHOD (gtk_image, G_OBJECT_CLASS, notify)
+
+ g_type_class_unref (gtk_image_class);
+ }
+
+
+ icon_sizes_table_quark = g_quark_from_string ("icon-sizes-table");
+}
+
+
+static void
+new_gtk_settings_notify
+(GObject * object,
+ GParamSpec * pspec)
+{
+ int * icon_sizes_table;
+ int i;
+ char * icon_sizes_string;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_settings, notify, (object, pspec));
+
+ if (strcmp (pspec->name, "gtk-icon-sizes") != 0)
+ return;
+
+ icon_sizes_table = g_object_get_qdata (object, icon_sizes_table_quark);
+ if (icon_sizes_table == NULL)
+ {
+ icon_sizes_table = calloc (GTK_ICON_SIZE_DIALOG + 1,
+ sizeof (int));
+ g_object_set_qdata_full (object, icon_sizes_table_quark,
+ icon_sizes_table, free_icon_sizes_table);
+ }
+
+ /* Initialize the icon sizes table */
+ for (i = 0; i <= GTK_ICON_SIZE_DIALOG; i++)
+ icon_sizes_table[i] = -1;
+
+ g_object_get (object, "gtk-icon-sizes", &icon_sizes_string, NULL);
+ if (icon_sizes_string)
+ parse_icon_sizes_string (icon_sizes_string, icon_sizes_table);
+}
+
+
+static void
+new_gtk_image_notify
+(GObject * object,
+ GParamSpec * pspec)
+{
+ GtkSettings * settings;
+ GtkImage * image;
+ GtkWidget * image_parent;
+ char * stock_id;
+ int pixel_size;
+ GtkIconSize icon_size;
+ int * icon_sizes_table;
+ int i;
+ char * icon_sizes_string;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_image, notify, (object, pspec));
+
+
+ image = GTK_IMAGE (object);
+
+ if (strcmp (pspec->name, "stock") == 0)
+ {
+ g_object_get (object, "stock", &stock_id, NULL);
+ g_object_get (object, "icon-size", &icon_size, NULL);
+ if (stock_id != NULL)
+ {
+ g_object_freeze_notify (object);
+ gtk_image_set_from_icon_name (image, stock_id, icon_size);
+ g_object_thaw_notify (object);
+ }
+ return;
+ }
+ else if (strcmp (pspec->name, "pixel-size") == 0)
+ {
+ pixel_size = gtk_image_get_pixel_size (image);
+ if (pixel_size == 0)
+ gtk_image_set_pixel_size (image, -1);
+ else if (pixel_size != 16)
+ return;
+ image_parent = gtk_widget_get_parent (GTK_WIDGET (object));
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
+ if (image_parent != NULL &&
+ GTK_IS_IMAGE_MENU_ITEM (image_parent))
+ {
+ g_object_set (object,
+ "icon-size", GTK_ICON_SIZE_MENU,
+ NULL);
+ }
+ else
+ return;
+ G_GNUC_END_IGNORE_DEPRECATIONS;
+ }
+ else if (strcmp (pspec->name, "icon-size") != 0)
+ return;
+
+ g_object_get (object, "icon-size", &icon_size, NULL);
+ if (icon_size <= GTK_ICON_SIZE_INVALID ||
+ icon_size > GTK_ICON_SIZE_DIALOG)
+ return;
+
+ icon_sizes_table = g_object_get_qdata (object, icon_sizes_table_quark);
+ if (icon_sizes_table == NULL)
+ {
+ icon_sizes_table = calloc (GTK_ICON_SIZE_DIALOG + 1,
+ sizeof (int));
+ g_object_set_qdata_full (object, icon_sizes_table_quark,
+ icon_sizes_table, free_icon_sizes_table);
+
+ /* Initialize the icon sizes table */
+ for (i = 0; i <= GTK_ICON_SIZE_DIALOG; i++)
+ icon_sizes_table[i] = -1;
+
+ settings = gtk_widget_get_settings (GTK_WIDGET (image));
+ g_object_get (G_OBJECT (settings),
+ "gtk-icon-sizes", &icon_sizes_string,
+ NULL);
+ if (icon_sizes_string)
+ parse_icon_sizes_string (icon_sizes_string, icon_sizes_table);
+ }
+
+ gtk_image_set_pixel_size (image, icon_sizes_table[icon_size]);
+}
+
+
+/* Helper functions */
+
+static void free_icon_sizes_table (gpointer data)
+{
+ free (data);
+}
+
+
+static void
+parse_error
+(const char * icon_sizes_string,
+ int position,
+ const char * error_message)
+{
+ g_warning (
+"Failed to parse GTK setting \'gtk-icon-sizes\' at character offset %d:\n"
+"%s\n"
+" %s\n"
+" %*.1s\n",
+ position, error_message, icon_sizes_string, position, "^");
+}
+
+
+static void
+parse_icon_sizes_string
+(char * icon_sizes_string,
+ int * icon_sizes_table)
+{
+ const char * size_names_table[] =
+ {
+ NULL,
+ "gtk-menu",
+ "gtk-small-toolbar",
+ "gtk-large-toolbar",
+ "gtk-button",
+ "gtk-dnd",
+ "gtk-dialog",
+ NULL
+ };
+
+ int i;
+ int j;
+ char * size_name;
+ int size_name_length;
+ char * p;
+ long width;
+ long height;
+
+
+ i = 0;
+ while (icon_sizes_string[i] != '\0')
+ {
+ /* Skip over any spaces preceding the icon size name */
+ while (isspace (icon_sizes_string[i]))
+ i++;
+
+ /* Collect the size name */
+ size_name = &icon_sizes_string[i];
+ size_name_length = 0;
+ while (isalnum (size_name[size_name_length]) ||
+ size_name[size_name_length] == '-' ||
+ size_name[size_name_length] == '_')
+ size_name_length++;
+ size_name = strndup (size_name, size_name_length);
+
+ /* Skip over any spaces following the icon size name */
+ i += size_name_length;
+ while (isspace (icon_sizes_string[i]))
+ i++;
+
+ if (icon_sizes_string[i] != '=')
+ {
+ parse_error (icon_sizes_string, i, "Expected \'=\'");
+ free (size_name);
+ return;
+ }
+ else
+ i++;
+
+ /* Read the icon width and height */
+ width = 0;
+ height = 0;
+ width = strtol (&icon_sizes_string[i], &p, 0);
+ while (isspace (*p))
+ p++;
+ if (*p == ',')
+ height = strtol (p+1, &p, 0);
+ if (height <= 0)
+ height = width;
+
+ if (*p == ':')
+ p++;
+ i = p - icon_sizes_string;
+
+
+ for (j = 1; size_names_table[j] != NULL; j++)
+ if (strcmp (size_name, size_names_table[j]) == 0)
+ break;
+
+ if (size_names_table[j] == NULL)
+ {
+ parse_error (icon_sizes_string, i,
+ "Unknown icon size name");
+ }
+ else if (width <= 0 || width > 256)
+ {
+ parse_error (icon_sizes_string, i,
+ "Icon width is suspicious, should be"
+ " between 1 and 256 px");
+ }
+ else if (height <= 0 || height > 256)
+ {
+ parse_error (icon_sizes_string, i,
+ "Icon height is suspicious, should be"
+ " between 1 and 256 px");
+ }
+ else
+ {
+ icon_sizes_table[j] = (int) MAX (width, height);
+ }
+
+
+ free (size_name);
+ }
+}
diff --git a/patches/no-emojis.c b/patches/no-emojis.c
new file mode 100644
index 0000000..dc7dd89
--- /dev/null
+++ b/patches/no-emojis.c
@@ -0,0 +1,61 @@
+/* No Emojis:
+ * (from gtk3-classic patch 'other__hide-insert-emoji.patch')
+ *
+ * Hides the 'Insert Emoji' menu item found at the bottom of the context menus
+ * for GtkEntry and GtkTextView widgets.
+ *
+ * Set the environment variable GTKM_INSERT_EMOJI=1 to restore the menu items.
+ */
+
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <gtk3-classic.h>
+
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "Gtk3-Classic::No-Emojis"
+
+
+INTERCEPTED_CLASS_METHOD (gtk_menu_item, show,
+ (GtkWidget * widget),
+ void)
+
+
+void no_emojis_init ()
+{
+ GtkMenuItemClass * gtk_menu_item_class =
+ g_type_class_ref (GTK_TYPE_MENU_ITEM);
+
+ INTERCEPT_CLASS_METHOD (
+ gtk_menu_item, GTK_WIDGET_CLASS, show)
+
+ g_type_class_unref (gtk_menu_item_class);
+}
+
+
+static void
+new_gtk_menu_item_show
+(GtkWidget * widget)
+
+{
+ const char * gtkm_insert_emoji;
+ const char * label;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_menu_item, show,
+ (widget));
+
+
+ gtkm_insert_emoji = getenv ("GTKM_INSERT_EMOJI");
+ if (gtkm_insert_emoji != NULL && strcmp (gtkm_insert_emoji, "1") == 0)
+ return;
+
+ label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget));
+ if (label != NULL && strcmp (label, _("Insert _Emoji")) == 0)
+ gtk_widget_hide (widget);
+}
diff --git a/patches/persistent-mnemonics.c b/patches/persistent-mnemonics.c
new file mode 100644
index 0000000..311815e
--- /dev/null
+++ b/patches/persistent-mnemonics.c
@@ -0,0 +1,100 @@
+/* Persistent mnemonics:
+ * (from 'sgm-flexible-mnemonics.c' [https://github.com/thesquash/sgm])
+ *
+ * Restores the behaviour of the GTK setting 'gtk-auto-mnemonics'. When this
+ * setting is set (TRUE, the default), mnemonic letters on buttons and menu
+ * items will be underlined only while the <Alt> key is pressed; when unset
+ * (FALSE), mnemonics will always be underlined.
+ *
+ * Enable the latter behaviour by adding to your settings.ini file:
+ *
+ * gtk-auto-mnemonics = 0
+ */
+
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <gtk3-classic.h>
+
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "Gtk3-Classic::Persistent-Mnemonics"
+
+
+INTERCEPTED_CLASS_METHOD (gtk_window, notify,
+ (GObject * object,
+ GParamSpec * pspec),
+ void)
+
+
+INTERCEPTED_CLASS_METHOD (gtk_menu_shell, deactivate,
+ (GtkMenuShell * menu_shell),
+ void)
+
+
+void persistent_mnemonics_init ()
+{
+ {
+ GtkWindowClass * gtk_window_class =
+ g_type_class_ref (GTK_TYPE_WINDOW);
+
+ INTERCEPT_CLASS_METHOD (gtk_window, G_OBJECT_CLASS, notify)
+
+ g_type_class_unref (gtk_window_class);
+ }
+
+
+ {
+ GtkMenuShellClass * gtk_menu_shell_class =
+ g_type_class_ref (GTK_TYPE_MENU_SHELL);
+
+ INTERCEPT_CLASS_METHOD (gtk_menu_shell, GTK_MENU_SHELL_CLASS,
+ deactivate)
+
+ g_type_class_unref (gtk_menu_shell_class);
+ }
+}
+
+
+static void
+new_gtk_window_notify
+(GObject * object,
+ GParamSpec * pspec)
+{
+ GtkSettings * settings;
+ gboolean auto_mnemonics;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_window, notify, (object, pspec));
+
+ if (strcmp (pspec->name, "mnemonics-visible") != 0)
+ return;
+
+ if (! gtk_window_get_mnemonics_visible (GTK_WINDOW (object)))
+ {
+ settings = gtk_widget_get_settings (GTK_WIDGET (object));
+ g_object_get (settings,
+ "gtk-auto-mnemonics", &auto_mnemonics,
+ NULL);
+ if (! auto_mnemonics)
+ gtk_window_set_mnemonics_visible (GTK_WINDOW (object),
+ TRUE);
+ }
+}
+
+
+static void
+new_gtk_menu_shell_deactivate
+(GtkMenuShell * menu_shell)
+{
+ GtkWidget * toplevel;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_menu_shell, deactivate, (menu_shell));
+
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu_shell));
+ if (toplevel)
+ g_object_notify (G_OBJECT (toplevel), "mnemonics-visible");
+}
diff --git a/patches/smaller-widgets.c b/patches/smaller-widgets.c
new file mode 100644
index 0000000..3b9888f
--- /dev/null
+++ b/patches/smaller-widgets.c
@@ -0,0 +1,262 @@
+/* Smaller Widgets:
+ * (based on gtk3-classic CSS 'smaller-adwaita.css', and gtk3-classic patch
+ * 'appearance__smaller-statusbar.patch'):
+ *
+ * Reduces the size of certain widgets, especially when the built-in GTK themes
+ * (Adwaita and HighContrast) are in use, in the spirit of more traditional
+ * GTK themes for prior versions of GTK.
+ */
+
+
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <glib.h>
+
+#include <string.h>
+
+#include <gtk3-classic.h>
+
+
+#undef G_LOG_DOMAIN
+#define G_LOG_DOMAIN "Gtk3-Classic::Smaller-Widgets"
+
+
+#define CSS \
+ "button,\n" \
+ "button.titlebutton,\n" \
+ "button.image-button,\n" \
+ "button.text-button,\n" \
+ "button.image-button.text-button,\n" \
+ ".stack-switcher > button.text-button {\n" \
+ " padding: 3px 6px;\n" \
+ " min-height: 20px;\n" \
+ " min-width: 0;\n" \
+ "}\n" \
+ ".stack-switcher > button.text-button {\n" \
+ " min-width: 80px;\n" \
+ "}\n" \
+ "button.text-button.image-button label {\n" \
+ " padding: 0 2px;\n" \
+ "}\n" \
+ "notebook > header.top tab,\n" \
+ "notebook > header.bottom tab {\n" \
+ " padding: 0 5px;\n" \
+ "}\n" \
+ "notebook > header.left tab,\n" \
+ "notebook > header.right tab {\n" \
+ " padding: 0 8px;\n" \
+ "}\n" \
+ "notebook tab button {\n" \
+ " padding: 0px;\n" \
+ " min-height: 15px;\n" \
+ "}\n" \
+ "entry,\n" \
+ "spinbutton:not(.vertical) {\n" \
+ " min-height: 26px;\n" \
+ "}\n" \
+ "treeview button {\n" \
+ " padding: 0 7px;\n" \
+ " min-height: 23px;\n" \
+ "}\n" \
+ "progressbar.horizontal trough,\n" \
+ "progressbar.horizontal progress,\n" \
+ "progressbar.vertical trough,\n" \
+ "progressbar.vertical progress,\n" \
+ "levelbar trough {\n" \
+ " min-height: 9px;\n" \
+ " min-width: 9px;\n" \
+ "}\n" \
+ "scale {\n" \
+ " padding: 10px 0;\n" \
+ "}\n" \
+ "headerbar, switch slider {\n" \
+ " min-height: 0;\n" \
+ "}\n" \
+ "popover:not(.emoji-picker) > *:not(grid) {\n" \
+ " margin: -3px;\n" \
+ "}\n" \
+ "tooltip * {\n" \
+ " padding: 0px;\n" \
+ "}\n" \
+ "placessidebar row {\n" \
+ " min-height: 29px;\n" \
+ "}\n" \
+ "placessidebar row button.sidebar-button {\n" \
+ " min-height: 20px;\n" \
+ " min-width: 20px;\n" \
+ " padding: 0;\n" \
+ "}\n" \
+ "filechooser > box.search-bar, filechooser > box:last-child {\n" \
+ " border-bottom: 1px solid alpha(#000, 0.15);\n" \
+ "}\n" \
+ "filechooser > actionbar > revealer > box {\n" \
+ " border-top: 1px solid alpha(#000, 0.15);\n" \
+ "}\n" \
+ "* {\n" \
+ " -GtkDialog-action-area-border: 5;\n" \
+ "}\n" \
+ "messagedialog > box {\n" \
+ " padding: 7px;\n" \
+ "}\n" \
+ "messagedialog buttonbox {\n" \
+ " margin-top: -17px;\n" \
+ "}\n" \
+ "menu, .menu, .context-menu, tooltip {\n" \
+ " border-radius: 0;\n" \
+ "}\n" \
+ ".background:not(.csd):not(.solid-csd) .titlebar:not(.default-decoration),\n" \
+ ".background:not(.csd):not(.solid-csd) .titlebar:not(.default-decoration) headerbar {\n" \
+ " background: inherit;\n" \
+ "}\n" \
+ "entry undershoot.left,\n" \
+ "entry undershoot.right,\n" \
+ "spinbutton:not(.vertical) undershoot.left,\n" \
+ "spinbutton:not(.vertical) undershoot.right,\n" \
+ "scrolledwindow undershoot.left,\n" \
+ "scrolledwindow undershoot.right,\n" \
+ "scrolledwindow undershoot.top,\n" \
+ "scrolledwindow undershoot.bottom {\n" \
+ " background-image: none;\n" \
+ "}\n"
+
+
+INTERCEPTED_CLASS_METHOD (gtk_settings, notify,
+ (GObject * object,
+ GParamSpec * pspec),
+ void)
+
+
+INTERCEPTED_CLASS_METHOD (gtk_window, constructed,
+ (GObject * object),
+ void)
+
+
+INTERCEPTED_CLASS_METHOD (gtk_statusbar, constructed,
+ (GObject * object),
+ void)
+
+
+void smaller_widgets_init ()
+{
+ {
+ GtkSettingsClass * gtk_settings_class =
+ g_type_class_ref (GTK_TYPE_SETTINGS);
+
+ INTERCEPT_CLASS_METHOD (gtk_settings, G_OBJECT_CLASS,
+ notify)
+
+ g_type_class_unref (gtk_settings_class);
+ }
+
+
+ {
+ GtkWindowClass * gtk_window_class =
+ g_type_class_ref (GTK_TYPE_WINDOW);
+
+ INTERCEPT_CLASS_METHOD (gtk_window, G_OBJECT_CLASS,
+ constructed)
+
+ g_type_class_unref (gtk_window_class);
+ }
+
+
+ {
+ GtkStatusbarClass * gtk_statusbar_class =
+ g_type_class_ref (GTK_TYPE_STATUSBAR);
+
+ INTERCEPT_CLASS_METHOD (gtk_statusbar, G_OBJECT_CLASS,
+ constructed)
+
+ g_type_class_unref (gtk_statusbar_class);
+ }
+}
+
+
+static void
+new_gtk_settings_notify
+(GObject * object,
+ GParamSpec * pspec)
+{
+ const char * theme_name;
+ GdkScreen * screen;
+ GtkCssProvider * provider;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_settings, notify, (object, pspec));
+
+
+ if (strcmp (pspec->name, "gtk-theme-name") != 0)
+ return;
+
+ g_object_get (object, "gtk-theme-name", &theme_name, NULL);
+
+ screen = g_object_get_data (object, "screen");
+ if (screen == NULL)
+ return;
+
+ provider = g_object_get_data (G_OBJECT (screen),
+ "smaller-adwaita-css");
+ if (provider == NULL)
+ return;
+
+ if (strcmp (theme_name, "Adwaita") == 0 ||
+ strcmp (theme_name, "Adwaita-Dark") == 0 ||
+ strcmp (theme_name, "HighContrast") == 0 ||
+ strcmp (theme_name, "HighContrastInverse") == 0)
+ gtk_style_context_add_provider_for_screen (screen,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
+ else
+ gtk_style_context_remove_provider_for_screen (screen,
+ GTK_STYLE_PROVIDER (provider));
+}
+
+
+static void
+new_gtk_window_constructed
+(GObject * object)
+{
+ GdkScreen * screen;
+ GtkCssProvider * provider;
+ GtkSettings * settings;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_window, constructed, (object));
+
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (object));
+ provider = g_object_get_data (G_OBJECT (screen),
+ "smaller-adwaita-css");
+ if (provider == NULL)
+ {
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider, CSS, -1, NULL);
+ g_object_set_data (G_OBJECT (screen),
+ "smaller-adwaita-css",
+ provider);
+
+ settings = gtk_settings_get_for_screen (screen);
+ g_object_set_data (G_OBJECT (settings), "screen", screen);
+ g_object_notify (G_OBJECT (settings),
+ "gtk-theme-name");
+ }
+
+}
+
+
+static void
+new_gtk_statusbar_constructed
+(GObject * object)
+{
+ GtkStyleContext * style_context;
+
+
+ CALL_ORIGINAL_CLASS_METHOD (gtk_statusbar, constructed, (object));
+
+
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (object));
+ gtk_style_context_add_class (style_context, "classic");
+
+ gtk_widget_set_margin_top (GTK_WIDGET (object), 1);
+ gtk_widget_set_margin_bottom (GTK_WIDGET (object), 1);
+}
bgstack15