Disable the default tab bar menu for the main notebook widget and use a custom menu instead which lists all open files as usual plus 'Close Other Documents' and 'Close All' menu items.
Remove GeanyDocumentPrivate::tabmenu_label. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3615 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
c573d3cc22
commit
93b0278a52
@ -4,6 +4,12 @@
|
|||||||
Adjust minimum required GTK version.
|
Adjust minimum required GTK version.
|
||||||
* src/Makefile.am, wscript:
|
* src/Makefile.am, wscript:
|
||||||
Add main.h to the list of installed header files.
|
Add main.h to the list of installed header files.
|
||||||
|
* geany.glade, src/document.c, src/documentprivate.h, src/interface.c,
|
||||||
|
src/notebook.c, src/ui_utils.c:
|
||||||
|
Remove GeanyDocumentPrivate::tabmenu_label.
|
||||||
|
Disable the default tab bar menu for the main notebook widget and
|
||||||
|
use a custom menu instead which lists all open files as usual plus
|
||||||
|
'Close Other Documents' and 'Close All' menu items.
|
||||||
|
|
||||||
|
|
||||||
2009-02-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
2009-02-27 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||||
|
@ -1766,7 +1766,7 @@
|
|||||||
<property name="show_border">True</property>
|
<property name="show_border">True</property>
|
||||||
<property name="tab_pos">GTK_POS_TOP</property>
|
<property name="tab_pos">GTK_POS_TOP</property>
|
||||||
<property name="scrollable">True</property>
|
<property name="scrollable">True</property>
|
||||||
<property name="enable_popup">True</property>
|
<property name="enable_popup">False</property>
|
||||||
<signal name="switch_page" handler="on_notebook1_switch_page_after" after="yes" last_modification_time="Fri, 26 May 2006 11:47:25 GMT"/>
|
<signal name="switch_page" handler="on_notebook1_switch_page_after" after="yes" last_modification_time="Fri, 26 May 2006 11:47:25 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
@ -296,7 +296,6 @@ void document_update_tab_label(GeanyDocument *doc)
|
|||||||
parent = gtk_widget_get_parent(parent);
|
parent = gtk_widget_get_parent(parent);
|
||||||
|
|
||||||
gtk_label_set_text(GTK_LABEL(doc->priv->tab_label), base_name);
|
gtk_label_set_text(GTK_LABEL(doc->priv->tab_label), base_name);
|
||||||
gtk_label_set_text(GTK_LABEL(doc->priv->tabmenu_label), base_name);
|
|
||||||
|
|
||||||
ui_widget_set_tooltip_text(parent, DOC_FILENAME(doc));
|
ui_widget_set_tooltip_text(parent, DOC_FILENAME(doc));
|
||||||
|
|
||||||
|
@ -61,8 +61,6 @@ typedef struct GeanyDocumentPrivate
|
|||||||
{
|
{
|
||||||
/* GtkLabel shown in the notebook header. */
|
/* GtkLabel shown in the notebook header. */
|
||||||
GtkWidget *tab_label;
|
GtkWidget *tab_label;
|
||||||
/* GtkLabel shown in the notebook right-click menu. */
|
|
||||||
GtkWidget *tabmenu_label;
|
|
||||||
/* GtkTreeView object for this %document within the Symbols treeview of the sidebar. */
|
/* GtkTreeView object for this %document within the Symbols treeview of the sidebar. */
|
||||||
GtkWidget *tag_tree;
|
GtkWidget *tag_tree;
|
||||||
/* GtkTreeStore object for this %document within the Symbols treeview of the sidebar. */
|
/* GtkTreeStore object for this %document within the Symbols treeview of the sidebar. */
|
||||||
|
@ -1082,7 +1082,6 @@ create_window1 (void)
|
|||||||
gtk_widget_show (notebook1);
|
gtk_widget_show (notebook1);
|
||||||
gtk_paned_pack2 (GTK_PANED (hpaned1), notebook1, TRUE, TRUE);
|
gtk_paned_pack2 (GTK_PANED (hpaned1), notebook1, TRUE, TRUE);
|
||||||
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook1), TRUE);
|
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook1), TRUE);
|
||||||
gtk_notebook_popup_enable (GTK_NOTEBOOK (notebook1));
|
|
||||||
|
|
||||||
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
|
scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
|
||||||
gtk_widget_show (scrolledwindow1);
|
gtk_widget_show (scrolledwindow1);
|
||||||
|
@ -179,6 +179,73 @@ static gboolean is_position_on_tab_bar(GtkNotebook *notebook, GdkEventButton *ev
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void tab_bar_menu_activate_cb(GtkMenuItem *menuitem, gpointer data)
|
||||||
|
{
|
||||||
|
GeanyDocument *doc = data;
|
||||||
|
|
||||||
|
if (! DOC_VALID(doc))
|
||||||
|
return;
|
||||||
|
|
||||||
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
|
||||||
|
document_get_notebook_page(doc));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static GtkMenu *get_tab_bar_popup_menu(void)
|
||||||
|
{
|
||||||
|
static GtkWidget *menu = NULL;
|
||||||
|
GtkWidget *menu_item, *menu_item_label;
|
||||||
|
const GdkColor *color;
|
||||||
|
GeanyDocument *doc;
|
||||||
|
guint i, len;
|
||||||
|
gchar *base_name;
|
||||||
|
|
||||||
|
if (menu == NULL)
|
||||||
|
menu = gtk_menu_new();
|
||||||
|
|
||||||
|
/* clear the old menu items */
|
||||||
|
gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback) gtk_widget_destroy, NULL);
|
||||||
|
|
||||||
|
len = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
doc = document_get_from_page(i);
|
||||||
|
if (! DOC_VALID(doc))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
base_name = g_path_get_basename(doc->file_name);
|
||||||
|
menu_item = gtk_image_menu_item_new_with_label(base_name);
|
||||||
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),
|
||||||
|
gtk_image_new_from_icon_name(GTK_STOCK_FILE, GTK_ICON_SIZE_MENU));
|
||||||
|
gtk_widget_show(menu_item);
|
||||||
|
gtk_container_add(GTK_CONTAINER(menu), menu_item);
|
||||||
|
g_signal_connect(menu_item, "activate", G_CALLBACK(tab_bar_menu_activate_cb), doc);
|
||||||
|
|
||||||
|
color = document_get_status_color(doc);
|
||||||
|
menu_item_label = gtk_bin_get_child(GTK_BIN(menu_item));
|
||||||
|
gtk_widget_modify_fg(menu_item_label, GTK_STATE_NORMAL, color);
|
||||||
|
gtk_widget_modify_fg(menu_item_label, GTK_STATE_ACTIVE, color);
|
||||||
|
|
||||||
|
g_free(base_name);
|
||||||
|
}
|
||||||
|
menu_item = gtk_separator_menu_item_new();
|
||||||
|
gtk_widget_show(menu_item);
|
||||||
|
gtk_container_add(GTK_CONTAINER(menu), menu_item);
|
||||||
|
|
||||||
|
menu_item = ui_image_menu_item_new(GTK_STOCK_CLOSE, _("Close Ot_her Documents"));
|
||||||
|
gtk_widget_show(menu_item);
|
||||||
|
gtk_container_add(GTK_CONTAINER(menu), menu_item);
|
||||||
|
g_signal_connect(menu_item, "activate", G_CALLBACK(on_close_other_documents1_activate), NULL);
|
||||||
|
|
||||||
|
menu_item = ui_image_menu_item_new(GTK_STOCK_CLOSE, _("C_lose All"));
|
||||||
|
gtk_widget_show(menu_item);
|
||||||
|
gtk_container_add(GTK_CONTAINER(menu), menu_item);
|
||||||
|
g_signal_connect(menu_item, "activate", G_CALLBACK(on_close_all1_activate), NULL);
|
||||||
|
|
||||||
|
return GTK_MENU(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean notebook_tab_bar_click_cb(GtkWidget *widget, GdkEventButton *event,
|
static gboolean notebook_tab_bar_click_cb(GtkWidget *widget, GdkEventButton *event,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
@ -195,6 +262,11 @@ static gboolean notebook_tab_bar_click_cb(GtkWidget *widget, GdkEventButton *eve
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event->button == 3)
|
||||||
|
{
|
||||||
|
gtk_menu_popup(get_tab_bar_popup_menu(), NULL, NULL,
|
||||||
|
NULL, NULL, event->button, event->time);
|
||||||
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,17 +524,14 @@ gint notebook_new_tab(GeanyDocument *this)
|
|||||||
|
|
||||||
gtk_widget_show_all(ebox);
|
gtk_widget_show_all(ebox);
|
||||||
|
|
||||||
this->priv->tabmenu_label = gtk_label_new(NULL);
|
|
||||||
gtk_misc_set_alignment(GTK_MISC(this->priv->tabmenu_label), 0.0, 0);
|
|
||||||
|
|
||||||
document_update_tab_label(this);
|
document_update_tab_label(this);
|
||||||
|
|
||||||
if (file_prefs.tab_order_ltr)
|
if (file_prefs.tab_order_ltr)
|
||||||
tabnum = gtk_notebook_append_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
|
tabnum = gtk_notebook_append_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
|
||||||
ebox, this->priv->tabmenu_label);
|
ebox, NULL);
|
||||||
else
|
else
|
||||||
tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
|
tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
|
||||||
ebox, this->priv->tabmenu_label, 0);
|
ebox, NULL, 0);
|
||||||
|
|
||||||
tab_count_changed();
|
tab_count_changed();
|
||||||
|
|
||||||
|
@ -1333,8 +1333,6 @@ void ui_update_tab_status(GeanyDocument *doc)
|
|||||||
/* NULL color will reset to default */
|
/* NULL color will reset to default */
|
||||||
gtk_widget_modify_fg(doc->priv->tab_label, GTK_STATE_NORMAL, color);
|
gtk_widget_modify_fg(doc->priv->tab_label, GTK_STATE_NORMAL, color);
|
||||||
gtk_widget_modify_fg(doc->priv->tab_label, GTK_STATE_ACTIVE, color);
|
gtk_widget_modify_fg(doc->priv->tab_label, GTK_STATE_ACTIVE, color);
|
||||||
gtk_widget_modify_fg(doc->priv->tabmenu_label, GTK_STATE_NORMAL, color);
|
|
||||||
gtk_widget_modify_fg(doc->priv->tabmenu_label, GTK_STATE_ACTIVE, color);
|
|
||||||
|
|
||||||
treeviews_openfiles_update(doc);
|
treeviews_openfiles_update(doc);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user