[gtk/matthiasc/for-master: 7/7] Cosmetic improvements to the filebrowser demo
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 7/7] Cosmetic improvements to the filebrowser demo
- Date: Tue, 2 Jun 2020 03:14:21 +0000 (UTC)
commit 5afe6f7825e1e5ecad9c0dc58265d74568d6f44b
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 1 23:12:01 2020 -0400
Cosmetic improvements to the filebrowser demo
Make it look good.
demos/gtk-demo/demo.gresource.xml | 1 +
demos/gtk-demo/listview_filebrowser.c | 26 ++++++++++++++++++++++++++
demos/gtk-demo/listview_filebrowser.css | 11 +++++++++++
demos/gtk-demo/listview_filebrowser.ui | 11 ++++++++++-
4 files changed, 48 insertions(+), 1 deletion(-)
---
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index 8753b078ba..d274e67024 100644
--- a/demos/gtk-demo/demo.gresource.xml
+++ b/demos/gtk-demo/demo.gresource.xml
@@ -127,6 +127,7 @@
</gresource>
<gresource prefix="/listview_filebrowser">
<file>listview_filebrowser.ui</file>
+ <file>listview_filebrowser.css</file>
</gresource>
<gresource prefix="/listview_minesweeper">
<file>listview_minesweeper.ui</file>
diff --git a/demos/gtk-demo/listview_filebrowser.c b/demos/gtk-demo/listview_filebrowser.c
index 8483ec35ff..7dcf3e3d3f 100644
--- a/demos/gtk-demo/listview_filebrowser.c
+++ b/demos/gtk-demo/listview_filebrowser.c
@@ -18,6 +18,7 @@ struct _FileBrowserView
GtkListItemFactory *factory;
char *icon_name;
+ char *title;
GtkOrientation orientation;
};
@@ -25,6 +26,7 @@ enum {
PROP_0,
PROP_FACTORY,
PROP_ICON_NAME,
+ PROP_TITLE,
PROP_ORIENTATION,
N_PROPS
@@ -54,6 +56,10 @@ file_browser_view_get_property (GObject *object,
g_value_set_string (value, self->icon_name);
break;
+ case PROP_TITLE:
+ g_value_set_string (value, self->title);
+ break;
+
case PROP_ORIENTATION:
g_value_set_enum (value, self->orientation);
break;
@@ -83,6 +89,11 @@ file_browser_view_set_property (GObject *object,
self->icon_name = g_value_dup_string (value);
break;
+ case PROP_TITLE:
+ g_free (self->title);
+ self->title = g_value_dup_string (value);
+ break;
+
case PROP_ORIENTATION:
self->orientation = g_value_get_enum (value);
break;
@@ -100,6 +111,7 @@ file_browser_view_finalize (GObject *object)
g_object_unref (self->factory);
g_free (self->icon_name);
+ g_free (self->title);
G_OBJECT_CLASS (file_browser_view_parent_class)->dispose (object);
}
@@ -125,6 +137,12 @@ file_browser_view_class_init (FileBrowserViewClass *klass)
"icon to display for selecting this view",
NULL,
G_PARAM_READWRITE);
+ properties[PROP_TITLE] =
+ g_param_spec_string ("title",
+ "title",
+ "title to display for selecting this view",
+ NULL,
+ G_PARAM_READWRITE);
properties[PROP_ORIENTATION] =
g_param_spec_enum ("orientation",
"orientation",
@@ -224,6 +242,14 @@ do_listview_filebrowser (GtkWidget *do_widget)
GtkDirectoryList *dirlist;
GFile *file;
char *cwd;
+ GtkCssProvider *provider;
+
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_resource (provider, "/listview_filebrowser/listview_filebrowser.css");
+ gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ 800);
+ g_object_unref (provider);
builder = gtk_builder_new_from_resource ("/listview_filebrowser/listview_filebrowser.ui");
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
diff --git a/demos/gtk-demo/listview_filebrowser.css b/demos/gtk-demo/listview_filebrowser.css
new file mode 100644
index 0000000000..c27fadf57f
--- /dev/null
+++ b/demos/gtk-demo/listview_filebrowser.css
@@ -0,0 +1,11 @@
+list.viewswitcher {
+ border: 1px solid gray;
+}
+
+list.viewswitcher > row {
+ padding: 5px;
+}
+
+list.viewswitcher row:selected {
+ background: gray;
+}
diff --git a/demos/gtk-demo/listview_filebrowser.ui b/demos/gtk-demo/listview_filebrowser.ui
index 126c1baa02..7d5d4ce5cd 100644
--- a/demos/gtk-demo/listview_filebrowser.ui
+++ b/demos/gtk-demo/listview_filebrowser.ui
@@ -39,12 +39,14 @@
</object>
</property>
<property name="icon-name">view-list-symbolic</property>
+ <property name="title" translatable="yes">List</property>
<property name="orientation">horizontal</property>
</object>
</child>
<child>
<object class="FileBrowserView">
<property name="icon-name">view-grid-symbolic</property>
+ <property name="title" translatable="yes">Grid</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
@@ -92,6 +94,7 @@
<child>
<object class="FileBrowserView">
<property name="icon-name">view-paged-symbolic</property>
+ <property name="title" translatable="yes">Paged</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="bytes"><![CDATA[
@@ -174,7 +177,7 @@
<property name="show-title-buttons">1</property>
<child>
<object class="GtkButton">
- <property name="icon-name">go-up</property>
+ <property name="icon-name">go-up-symbolic</property>
<signal name="clicked" handler="filebrowser_up_clicked_cb" object="dirlist" swapped="no"/>
</object>
</child>
@@ -184,6 +187,7 @@
<property name="orientation">horizontal</property>
<style>
<class name="linked"/>
+ <class name="viewswitcher"/>
</style>
<property name="model">
<object class="GtkSingleSelection" id="selected-view">
@@ -203,6 +207,11 @@
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
+ <binding name="tooltip-text">
+ <lookup type="FileBrowserView" name="title">
+ <lookup name="item">GtkListItem</lookup>
+ </lookup>
+ </binding>
</object>
</property>
</template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]