Use Gtk::Viewport wrapper class

There is a GtkViewport wrapper class in gtkmm, Gtk::Viewport.  Make use
of that class instead of direct gtk calls.

Reference:
https://developer.gnome.org/gtkmm/2.24/classGtk_1_1Viewport.html
This commit is contained in:
Luca Bacci 2018-08-27 20:18:55 +02:00 committed by Mike Fleetwood
parent bd75641842
commit 1f54ab6b12
1 changed files with 5 additions and 6 deletions

View File

@ -22,8 +22,8 @@
#include "Utils.h"
#include "btrfs.h"
#include <gtk/gtk.h>
#include <gtkmm/alignment.h>
#include <gtkmm/viewport.h>
namespace GParted
{
@ -53,11 +53,10 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition ) : pa
//As Gtk::VBox widget info_msg_vbox doesn't have a native scrolling capability a
// Gtk::Viewport is automatically created to contain it when it is added to the
// Gtk::ScrolledWindow widget info_scrolled. The Viewport widget is created with
// shadow type GTK_SHADOW_IN by default. Change to GTK_SHADOW_NONE. Have to use
// GTK+ C API as the Viewport widget isn't exposed via gtkmm C++ API.
// https://developer.gnome.org/gtkmm/2.24/classGtk_1_1ScrolledWindow.html#a17c588d56d93923841d38f0d5e2ec9d7
GtkWidget * scrollable_child = gtk_bin_get_child(GTK_BIN(info_scrolled.gobj()));
gtk_viewport_set_shadow_type(GTK_VIEWPORT(scrollable_child), GTK_SHADOW_NONE);
// shadow type GTK_SHADOW_IN by default. Change to GTK_SHADOW_NONE.
Gtk::Viewport * child_viewport = dynamic_cast<Gtk::Viewport *>(info_scrolled.get_child());
if (child_viewport)
child_viewport->set_shadow_type(Gtk::SHADOW_NONE);
//horizontally center the information scrolled window to match partition graphic
Gtk::Alignment * center_widget = manage( new Gtk::Alignment(0.5, 0.5, 0.0, 1.0) ) ;
center_widget ->add( info_scrolled ) ;