fengshui & add resize window shortcut
This commit is contained in:
parent
db9d3e66f2
commit
b138c2c83a
1
TODO.md
1
TODO.md
|
@ -10,6 +10,7 @@
|
||||||
- See whether it even exists at all
|
- See whether it even exists at all
|
||||||
- [ ] Finish cleaning up GTK4 version
|
- [ ] Finish cleaning up GTK4 version
|
||||||
- [ ] Think about best way of having GTK4 version alongside
|
- [ ] Think about best way of having GTK4 version alongside
|
||||||
|
- [ ] Shortcut to resize window
|
||||||
|
|
||||||
# Previously done
|
# Previously done
|
||||||
|
|
||||||
|
|
91
config.h
91
config.h
|
@ -1,22 +1,26 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
// #include <gdk/gdk.h> // <gdk/gdkenums.h>, <gdk/gdkkeysyms.h>
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
// #include "/usr/include/gtk-4.0/gtk/gtk.h"
|
|
||||||
|
|
||||||
// Key user config
|
/* Key user config */
|
||||||
#define WIDTH 1920 // 960 for half-width, 1920 for full width
|
#define FULL_WIDTH 1920
|
||||||
#define HEIGHT_GTK3 990 // GTK4 and GTK3 interpret this differently. In GTK4, this includes the height of the top bar
|
#define WIDTH FULL_WIDTH
|
||||||
#define HEIGHT_GTK4 1080 // GTK4 and GTK3 interpret this differently. In GTK4, this includes the height of the top bar
|
#define BAR_WIDTH FULL_WIDTH/2
|
||||||
#define BAR_SIZE 960
|
#define HEIGHT_GTK3 990
|
||||||
|
#define HEIGHT_GTK4 1080
|
||||||
|
// GTK4 and GTK3 interpret height differently.
|
||||||
|
// In GTK4, it includes the height of the top bar
|
||||||
|
|
||||||
// More user config
|
/* More user config */
|
||||||
#define ZOOM_START_LEVEL 2
|
#define ZOOM_START_LEVEL 1.8
|
||||||
#define ZOOM_STEPSIZE .1
|
#define ZOOM_STEPSIZE .1
|
||||||
#define MAX_NUM_TABS 8 // 0/false for unlimited tabs
|
#define MAX_NUM_TABS 8 // 0 or false for unlimited tabs
|
||||||
#define SEARCH "https://search.brave.com/search?q=%s" // "https://search.nunosempere.com/search?q=%s", "https://lite.duckduckgo.com/html/?q=%s"
|
#define SEARCH "https://search.brave.com/search?q=%s"
|
||||||
#define HOME "https://search.brave.com/search" // "file:///opt/rose/homepage.png", ""
|
#define HOME "https://search.brave.com/search"
|
||||||
|
// #define SEARCH "https://search.nunosempere.com/search?q=%s"
|
||||||
|
// #define SEARCH "https://lite.duckduckgo.com/html/?q=%s"
|
||||||
|
// #define HOME "file:///opt/rosenrot/flower-imgs/rose-homepage.png"
|
||||||
|
|
||||||
// Plugins
|
/* Plugins */
|
||||||
#define LIBRE_REDIRECT_ENABLED true
|
#define LIBRE_REDIRECT_ENABLED true
|
||||||
#define READABILITY_ENABLED true
|
#define READABILITY_ENABLED true
|
||||||
#define CUSTOM_USER_AGENT false
|
#define CUSTOM_USER_AGENT false
|
||||||
|
@ -33,26 +37,38 @@ To remove plugins completely;
|
||||||
You could also look into commit afe93518a for an approach using stand-in code.
|
You could also look into commit afe93518a for an approach using stand-in code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Webkit settings
|
/* Webkit */
|
||||||
// https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html
|
// https://webkitgtk.org/reference/webkit2gtk/stable/class.Settings.html
|
||||||
#define WEBKIT_DEFAULT_SETTINGS \
|
#define WEBKIT_DEFAULT_SETTINGS \
|
||||||
"enable-back-forward-navigation-gestures", true, "enable-developer-extras", true, \
|
"enable-back-forward-navigation-gestures", true, \
|
||||||
|
"enable-developer-extras", true, \
|
||||||
"enable-smooth-scrolling", false, \
|
"enable-smooth-scrolling", false, \
|
||||||
"default-charset", "utf-8"
|
"default-charset", "utf-8"
|
||||||
#define DATA_DIR "/home/nuno/.cache/rosenrot"
|
#define DATA_DIR "/home/nuno/.cache/rosenrot"
|
||||||
#define DATA_MANAGER_OPTS "base-cache-directory", DATA_DIR, "base-data-directory", DATA_DIR
|
#define DATA_MANAGER_OPTS "base-cache-directory", DATA_DIR, "base-data-directory", DATA_DIR
|
||||||
#define NETWORK_SESSION_OPTS DATA_DIR, DATA_DIR
|
#define NETWORK_SESSION_OPTS DATA_DIR, DATA_DIR
|
||||||
|
|
||||||
// GTK
|
/* GTK */
|
||||||
#define GTK_SETTINGS_CONFIG_H "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false
|
|
||||||
// https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkkeysyms.h
|
// https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkkeysyms.h
|
||||||
#define KEY(x) GDK_KEY_##x
|
|
||||||
// https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkenums.h
|
// https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gdk/gdkenums.h
|
||||||
|
#define GTK_SETTINGS_CONFIG_H "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false
|
||||||
|
#define KEY(x) GDK_KEY_##x
|
||||||
#define SFT 1 << 0
|
#define SFT 1 << 0
|
||||||
#define CTRL 1 << 2
|
#define CTRL 1 << 2
|
||||||
#define ALT 1 << 3
|
#define ALT 1 << 3
|
||||||
|
|
||||||
// Shortcuts
|
/* Misc helpers */
|
||||||
|
#define ABORT_REQUEST_ON_CURRENT_TAB NULL
|
||||||
|
#define NULLCHECK(x) \
|
||||||
|
do { \
|
||||||
|
if (x == NULL) { \
|
||||||
|
printf("\nNULL check not passed"); \
|
||||||
|
printf("@ %s (%d): ", __FILE__, __LINE__); \
|
||||||
|
exit(0); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/* Shortcuts */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
goback,
|
goback,
|
||||||
goforward,
|
goforward,
|
||||||
|
@ -80,6 +96,9 @@ typedef enum {
|
||||||
finder_next,
|
finder_next,
|
||||||
finder_prev,
|
finder_prev,
|
||||||
|
|
||||||
|
halve_window,
|
||||||
|
rebig_window,
|
||||||
|
|
||||||
prettify,
|
prettify,
|
||||||
} func;
|
} func;
|
||||||
|
|
||||||
|
@ -103,10 +122,11 @@ static struct {
|
||||||
{ CTRL, KEY(minus), zoomout },
|
{ CTRL, KEY(minus), zoomout },
|
||||||
{ CTRL, KEY(0), zoom_reset },
|
{ CTRL, KEY(0), zoom_reset },
|
||||||
|
|
||||||
{ CTRL, KEY(KP_Page_Up), prev_tab },
|
{ CTRL | SFT, KEY(KP_Page_Up), prev_tab }, // use SFT just to show one can
|
||||||
{ CTRL, KEY(KP_Page_Down), next_tab },
|
{ CTRL | SFT, KEY(KP_Page_Down), next_tab },
|
||||||
{ CTRL, KEY(Page_Up), prev_tab }, // working hypothesis: Page_UP vs KP_Page_Up might depend on whether the user has a numpad
|
{ CTRL | SFT, KEY(Page_Up), prev_tab },
|
||||||
{ CTRL, KEY(Page_Down), next_tab },
|
// working hypothesis: Page_UP vs KP_Page_Up might depend on whether the user has a numpad
|
||||||
|
{ CTRL | SFT, KEY(Page_Down), next_tab },
|
||||||
{ CTRL, KEY(t), new_tab },
|
{ CTRL, KEY(t), new_tab },
|
||||||
{ CTRL, KEY(w), close_tab },
|
{ CTRL, KEY(w), close_tab },
|
||||||
|
|
||||||
|
@ -115,28 +135,7 @@ static struct {
|
||||||
{ CTRL, KEY(f), show_finder },
|
{ CTRL, KEY(f), show_finder },
|
||||||
{ CTRL, KEY(n), finder_next },
|
{ CTRL, KEY(n), finder_next },
|
||||||
{ CTRL, KEY(N), finder_prev },
|
{ CTRL, KEY(N), finder_prev },
|
||||||
|
{ CTRL, KEY(Left), halve_window },
|
||||||
|
{ CTRL, KEY(Right), rebig_window },
|
||||||
{ CTRL, KEY(p), prettify }
|
{ CTRL, KEY(p), prettify }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Old controls: {
|
|
||||||
{ CTRL, KEY(h), goback },
|
|
||||||
{ CTRL, KEY(l), goforward },
|
|
||||||
{ CTRL, KEY(r), refresh },
|
|
||||||
{ CTRL | SFT, KEY(R), refresh_force },
|
|
||||||
{ CTRL | SFT, KEY(H), back_to_home },
|
|
||||||
{ CTRL, KEY(equal), zoomin },
|
|
||||||
{ CTRL, KEY(minus), zoomout },
|
|
||||||
{ CTRL, KEY(0), zoom_reset },
|
|
||||||
{ ALT, KEY(h), prev_tab },
|
|
||||||
{ CTRL, KEY(k), hide_searchbar },
|
|
||||||
{ ALT, KEY(l), next_tab },
|
|
||||||
{ CTRL, KEY(w), close_tab },
|
|
||||||
{ 0x0, KEY(F11), toggle_fullscreen },
|
|
||||||
{ CTRL, KEY(e), show_searchbar },
|
|
||||||
{ CTRL, KEY(f), show_finder },
|
|
||||||
{ CTRL, KEY(n), finder_next },
|
|
||||||
{ CTRL | SFT, KEY(N), finder_prev },
|
|
||||||
{ CTRL, KEY(p), prettify }
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
26
rosenrot4.c
26
rosenrot4.c
|
@ -6,21 +6,10 @@
|
||||||
#include "plugins/plugins.h"
|
#include "plugins/plugins.h"
|
||||||
#include <webkit/webkit.h>
|
#include <webkit/webkit.h>
|
||||||
|
|
||||||
#define NULLCHECK(x) \
|
|
||||||
do { \
|
|
||||||
if (x == NULL) { \
|
|
||||||
printf("\nNULL check not passed"); \
|
|
||||||
printf("@ %s (%d): ", __FILE__, __LINE__); \
|
|
||||||
exit(0); \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
static GtkNotebook* notebook;
|
static GtkNotebook* notebook;
|
||||||
static GtkWindow* window;
|
static GtkWindow* window;
|
||||||
typedef enum { _SEARCH,
|
typedef enum { _SEARCH, _FIND, _HIDDEN } Bar_entry_mode;
|
||||||
_FIND,
|
|
||||||
_HIDDEN } Bar_entry_mode;
|
|
||||||
static struct {
|
static struct {
|
||||||
GtkHeaderBar* widget;
|
GtkHeaderBar* widget;
|
||||||
GtkEntry* line;
|
GtkEntry* line;
|
||||||
|
@ -173,7 +162,8 @@ GtkWidget* handle_signal_create_new_tab(WebKitWebView* self,
|
||||||
} else {
|
} else {
|
||||||
webkit_web_view_evaluate_javascript(self, "alert('Too many tabs, not opening a new one')", -1, NULL, "rosenrot-alert-numtabs", NULL, NULL, NULL);
|
webkit_web_view_evaluate_javascript(self, "alert('Too many tabs, not opening a new one')", -1, NULL, "rosenrot-alert-numtabs", NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
return NULL; // Could also return GTK_WIDGET(self), in which case the new uri would also be loaded in the current webview.
|
return ABORT_REQUEST_ON_CURRENT_TAB;
|
||||||
|
// Could also return GTK_WIDGET(self), in which case the new uri would also be loaded in the current webview. This could be interesting if I wanted to e.g., open an alternative frontend in a new tab
|
||||||
}
|
}
|
||||||
|
|
||||||
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri)
|
void notebook_create_new_tab(GtkNotebook* notebook, const char* uri)
|
||||||
|
@ -359,6 +349,14 @@ int handle_shortcut(func id)
|
||||||
toggle_bar(notebook, _HIDDEN);
|
toggle_bar(notebook, _HIDDEN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case halve_window:
|
||||||
|
gtk_window_set_default_size(window, FULL_WIDTH/2, HEIGHT_GTK4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case rebig_window:
|
||||||
|
gtk_window_set_default_size(window, FULL_WIDTH, HEIGHT_GTK4);
|
||||||
|
break;
|
||||||
|
|
||||||
case prettify: {
|
case prettify: {
|
||||||
if (READABILITY_ENABLED) {
|
if (READABILITY_ENABLED) {
|
||||||
char* readability_js = malloc(READABILITY_N + 1);
|
char* readability_js = malloc(READABILITY_N + 1);
|
||||||
|
@ -417,7 +415,7 @@ int main(int argc, char** argv)
|
||||||
bar.line_text = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0));
|
bar.line_text = GTK_ENTRY_BUFFER(gtk_entry_buffer_new("", 0));
|
||||||
bar.line = GTK_ENTRY(gtk_entry_new_with_buffer(bar.line_text));
|
bar.line = GTK_ENTRY(gtk_entry_new_with_buffer(bar.line_text));
|
||||||
gtk_entry_set_alignment(bar.line, 0.48);
|
gtk_entry_set_alignment(bar.line, 0.48);
|
||||||
gtk_widget_set_size_request(GTK_WIDGET(bar.line), BAR_SIZE, -1);
|
gtk_widget_set_size_request(GTK_WIDGET(bar.line), BAR_WIDTH, -1);
|
||||||
|
|
||||||
bar.widget = GTK_HEADER_BAR(gtk_header_bar_new());
|
bar.widget = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||||
gtk_header_bar_set_title_widget(bar.widget, GTK_WIDGET(bar.line));
|
gtk_header_bar_set_title_widget(bar.widget, GTK_WIDGET(bar.line));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user