Skip to content

Commit 3ef7e02

Browse files
committed
Statusbar button
1 parent 970591c commit 3ef7e02

4 files changed

Lines changed: 132 additions & 0 deletions

File tree

src/nemo-statusbar.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,34 @@ nemo_status_bar_dispose (GObject *object)
9090
G_OBJECT_CLASS (nemo_status_bar_parent_class)->dispose (object);
9191
}
9292

93+
static void
94+
action_toggle_split_view_callback (GtkButton *button, NemoStatusBar *bar)
95+
{
96+
NemoWindow *window = bar->window;
97+
98+
if (!nemo_window_split_view_showing (window)) {
99+
nemo_window_split_view_on (window);
100+
} else {
101+
nemo_window_split_view_off (window);
102+
}
103+
104+
nemo_status_bar_sync_button_states (bar);
105+
}
106+
107+
static void
108+
action_toggle_preview_pane_callback (GtkButton *button, NemoStatusBar *bar)
109+
{
110+
NemoWindow *window = bar->window;
111+
112+
if (!nemo_window_preview_pane_showing (window)) {
113+
nemo_window_preview_pane_on (window);
114+
} else {
115+
nemo_window_preview_pane_off (window);
116+
}
117+
118+
nemo_status_bar_sync_button_states (bar);
119+
}
120+
93121
static void
94122
action_places_toggle_callback (GtkButton *button, NemoStatusBar *bar)
95123
{
@@ -130,6 +158,18 @@ sidebar_type_changed_cb (gpointer pointer, const gchar *sidebar_id, gpointer use
130158
nemo_status_bar_sync_button_states (NEMO_STATUS_BAR (user_data));
131159
}
132160

161+
static void
162+
preview_pane_state_changed_cb (gpointer pointer, GParamSpec *pspec, gpointer user_data)
163+
{
164+
nemo_status_bar_sync_button_states (NEMO_STATUS_BAR (user_data));
165+
}
166+
167+
static void
168+
split_view_state_changed_cb (gpointer pointer, GParamSpec *pspec, gpointer user_data)
169+
{
170+
nemo_status_bar_sync_button_states (NEMO_STATUS_BAR (user_data));
171+
}
172+
133173
static void
134174
on_slider_changed_cb (GtkWidget *zoom_slider, gpointer user_data)
135175
{
@@ -229,6 +269,24 @@ nemo_status_bar_constructed (GObject *object)
229269
gtk_range_set_increments (GTK_RANGE (zoom_slider), 1.0, 1.0);
230270
gtk_range_set_round_digits (GTK_RANGE (zoom_slider), 0);
231271

272+
button = gtk_toggle_button_new ();
273+
icon = gtk_image_new_from_icon_name ("view-dual-symbolic", size);
274+
gtk_button_set_image (GTK_BUTTON (button), icon);
275+
gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show Split View (F3)"));
276+
bar->split_view_button = button;
277+
gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
278+
g_signal_connect (GTK_BUTTON (button), "clicked",
279+
G_CALLBACK (action_toggle_split_view_callback), bar);
280+
281+
button = gtk_toggle_button_new ();
282+
icon = gtk_image_new_from_icon_name ("xsi-preview-symbolic", size);
283+
gtk_button_set_image (GTK_BUTTON (button), icon);
284+
gtk_widget_set_tooltip_text (GTK_WIDGET (button), _("Show the Preview pane (F7)"));
285+
bar->preview_pane_button = button;
286+
gtk_box_pack_start (GTK_BOX (bar), button, FALSE, FALSE, 2);
287+
g_signal_connect (GTK_BUTTON (button), "clicked",
288+
G_CALLBACK (action_toggle_preview_pane_callback), bar);
289+
232290
gtk_widget_show_all (GTK_WIDGET (bar));
233291

234292
g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::show-sidebar",
@@ -237,6 +295,12 @@ nemo_status_bar_constructed (GObject *object)
237295
g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::sidebar-view-id",
238296
G_CALLBACK (sidebar_type_changed_cb), bar, G_CONNECT_AFTER);
239297

298+
g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::show-preview-pane",
299+
G_CALLBACK (preview_pane_state_changed_cb), bar, G_CONNECT_AFTER);
300+
301+
g_signal_connect_object (NEMO_WINDOW (bar->window), "notify::show-split-view",
302+
G_CALLBACK (split_view_state_changed_cb), bar, G_CONNECT_AFTER);
303+
240304
g_signal_connect (GTK_RANGE (zoom_slider), "value-changed",
241305
G_CALLBACK (on_slider_changed_cb), bar);
242306

@@ -332,6 +396,23 @@ nemo_status_bar_sync_button_states (NemoStatusBar *bar)
332396
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->places_button), FALSE);
333397
}
334398
g_signal_handlers_unblock_by_func (GTK_BUTTON (bar->places_button), action_places_toggle_callback, bar);
399+
400+
g_signal_handlers_block_by_func (GTK_BUTTON (bar->split_view_button), action_toggle_split_view_callback, bar);
401+
if (nemo_window_split_view_showing (bar->window)) {
402+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->split_view_button), TRUE);
403+
} else {
404+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->split_view_button), FALSE);
405+
}
406+
g_signal_handlers_unblock_by_func (GTK_BUTTON (bar->split_view_button), action_toggle_split_view_callback, bar);
407+
408+
g_signal_handlers_block_by_func (GTK_BUTTON (bar->preview_pane_button), action_toggle_preview_pane_callback, bar);
409+
if (nemo_window_preview_pane_showing (bar->window)) {
410+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->preview_pane_button), TRUE);
411+
} else {
412+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bar->preview_pane_button), FALSE);
413+
}
414+
g_signal_handlers_unblock_by_func (GTK_BUTTON (bar->preview_pane_button), action_toggle_preview_pane_callback, bar);
415+
335416
}
336417

