@@ -73,6 +73,28 @@ static void wig_application_add_new_tab_with_uri(WigApplication *app, WigWindow
7373 webkit_web_view_load_uri (web_view , uri );
7474}
7575
76+ void wig_application_open_internal_page (WigApplication * app , GtkWindow * win , const char * uri )
77+ {
78+ if (win && wig_window_focus_tab_by_site (WIG_WINDOW (win ), uri ))
79+ return ;
80+
81+ for (GList * l = gtk_application_get_windows (GTK_APPLICATION (app )); l ; l = l -> next ) {
82+ if (l -> data == win )
83+ continue ;
84+
85+ if (wig_window_focus_tab_by_site (WIG_WINDOW (l -> data ), uri )) {
86+ gtk_window_present (GTK_WINDOW (l -> data ));
87+ return ;
88+ }
89+ }
90+
91+ if (!win )
92+ win = gtk_application_get_active_window (GTK_APPLICATION (app ));
93+
94+ if (win )
95+ wig_application_add_new_tab_with_uri (app , WIG_WINDOW (win ), uri );
96+ }
97+
7698static gboolean uri_should_be_recorded (const char * uri )
7799{
78100 if (!uri || !* uri )
@@ -230,13 +252,7 @@ static gboolean on_decide_destination(WebKitDownload *download, const char *sugg
230252 g_autofree char * path = g_build_filename (dir ? dir : fallback , suggested_filename , NULL );
231253 webkit_download_set_destination (download , path );
232254
233- for (GList * l = gtk_application_get_windows (GTK_APPLICATION (app )); l ; l = l -> next ) {
234- if (wig_window_focus_tab_by_site (WIG_WINDOW (l -> data ), "wig:downloads" ))
235- return TRUE;
236- }
237-
238- GtkWindow * active = gtk_application_get_active_window (GTK_APPLICATION (app ));
239- wig_application_add_new_tab_with_uri (app , WIG_WINDOW (active ), "wig:downloads" );
255+ wig_application_open_internal_page (app , NULL , "wig:downloads" );
240256 return TRUE;
241257}
242258
@@ -426,6 +442,8 @@ static void wig_application_startup(GApplication *application)
426442 { "win.find" , { "<Primary>f" , NULL } },
427443 { "win.find-next" , { "<Primary>g" , "F3" , NULL } },
428444 { "win.find-previous" , { "<Primary><Shift>g" , "<Shift>F3" , NULL } },
445+ { "win.show-downloads" , { "<Primary>j" , NULL } },
446+ { "win.show-history" , { "<Primary>h" , NULL } },
429447
430448 };
431449
0 commit comments