[Xfce4-commits] [apps/xfce4-terminal] 01/01: Use TerminalTabAttr for closed tabs info
noreply at xfce.org
noreply at xfce.org
Fri May 25 16:35:03 CEST 2018
This is an automated email from the git hooks/post-receive script.
f 2 4 0 4 p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-terminal.
commit 39ac0d079a989618163163b0e131d92fe44c05b9
Author: Igor <f2404 at yandex.ru>
Date: Fri May 25 10:34:06 2018 -0400
Use TerminalTabAttr for closed tabs info
---
terminal/terminal-options.c | 37 +++++++++++++++------------
terminal/terminal-options.h | 3 +++
terminal/terminal-window.c | 62 +++++++++++++++------------------------------
3 files changed, 44 insertions(+), 58 deletions(-)
diff --git a/terminal/terminal-options.c b/terminal/terminal-options.c
index 0661468..7f2b541 100644
--- a/terminal/terminal-options.c
+++ b/terminal/terminal-options.c
@@ -128,22 +128,6 @@ terminal_option_show_hide_cmp (const gchar *long_name,
-static void
-terminal_tab_attr_free (TerminalTabAttr *attr)
-{
- terminal_return_if_fail (attr != NULL);
-
- g_strfreev (attr->command);
- g_free (attr->directory);
- g_free (attr->title);
- g_free (attr->initial_title);
- g_free (attr->color_text);
- g_free (attr->color_bg);
- g_slice_free (TerminalTabAttr, attr);
-}
-
-
-
void
terminal_options_parse (gint argc,
gchar **argv,
@@ -649,6 +633,7 @@ terminal_window_attr_new (void)
tab_attr = g_slice_new0 (TerminalTabAttr);
tab_attr->dynamic_title_mode = TERMINAL_TITLE_DEFAULT;
+ tab_attr->position = -1;
win_attr->tabs = g_slist_prepend (NULL, tab_attr);
return win_attr;
@@ -657,6 +642,26 @@ terminal_window_attr_new (void)
/**
+ * terminal_tab_attr_free:
+ * @attr : A #TerminalTabAttr.
+ **/
+void
+terminal_tab_attr_free (TerminalTabAttr *attr)
+{
+ terminal_return_if_fail (attr != NULL);
+
+ g_strfreev (attr->command);
+ g_free (attr->directory);
+ g_free (attr->title);
+ g_free (attr->initial_title);
+ g_free (attr->color_text);
+ g_free (attr->color_bg);
+ g_slice_free (TerminalTabAttr, attr);
+}
+
+
+
+/**
* terminal_window_attr_free:
* @attr : A #TerminalWindowAttr.
**/
diff --git a/terminal/terminal-options.h b/terminal/terminal-options.h
index a27068b..4fb1314 100644
--- a/terminal/terminal-options.h
+++ b/terminal/terminal-options.h
@@ -61,6 +61,7 @@ typedef struct
gchar *color_text;
gchar *color_bg;
TerminalTitle dynamic_title_mode;
+ gint position;
guint hold : 1;
guint active : 1;
} TerminalTabAttr;
@@ -107,6 +108,8 @@ GSList *terminal_window_attr_parse (gint argc,
TerminalWindowAttr *terminal_window_attr_new (void);
+void terminal_tab_attr_free (TerminalTabAttr *attr);
+
void terminal_window_attr_free (TerminalWindowAttr *attr);
G_END_DECLS
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index 5f71678..a130a37 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -53,15 +53,6 @@
-/* Closed tabs stored info */
-typedef struct
-{
- gchar *custom_title;
- gchar *working_directory;
- gint position;
- gboolean was_active;
-} TerminalWindowTabInfo;
-
/* Signal identifiers */
enum
{
@@ -249,7 +240,6 @@ static void terminal_window_switch_tab (GtkNotebook
gboolean switch_left);
static void terminal_window_move_tab (GtkNotebook *notebook,
gboolean move_left);
-static void terminal_window_tab_info_free (TerminalWindowTabInfo *tab_info);
static void terminal_window_toggle_menubar (GtkWidget *widget,
TerminalWindow *window);
static void terminal_window_menubar_deactivate (GtkWidget *widget,
@@ -608,7 +598,7 @@ terminal_window_finalize (GObject *object)
g_slist_free (window->priv->tabs_menu_actions);
g_free (window->priv->font);
- g_queue_free_full (window->priv->closed_tabs_list, (GDestroyNotify) terminal_window_tab_info_free);
+ g_queue_free_full (window->priv->closed_tabs_list, (GDestroyNotify) terminal_tab_attr_free);
(*G_OBJECT_CLASS (terminal_window_parent_class)->finalize) (object);
}
@@ -1108,13 +1098,14 @@ terminal_window_close_tab_request (TerminalScreen *screen,
if (terminal_window_confirm_close (screen, window))
{
/* store info on the tab being closed */
- TerminalWindowTabInfo *tab_info = g_new (TerminalWindowTabInfo, 1);
- tab_info->was_active = (screen == window->priv->active);
- tab_info->position = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (screen));
- tab_info->working_directory = g_strdup (terminal_screen_get_working_directory (screen));
- tab_info->custom_title = IS_STRING (terminal_screen_get_custom_title (screen)) ?
- g_strdup (terminal_screen_get_custom_title (screen)) : NULL;
- g_queue_push_tail (window->priv->closed_tabs_list, tab_info);
+ TerminalTabAttr *tab_attr = g_slice_new0 (TerminalTabAttr);
+ tab_attr->active = (screen == window->priv->active);
+ tab_attr->dynamic_title_mode = TERMINAL_TITLE_DEFAULT;
+ tab_attr->position = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (screen));
+ tab_attr->directory = g_strdup (terminal_screen_get_working_directory (screen));
+ tab_attr->title = IS_STRING (terminal_screen_get_custom_title (screen)) ?
+ g_strdup (terminal_screen_get_custom_title (screen)) : NULL;
+ g_queue_push_tail (window->priv->closed_tabs_list, tab_attr);
gtk_widget_destroy (GTK_WIDGET (screen));
}
@@ -1622,34 +1613,31 @@ static void
terminal_window_action_undo_close_tab (GtkAction *action,
TerminalWindow *window)
{
- TerminalScreen *terminal;
- TerminalWindowTabInfo *tab_info;
- GtkWidget *current = GTK_WIDGET (window->priv->active);
+ TerminalScreen *terminal;
+ TerminalTabAttr *tab_attr;
+ GtkWidget *current = GTK_WIDGET (window->priv->active);
if (G_UNLIKELY (g_queue_is_empty (window->priv->closed_tabs_list)))
return;
- terminal = TERMINAL_SCREEN (g_object_new (TERMINAL_TYPE_SCREEN, NULL));
- terminal_window_add (window, terminal);
-
/* get info on the last closed tab and remove it from the list */
- tab_info = g_queue_pop_tail (window->priv->closed_tabs_list);
+ tab_attr = g_queue_pop_tail (window->priv->closed_tabs_list);
+
+ terminal = terminal_screen_new (tab_attr, window->priv->grid_width, window->priv->grid_height);
+ terminal_window_add (window, terminal);
- /* set info to the new tab */
- terminal_screen_set_working_directory (terminal, tab_info->working_directory);
- if (tab_info->custom_title != NULL)
- terminal_screen_set_custom_title (terminal, tab_info->custom_title);
- gtk_notebook_reorder_child (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (terminal), tab_info->position);
+ /* set unclosed tab position */
+ gtk_notebook_reorder_child (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (terminal), tab_attr->position);
/* restore tab focus if the unclosed one wasn't active when it was closed */
- if (!tab_info->was_active)
+ if (!tab_attr->active)
{
gint page_num = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), current);
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), page_num);
}
/* free info */
- terminal_window_tab_info_free (tab_info);
+ terminal_tab_attr_free (tab_attr);
terminal_window_update_actions (window);
terminal_screen_launch_child (terminal);
@@ -2482,16 +2470,6 @@ terminal_window_move_tab (GtkNotebook *notebook,
static void
-terminal_window_tab_info_free (TerminalWindowTabInfo *tab_info)
-{
- g_free (tab_info->custom_title);
- g_free (tab_info->working_directory);
- g_free (tab_info);
-}
-
-
-
-static void
terminal_window_toggle_menubar (GtkWidget *widget,
TerminalWindow *window)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list