Skip to content

Commit

Permalink
Fix GtkHeaderBar button placement under GTK 3.12: Bug #731111
Browse files Browse the repository at this point in the history
  • Loading branch information
rschroll authored and jimbonator committed Jun 17, 2014
1 parent 0c1c095 commit 64b1818
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pkg_check_modules(WEBKITGTK22X QUIET webkitgtk-3.0>=2.2.0 webkitgtk-3.0<=2.2.100
pkg_check_modules(WEBKITGTK20X QUIET webkitgtk-3.0>=2.0.0 webkitgtk-3.0<=2.0.100)
pkg_check_modules(WEBKITGTK110X QUIET webkitgtk-3.0>=1.10.0 webkitgtk-3.0<=1.10.2)

pkg_check_modules(GTK312X QUIET gtk+-3.0>=3.12.0)

# intl
include(Gettext)
if (XGETTEXT_FOUND)
Expand Down
9 changes: 9 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,15 @@ else ()
message(FATAL_ERROR "WebKitGTK not installed / unknown version detected")
endif ()

if (GTK312X_FOUND)
message(STATUS "GTK+ 3.12 support: ON")

set(EXTRA_VALA_OPTIONS
${EXTRA_VALA_OPTIONS}
-D GTK_3_12
)
endif ()

if (NO_FATAL_WARNINGS)
message(STATUS "Vala fatal warnings: OFF")
else ()
Expand Down
22 changes: 18 additions & 4 deletions src/client/components/main-toolbar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public class MainToolbar : PillHeaderbar {
insert.clear();
insert.add(archive_button = create_toolbar_button(null, GearyController.ACTION_ARCHIVE_MESSAGE, true));
insert.add(trash_buttons[0] = create_toolbar_button(null, GearyController.ACTION_TRASH_MESSAGE, true));
add_end(create_pill_buttons(insert));
Gtk.Box trash_archive = create_pill_buttons(insert);
insert.clear();
insert.add(trash_buttons[1] = create_toolbar_button(null, GearyController.ACTION_TRASH_MESSAGE, true));
add_end(create_pill_buttons(insert, false));
Gtk.Box trash = create_pill_buttons(insert, false);

// Search bar.
search_entry.width_chars = 28;
Expand All @@ -80,21 +80,35 @@ public class MainToolbar : PillHeaderbar {
search_entry.key_press_event.connect(on_search_key_press);
on_search_entry_changed(); // set initial state
search_entry.has_focus = true;
add_end(search_upgrade_progress_bar);
add_end(search_entry);

// Search upgrade progress bar.
search_upgrade_progress_bar.margin_top = 3;
search_upgrade_progress_bar.margin_bottom = 3;
search_upgrade_progress_bar.show_text = true;

// pack_end() ordering is reversed in GtkHeaderBar in 3.12 and above
#if !GTK_3_12
add_end(trash_archive);
add_end(trash);
add_end(search_upgrade_progress_bar);
add_end(search_entry);
#endif

// Application button. If we exported an app menu, we don't need this.
if (!Gtk.Settings.get_default().gtk_shell_shows_app_menu) {
insert.clear();
insert.add(create_menu_button("emblem-system-symbolic", application_menu, GearyController.ACTION_GEAR_MENU));
add_end(create_pill_buttons(insert));
}

// pack_end() ordering is reversed in GtkHeaderBar in 3.12 and above
#if GTK_3_12
add_end(search_entry);
add_end(search_upgrade_progress_bar);
add_end(trash);
add_end(trash_archive);
#endif

set_search_placeholder_text(DEFAULT_SEARCH_TEXT);
}

Expand Down

0 comments on commit 64b1818

Please sign in to comment.