[epiphany/wip/exalm/tabs] Remove alt+numbers
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/tabs] Remove alt+numbers
- Date: Tue, 15 Sep 2020 22:43:19 +0000 (UTC)
commit 8179f0adeb3f4ed45e9ec73e0d6a142aea0095d0
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Sep 16 03:42:56 2020 +0500
Remove alt+numbers
They are now in libhandy
src/ephy-tab-view.c | 31 +++++++++++++++++++
src/ephy-window.c | 86 -----------------------------------------------------
2 files changed, 31 insertions(+), 86 deletions(-)
---
diff --git a/src/ephy-tab-view.c b/src/ephy-tab-view.c
index 2123a4258..c927770e5 100644
--- a/src/ephy-tab-view.c
+++ b/src/ephy-tab-view.c
@@ -556,11 +556,37 @@ expand_changed_cb (EphyTabView *self)
hdy_tab_bar_set_expand_tabs (self->tab_bar, expand);
}
+static gboolean
+is_layout_reversed (void)
+{
+ GtkSettings *settings;
+ g_autofree char *layout = NULL;
+ g_auto (GStrv) parts = NULL;
+
+ settings = gtk_settings_get_default ();
+ g_object_get (settings, "gtk-decoration-layout", &layout, NULL);
+
+ parts = g_strsplit (layout, ":", 2);
+
+ /* Invalid layout, don't even try */
+ if (g_strv_length (parts) < 2)
+ return FALSE;
+
+ return !!g_strrstr (parts[0], "close");
+}
+
+static void
+notify_decoration_layout_cb (EphyTabView *self)
+{
+ hdy_tab_bar_set_inverted (self->tab_bar, is_layout_reversed ());
+}
+
void
ephy_tab_view_set_tab_bar (EphyTabView *self,
HdyTabBar *tab_bar)
{
GtkTargetList *target_list;
+ GtkSettings *settings;
static const GtkTargetEntry url_drag_types [] = {
{ (char *)EPHY_DND_URI_LIST_TYPE, 0, 0 },
{ (char *)EPHY_DND_URL_TYPE, 0, 1 },
@@ -606,5 +632,10 @@ ephy_tab_view_set_tab_bar (EphyTabView *self,
G_CONNECT_SWAPPED);
}
+ settings = gtk_settings_get_default ();
+ g_signal_connect_object (settings, "notify::gtk-decoration-layout",
+ G_CALLBACK (notify_decoration_layout_cb), self,
+ G_CONNECT_SWAPPED);
+
visibility_policy_changed_cb (self);
}
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 6e64e8782..236b1fc3f 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2558,85 +2558,6 @@ ephy_window_set_active_tab (EphyWindow *window,
ephy_window_connect_active_embed (window);
}
-static void
-tab_accels_item_activate (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- const char *action_name;
- int tab_number;
-
- action_name = g_action_get_name (G_ACTION (action));
-
- tab_number = atoi (action_name + strlen ("accel-"));
-
- ephy_tab_view_select_nth_page (EPHY_WINDOW (user_data)->tab_view, tab_number);
-}
-
-static void
-tab_accels_update (EphyWindow *window)
-{
- int n_pages;
- int i = 0;
- GActionGroup *action_group;
- char **actions;
-
- action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "tab");
- actions = g_action_group_list_actions (action_group);
-
- n_pages = ephy_tab_view_get_n_pages (window->tab_view);
- for (i = 0; actions[i] != NULL; i++) {
- if (strstr (actions[i], "accel-") != NULL) {
- GAction *action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- actions[i]);
- int tab_number = atoi (actions[i] + strlen ("accel-"));
-
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), (tab_number < n_pages));
- }
- }
-
- g_strfreev (actions);
-}
-
-#define TAB_ACCELS_N 10
-
-static void
-setup_tab_accels (EphyWindow *window)
-{
- GActionGroup *action_group;
- GApplication *app;
- guint i;
-
- action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "tab");
- app = g_application_get_default ();
-
- for (i = 0; i < TAB_ACCELS_N; i++) {
- GSimpleAction *simple_action;
- char *action_name;
- char *action_name_with_tab;
- char *accel;
-
- action_name = g_strdup_printf ("accel-%u", i);
- action_name_with_tab = g_strconcat ("tab.", action_name, NULL);
- accel = g_strdup_printf ("<alt>%u", (i + 1) % TAB_ACCELS_N);
-
- simple_action = g_simple_action_new (action_name, NULL);
-
- g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (simple_action));
- gtk_application_set_accels_for_action (GTK_APPLICATION (app),
- action_name_with_tab,
- (const gchar *[]) {accel, NULL});
-
- g_signal_connect (G_ACTION (simple_action), "activate",
- G_CALLBACK (tab_accels_item_activate), window);
-
- g_object_unref (simple_action);
- g_free (accel);
- g_free (action_name);
- g_free (action_name_with_tab);
- }
-}
-
static void
tab_view_setup_menu_cb (HdyTabView *tab_view,
HdyTabPage *page,
@@ -2782,8 +2703,6 @@ tab_view_page_attached_cb (HdyTabView *tab_view,
window->present_on_insert = FALSE;
g_idle_add ((GSourceFunc)present_on_idle_cb, g_object_ref (window));
}
-
- tab_accels_update (window);
}
static void
@@ -2804,8 +2723,6 @@ tab_view_page_detached_cb (HdyTabView *tab_view,
g_signal_handlers_disconnect_by_func
(ephy_embed_get_web_view (EPHY_EMBED (content)), G_CALLBACK (download_only_load_cb), window);
- tab_accels_update (window);
-
if (ephy_tab_view_get_n_pages (window->tab_view) == 0) {
EphyShell *shell = ephy_shell_get_default ();
GList *windows = gtk_application_get_windows (GTK_APPLICATION (shell));
@@ -3723,9 +3640,6 @@ ephy_window_constructed (GObject *object)
ephy_gui_ensure_window_group (GTK_WINDOW (window));
- /* Setup tab accels */
- setup_tab_accels (window);
-
window->tab_view = setup_tab_view (window);
window->tab_bar = hdy_tab_bar_new ();
window->tab_bar_revealer = GTK_REVEALER (gtk_revealer_new ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]