337418
void

src/nemo-statusbar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ struct _NemoStatusBar
5454
GtkWidget *show_button;
5555
GtkWidget *hide_button;
5656
GtkWidget *separator;
57+
GtkWidget *split_view_button;
58+
GtkWidget *preview_pane_button;
5759
};
5860

5961
struct _NemoStatusBarClass

src/nemo-window-private.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ struct NemoWindowDetails
104104
gboolean show_preview_pane; // State flag
105105
gboolean preview_pane_width_set; // Initial width has been set from settings
106106

107+
/* split view */
108+
gboolean show_split_view; // State flag
109+
107110
gboolean disable_chrome;
108111

109112
guint sidebar_width_handler_id;

src/nemo-window.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ enum {
106106
PROP_DISABLE_CHROME = 1,
107107
PROP_SIDEBAR_VIEW_TYPE,
108108
PROP_SHOW_SIDEBAR,
109+
PROP_SHOW_PREVIEW_PANE,
110+
PROP_SHOW_SPLIT_VIEW,
109111
NUM_PROPERTIES,
110112
};
111113

@@ -818,6 +820,20 @@ nemo_window_set_property (GObject *object,
818820
case PROP_SHOW_SIDEBAR:
819821
nemo_window_set_show_sidebar (window, g_value_get_boolean (value));
820822
break;
823+
case PROP_SHOW_PREVIEW_PANE:
824+
if (g_value_get_boolean (value)) {
825+
nemo_window_preview_pane_on (window);
826+
} else {
827+
nemo_window_preview_pane_off (window);
828+
}
829+
break;
830+
case PROP_SHOW_SPLIT_VIEW:
831+
if (g_value_get_boolean (value)) {
832+
nemo_window_split_view_on (window);
833+
} else {
834+
nemo_window_split_view_off (window);
835+
}
836+
break;
821837
default:
822838
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, arg_id, pspec);
823839
break;
@@ -844,6 +860,12 @@ nemo_window_get_property (GObject *object,
844860
case PROP_SHOW_SIDEBAR:
845861
g_value_set_boolean (value, window->details->show_sidebar);
846862
break;
863+
case PROP_SHOW_PREVIEW_PANE:
864+
g_value_set_boolean (value, window->details->show_preview_pane);
865+
break;
866+
case PROP_SHOW_SPLIT_VIEW:
867+
g_value_set_boolean (value, window->details->show_split_view);
868+
break;
847869
default:
848870
g_assert_not_reached ();
849871
break;
@@ -2156,6 +2178,20 @@ nemo_window_class_init (NemoWindowClass *class)
21562178
FALSE,
21572179
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
21582180

2181+
properties[PROP_SHOW_PREVIEW_PANE] =
2182+
g_param_spec_boolean ("show-preview-pane",
2183+
"Show the preview pane",
2184+
"Show the preview pane",
2185+
FALSE,
2186+
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
2187+
2188+
properties[PROP_SHOW_SPLIT_VIEW] =
2189+
g_param_spec_boolean ("show-split-view",
2190+
"Show split view",
2191+
"Show split view",
2192+
FALSE,
2193+
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
2194+
21592195
signals[GO_UP] =
21602196
g_signal_new ("go-up",
21612197
G_TYPE_FROM_CLASS (class),
@@ -2411,8 +2447,11 @@ nemo_window_split_view_on (NemoWindow *window)
24112447
nemo_window_slot_open_location (slot, location, 0);
24122448
g_object_unref (location);
24132449

2450+
window->details->show_split_view = TRUE;
24142451
window_set_search_action_text (window, FALSE);
24152452
nemo_window_update_show_hide_ui_elements (window);
2453+
2454+
g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_SHOW_SPLIT_VIEW]);
24162455
}
24172456

24182457
void
@@ -2443,7 +2482,10 @@ nemo_window_split_view_off (NemoWindow *window)
24432482
nemo_navigation_state_set_master (window->details->nav_state,
24442483
active_pane->action_group);
24452484

2485+
window->details->show_split_view = FALSE;
24462486
nemo_window_update_show_hide_ui_elements (window);
2487+
2488+
g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_SHOW_SPLIT_VIEW]);
24472489
}
24482490

24492491
gboolean
@@ -2521,6 +2563,8 @@ nemo_window_preview_pane_on (NemoWindow *window)
25212563
}
25222564
}
25232565
nemo_window_update_show_hide_ui_elements (window);
2566+
2567+
g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_SHOW_PREVIEW_PANE]);
25242568
}
25252569

25262570
void
@@ -2571,6 +2615,8 @@ nemo_window_preview_pane_off (NemoWindow *window)
25712615
}
25722616
}
25732617
nemo_window_update_show_hide_ui_elements (window);
2618+
2619+
g_object_notify_by_pspec (G_OBJECT (window), properties[PROP_SHOW_PREVIEW_PANE]);
25742620
}
25752621

25762622
gboolean

0 commit comments

Comments
 (0)