Skip to content

Commit

Permalink
Remove code duplication in sidebar close callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
bhennion committed Dec 24, 2023
1 parent 7fa4c17 commit f9b1dfe
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 16 deletions.
14 changes: 0 additions & 14 deletions src/core/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ MainWindow::MainWindow(GladeSearchpath* gladeSearchPath, Control* control, GtkAp
g_signal_connect(this->window, "window_state_event", xoj::util::wrap_for_g_callback_v<windowStateEventCallback>,
this);

g_signal_connect(get("buttonCloseSidebar"), "clicked", xoj::util::wrap_for_g_callback_v<buttonCloseSidebarClicked>,
this);

// "watch over" all key events
g_signal_connect(this->window, "key-press-event", G_CALLBACK(gtk_window_propagate_key_event), nullptr);
g_signal_connect(this->window, "key-release-event", G_CALLBACK(gtk_window_propagate_key_event), nullptr);
Expand Down Expand Up @@ -339,17 +336,6 @@ void MainWindow::updateScrollbarSidebarPosition() {
g_object_unref(boxContents);
}

void MainWindow::buttonCloseSidebarClicked(GtkButton* button, MainWindow* win) {
Settings* settings = win->control->getSettings();
if (settings->getActiveViewMode() == PresetViewModeIds::VIEW_MODE_DEFAULT) {
settings->setSidebarVisible(false);
ViewMode viewMode = settings->getViewModes()[PresetViewModeIds::VIEW_MODE_DEFAULT];
viewMode.showSidebar = false;
settings->setViewMode(PresetViewModeIds::VIEW_MODE_DEFAULT, viewMode);
}
win->setSidebarVisible(false);
}

auto MainWindow::deleteEventCallback(GtkWidget* widget, GdkEvent* event, Control* control) -> bool {
control->quit();

Expand Down
2 changes: 0 additions & 2 deletions src/core/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ class MainWindow: public GladeGui {

void createToolbar();

static void buttonCloseSidebarClicked(GtkButton* button, MainWindow* win);

/**
* Window close Button is pressed
*/
Expand Down
1 change: 1 addition & 0 deletions ui/main.glade
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="action-name">win.show-sidebar</property>
<property name="relief">none</property>
<child>
<object class="GtkImage" id="image8">
Expand Down

0 comments on commit f9b1dfe

Please sign in to comment.