xed-notebook.c: Clean up the code formatting
This commit is contained in:
parent
33f6b71eda
commit
d80329db5c
|
@ -109,8 +109,7 @@ xed_notebook_dispose (GObject *object)
|
|||
|
||||
for (l = children; l != NULL; l = g_list_next (l))
|
||||
{
|
||||
xed_notebook_remove_tab (notebook,
|
||||
XED_TAB (l->data));
|
||||
xed_notebook_remove_tab (notebook, XED_TAB (l->data));
|
||||
}
|
||||
|
||||
g_list_free (children);
|
||||
|
@ -185,7 +184,8 @@ xed_notebook_class_init (XedNotebookClass *klass)
|
|||
}
|
||||
|
||||
static XedNotebook *
|
||||
find_notebook_at_pointer (gint abs_x, gint abs_y)
|
||||
find_notebook_at_pointer (gint abs_x,
|
||||
gint abs_y)
|
||||
{
|
||||
GdkWindow *win_at_pointer;
|
||||
GdkWindow *toplevel_win;
|
||||
|
@ -206,11 +206,9 @@ find_notebook_at_pointer (gint abs_x, gint abs_y)
|
|||
gdk_window_get_user_data (toplevel_win, &toplevel);
|
||||
|
||||
/* toplevel should be an XedWindow */
|
||||
if ((toplevel != NULL) &&
|
||||
XED_IS_WINDOW (toplevel))
|
||||
if ((toplevel != NULL) && XED_IS_WINDOW (toplevel))
|
||||
{
|
||||
return XED_NOTEBOOK (_xed_window_get_notebook
|
||||
(XED_WINDOW (toplevel)));
|
||||
return XED_NOTEBOOK (_xed_window_get_notebook (XED_WINDOW (toplevel)));
|
||||
}
|
||||
|
||||
/* We are outside all windows containing a notebook */
|
||||
|
@ -267,8 +265,7 @@ find_tab_num_at_pos (XedNotebook *notebook,
|
|||
continue;
|
||||
}
|
||||
|
||||
gdk_window_get_origin (GDK_WINDOW (gtk_widget_get_window (tab)),
|
||||
&x_root, &y_root);
|
||||
gdk_window_get_origin (GDK_WINDOW (gtk_widget_get_window (tab)), &x_root, &y_root);
|
||||
|
||||
gtk_widget_get_allocation(tab, &allocation);
|
||||
|
||||
|
@ -375,21 +372,18 @@ xed_notebook_reorder_tab (XedNotebook *src,
|
|||
g_return_if_fail (XED_IS_NOTEBOOK (src));
|
||||
g_return_if_fail (XED_IS_TAB (tab));
|
||||
|
||||
old_position = gtk_notebook_page_num (GTK_NOTEBOOK (src),
|
||||
GTK_WIDGET (tab));
|
||||
old_position = gtk_notebook_page_num (GTK_NOTEBOOK (src), GTK_WIDGET (tab));
|
||||
|
||||
if (old_position == dest_position)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_notebook_reorder_child (GTK_NOTEBOOK (src),
|
||||
GTK_WIDGET (tab),
|
||||
dest_position);
|
||||
gtk_notebook_reorder_child (GTK_NOTEBOOK (src), GTK_WIDGET (tab), dest_position);
|
||||
|
||||
if (!src->priv->drag_in_progress)
|
||||
{
|
||||
g_signal_emit (G_OBJECT (src),
|
||||
signals[TABS_REORDERED],
|
||||
0);
|
||||
g_signal_emit (G_OBJECT (src), signals[TABS_REORDERED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +396,9 @@ drag_start (XedNotebook *notebook,
|
|||
/* get a new cursor, if necessary */
|
||||
/* FIXME multi-head */
|
||||
if (cursor == NULL)
|
||||
{
|
||||
cursor = gdk_cursor_new (GDK_FLEUR);
|
||||
}
|
||||
|
||||
/* grab the pointer */
|
||||
gtk_grab_add (GTK_WIDGET (notebook));
|
||||
|
@ -424,16 +420,13 @@ drag_stop (XedNotebook *notebook)
|
|||
{
|
||||
if (notebook->priv->drag_in_progress)
|
||||
{
|
||||
g_signal_emit (G_OBJECT (notebook),
|
||||
signals[TABS_REORDERED],
|
||||
0);
|
||||
g_signal_emit (G_OBJECT (notebook), signals[TABS_REORDERED], 0);
|
||||
}
|
||||
|
||||
notebook->priv->drag_in_progress = FALSE;
|
||||
if (notebook->priv->motion_notify_handler_id != 0)
|
||||
{
|
||||
g_signal_handler_disconnect (G_OBJECT (notebook),
|
||||
notebook->priv->motion_notify_handler_id);
|
||||
g_signal_handler_disconnect (G_OBJECT (notebook), notebook->priv->motion_notify_handler_id);
|
||||
notebook->priv->motion_notify_handler_id = 0;
|
||||
}
|
||||
}
|
||||
|
@ -453,12 +446,8 @@ move_current_tab (XedNotebook *notebook,
|
|||
{
|
||||
GtkWidget *cur_tab;
|
||||
|
||||
cur_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
|
||||
cur_page_num);
|
||||
|
||||
xed_notebook_reorder_tab (XED_NOTEBOOK (notebook),
|
||||
XED_TAB (cur_tab),
|
||||
dest_position);
|
||||
cur_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), cur_page_num);
|
||||
xed_notebook_reorder_tab (XED_NOTEBOOK (notebook), XED_TAB (cur_tab), dest_position);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,7 +463,9 @@ motion_notify_cb (XedNotebook *notebook,
|
|||
if (notebook->priv->drag_in_progress == FALSE)
|
||||
{
|
||||
if (notebook->priv->tab_drag_and_drop_enabled == FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (gtk_drag_check_threshold (GTK_WIDGET (notebook),
|
||||
notebook->priv->x_start,
|
||||
|
@ -489,19 +480,13 @@ motion_notify_cb (XedNotebook *notebook,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
result = find_notebook_and_tab_at_pos ((gint)event->x_root,
|
||||
(gint)event->y_root,
|
||||
&dest,
|
||||
&page_num);
|
||||
result = find_notebook_and_tab_at_pos ((gint)event->x_root, (gint)event->y_root, &dest, &page_num);
|
||||
|
||||
if (result != NOT_IN_APP_WINDOWS)
|
||||
{
|
||||
if (dest != notebook)
|
||||
{
|
||||
move_current_tab_to_another_notebook (notebook,
|
||||
dest,
|
||||
event,
|
||||
page_num);
|
||||
move_current_tab_to_another_notebook (notebook, dest, event, page_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -531,8 +516,7 @@ move_current_tab_to_another_notebook (XedNotebook *src,
|
|||
g_return_if_fail (dest != src);
|
||||
|
||||
cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (src));
|
||||
tab = XED_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (src),
|
||||
cur_page));
|
||||
tab = XED_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (src), cur_page));
|
||||
|
||||
/* stop drag in origin window */
|
||||
/* ungrab the pointer if it's grabbed */
|
||||
|
@ -546,11 +530,8 @@ move_current_tab_to_another_notebook (XedNotebook *src,
|
|||
xed_notebook_move_tab (src, dest, tab, dest_position);
|
||||
|
||||
/* start drag handling in dest notebook */
|
||||
dest->priv->motion_notify_handler_id =
|
||||
g_signal_connect (G_OBJECT (dest),
|
||||
"motion-notify-event",
|
||||
G_CALLBACK (motion_notify_cb),
|
||||
NULL);
|
||||
dest->priv->motion_notify_handler_id = g_signal_connect (G_OBJECT (dest), "motion-notify-event",
|
||||
G_CALLBACK (motion_notify_cb), NULL);
|
||||
|
||||
drag_start (dest, event->time);
|
||||
}
|
||||
|
@ -566,18 +547,14 @@ button_release_cb (XedNotebook *notebook,
|
|||
GtkWidget *cur_page;
|
||||
|
||||
cur_page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
|
||||
cur_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
|
||||
cur_page_num);
|
||||
cur_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), cur_page_num);
|
||||
|
||||
/* CHECK: I don't follow the code here -- Paolo */
|
||||
if (!is_in_notebook_window (notebook, event->x_root, event->y_root) &&
|
||||
(gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) > 1))
|
||||
{
|
||||
/* Tab was detached */
|
||||
g_signal_emit (G_OBJECT (notebook),
|
||||
signals[TAB_DETACHED],
|
||||
0,
|
||||
cur_page);
|
||||
g_signal_emit (G_OBJECT (notebook), signals[TAB_DETACHED], 0, cur_page);
|
||||
}
|
||||
|
||||
/* ungrab the pointer if it's grabbed */
|
||||
|
@ -602,27 +579,21 @@ button_press_cb (XedNotebook *notebook,
|
|||
gint tab_clicked;
|
||||
|
||||
if (notebook->priv->drag_in_progress)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
tab_clicked = find_tab_num_at_pos (notebook,
|
||||
event->x_root,
|
||||
event->y_root);
|
||||
tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
|
||||
|
||||
if ((event->button == 1) &&
|
||||
(event->type == GDK_BUTTON_PRESS) &&
|
||||
(tab_clicked >= 0))
|
||||
if ((event->button == 1) && (event->type == GDK_BUTTON_PRESS) && (tab_clicked >= 0))
|
||||
{
|
||||
notebook->priv->x_start = event->x_root;
|
||||
notebook->priv->y_start = event->y_root;
|
||||
|
||||
notebook->priv->motion_notify_handler_id =
|
||||
g_signal_connect (G_OBJECT (notebook),
|
||||
"motion-notify-event",
|
||||
G_CALLBACK (motion_notify_cb),
|
||||
NULL);
|
||||
notebook->priv->motion_notify_handler_id = g_signal_connect (G_OBJECT (notebook), "motion-notify-event",
|
||||
G_CALLBACK (motion_notify_cb), NULL);
|
||||
}
|
||||
else if ((event->type == GDK_BUTTON_PRESS) &&
|
||||
(event->button == 3 || event->button == 2))
|
||||
else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3 || event->button == 2))
|
||||
{
|
||||
if (tab_clicked == -1)
|
||||
{
|
||||
|
@ -636,8 +607,7 @@ button_press_cb (XedNotebook *notebook,
|
|||
else
|
||||
{
|
||||
/* Switch to the page the mouse is over, but don't consume the event */
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
|
||||
tab_clicked);
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -709,12 +679,10 @@ xed_notebook_switch_page_cb (GtkNotebook *notebook,
|
|||
* the list */
|
||||
if (nb->priv->focused_pages)
|
||||
{
|
||||
nb->priv->focused_pages =
|
||||
g_list_remove (nb->priv->focused_pages, child);
|
||||
nb->priv->focused_pages = g_list_remove (nb->priv->focused_pages, child);
|
||||
}
|
||||
|
||||
nb->priv->focused_pages = g_list_append (nb->priv->focused_pages,
|
||||
child);
|
||||
nb->priv->focused_pages = g_list_append (nb->priv->focused_pages, child);
|
||||
|
||||
/* give focus to the view */
|
||||
view = xed_tab_get_view (XED_TAB (child));
|
||||
|
@ -756,21 +724,14 @@ xed_notebook_init (XedNotebook *notebook)
|
|||
|
||||
notebook->priv->always_show_tabs = TRUE;
|
||||
|
||||
g_signal_connect (notebook,
|
||||
"button-press-event",
|
||||
(GCallback)button_press_cb,
|
||||
NULL);
|
||||
g_signal_connect (notebook,
|
||||
"button-release-event",
|
||||
(GCallback)button_release_cb,
|
||||
NULL);
|
||||
gtk_widget_add_events (GTK_WIDGET (notebook),
|
||||
GDK_BUTTON1_MOTION_MASK);
|
||||
g_signal_connect (notebook, "button-press-event",
|
||||
(GCallback)button_press_cb, NULL);
|
||||
g_signal_connect (notebook, "button-release-event",
|
||||
(GCallback)button_release_cb, NULL);
|
||||
gtk_widget_add_events (GTK_WIDGET (notebook), GDK_BUTTON1_MOTION_MASK);
|
||||
|
||||
g_signal_connect_after (G_OBJECT (notebook),
|
||||
"switch_page",
|
||||
G_CALLBACK (xed_notebook_switch_page_cb),
|
||||
NULL);
|
||||
g_signal_connect_after (G_OBJECT (notebook), "switch_page",
|
||||
G_CALLBACK (xed_notebook_switch_page_cb), NULL);
|
||||
|
||||
gtk_widget_add_events (GTK_WIDGET (notebook), GDK_SCROLL_MASK);
|
||||
g_signal_connect (notebook, "scroll-event",
|
||||
|
@ -805,8 +766,7 @@ xed_notebook_change_current_page (GtkNotebook *notebook,
|
|||
current = current + offset;
|
||||
|
||||
g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
|
||||
"gtk-keynav-wrap-around", &wrap_around,
|
||||
NULL);
|
||||
"gtk-keynav-wrap-around", &wrap_around, NULL);
|
||||
|
||||
if (wrap_around)
|
||||
{
|
||||
|
@ -831,7 +791,8 @@ xed_notebook_change_current_page (GtkNotebook *notebook,
|
|||
}
|
||||
|
||||
static void
|
||||
close_button_clicked_cb (XedTabLabel *tab_label, XedNotebook *notebook)
|
||||
close_button_clicked_cb (XedTabLabel *tab_label,
|
||||
XedNotebook *notebook)
|
||||
{
|
||||
XedTab *tab;
|
||||
|
||||
|
@ -847,10 +808,8 @@ create_tab_label (XedNotebook *nb,
|
|||
|
||||
tab_label = xed_tab_label_new (tab);
|
||||
|
||||
g_signal_connect (tab_label,
|
||||
"close-clicked",
|
||||
G_CALLBACK (close_button_clicked_cb),
|
||||
nb);
|
||||
g_signal_connect (tab_label, "close-clicked",
|
||||
G_CALLBACK (close_button_clicked_cb), nb);
|
||||
|
||||
g_object_set_data (G_OBJECT (tab), "tab-label", tab_label);
|
||||
|
||||
|
@ -876,9 +835,7 @@ remove_tab_label (XedNotebook *nb,
|
|||
|
||||
tab_label = get_tab_label (tab);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (tab_label,
|
||||
G_CALLBACK (close_button_clicked_cb),
|
||||
nb);
|
||||
g_signal_handlers_disconnect_by_func (tab_label, G_CALLBACK (close_button_clicked_cb), nb);
|
||||
|
||||
g_object_set_data (G_OBJECT (tab), "tab-label", NULL);
|
||||
}
|
||||
|
@ -922,26 +879,20 @@ xed_notebook_add_tab (XedNotebook *nb,
|
|||
g_return_if_fail (XED_IS_TAB (tab));
|
||||
|
||||
tab_label = create_tab_label (nb, tab);
|
||||
gtk_notebook_insert_page (GTK_NOTEBOOK (nb),
|
||||
GTK_WIDGET (tab),
|
||||
tab_label,
|
||||
position);
|
||||
gtk_notebook_insert_page (GTK_NOTEBOOK (nb), GTK_WIDGET (tab), tab_label, position);
|
||||
update_tabs_visibility (nb, TRUE);
|
||||
|
||||
g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
|
||||
|
||||
/* The signal handler may have reordered the tabs */
|
||||
position = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
|
||||
GTK_WIDGET (tab));
|
||||
position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
|
||||
|
||||
if (jump_to)
|
||||
{
|
||||
XedView *view;
|
||||
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), position);
|
||||
g_object_set_data (G_OBJECT (tab),
|
||||
"jump_to",
|
||||
GINT_TO_POINTER (jump_to));
|
||||
g_object_set_data (G_OBJECT (tab), "jump_to", GINT_TO_POINTER (jump_to));
|
||||
view = xed_tab_get_view (tab);
|
||||
|
||||
gtk_widget_grab_focus (GTK_WIDGET (view));
|
||||
|
@ -954,8 +905,7 @@ smart_tab_switching_on_closure (XedNotebook *nb,
|
|||
{
|
||||
gboolean jump_to;
|
||||
|
||||
jump_to = GPOINTER_TO_INT (g_object_get_data
|
||||
(G_OBJECT (tab), "jump_to"));
|
||||
jump_to = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tab), "jump_to"));
|
||||
|
||||
if (!jump_to || !nb->priv->focused_pages)
|
||||
{
|
||||
|
@ -970,10 +920,8 @@ smart_tab_switching_on_closure (XedNotebook *nb,
|
|||
/* activate the last focused tab */
|
||||
l = g_list_last (nb->priv->focused_pages);
|
||||
child = GTK_WIDGET (l->data);
|
||||
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
|
||||
child);
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (nb),
|
||||
page_num);
|
||||
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (nb), child);
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), page_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1016,8 +964,7 @@ xed_notebook_remove_tab (XedNotebook *nb,
|
|||
g_return_if_fail (XED_IS_TAB (tab));
|
||||
|
||||
/* Remove the page from the focused pages list */
|
||||
nb->priv->focused_pages = g_list_remove (nb->priv->focused_pages,
|
||||
tab);
|
||||
nb->priv->focused_pages = g_list_remove (nb->priv->focused_pages, tab);
|
||||
|
||||
position = gtk_notebook_page_num (GTK_NOTEBOOK (nb), GTK_WIDGET (tab));
|
||||
curr = gtk_notebook_get_current_page (GTK_NOTEBOOK (nb));
|
||||
|
@ -1044,9 +991,7 @@ xed_notebook_remove_all_tabs (XedNotebook *nb)
|
|||
g_list_free (nb->priv->focused_pages);
|
||||
nb->priv->focused_pages = NULL;
|
||||
|
||||
gtk_container_foreach (GTK_CONTAINER (nb),
|
||||
(GtkCallback)remove_tab,
|
||||
nb);
|
||||
gtk_container_foreach (GTK_CONTAINER (nb), (GtkCallback)remove_tab, nb);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1057,8 +1002,7 @@ set_close_buttons_sensitivity (XedTab *tab,
|
|||
|
||||
tab_label = get_tab_label (tab);
|
||||
|
||||
xed_tab_label_set_close_button_sensitive (XED_TAB_LABEL (tab_label),
|
||||
nb->priv->close_buttons_sensitive);
|
||||
xed_tab_label_set_close_button_sensitive (XED_TAB_LABEL (tab_label), nb->priv->close_buttons_sensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1077,13 +1021,13 @@ xed_notebook_set_close_buttons_sensitive (XedNotebook *nb,
|
|||
sensitive = (sensitive != FALSE);
|
||||
|
||||
if (sensitive == nb->priv->close_buttons_sensitive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nb->priv->close_buttons_sensitive = sensitive;
|
||||
|
||||
gtk_container_foreach (GTK_CONTAINER (nb),
|
||||
(GtkCallback)set_close_buttons_sensitivity,
|
||||
nb);
|
||||
gtk_container_foreach (GTK_CONTAINER (nb), (GtkCallback)set_close_buttons_sensitivity, nb);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1118,7 +1062,9 @@ xed_notebook_set_tab_drag_and_drop_enabled (XedNotebook *nb,
|
|||
enable = (enable != FALSE);
|
||||
|
||||
if (enable == nb->priv->tab_drag_and_drop_enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nb->priv->tab_drag_and_drop_enabled = enable;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue