[gnome-photos/wip/rishi/collection: 26/44] Add PhotosModelButton



commit a050d49a8ff12561d14fd1411c653dba89710799
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jan 16 12:05:17 2018 +0100

    Add PhotosModelButton
    
    This is like a GtkModelButton, but with a custom child inside, which
    isn't currently possible with GtkModelButton.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751212

 src/Makefile.am           |  2 ++
 src/photos-model-button.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++
 src/photos-model-button.h | 33 ++++++++++++++++++++++
 3 files changed, 106 insertions(+)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 7561e1bc..6c006f8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -136,6 +136,8 @@ gnome_photos_SOURCES = \
        photos-main-window.h \
        photos-media-server-item.c \
        photos-media-server-item.h \
+       photos-model-button.c \
+       photos-model-button.h \
        photos-notification-manager.c \
        photos-notification-manager.h \
        photos-offset-collection-view-controller.c \
diff --git a/src/photos-model-button.c b/src/photos-model-button.c
new file mode 100644
index 00000000..83ddf658
--- /dev/null
+++ b/src/photos-model-button.c
@@ -0,0 +1,71 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2018 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "config.h"
+
+#include "photos-model-button.h"
+
+
+struct _PhotosModelButton
+{
+  GtkButton parent_instance;
+};
+
+
+G_DEFINE_TYPE (PhotosModelButton, photos_model_button, GTK_TYPE_BUTTON);
+
+
+static void
+photos_model_button_clicked (GtkButton *button)
+{
+  GtkWidget *popover;
+
+  popover = gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_POPOVER);
+  if (popover != NULL)
+    gtk_popover_popdown (GTK_POPOVER (popover));
+
+  if (GTK_BUTTON_CLASS (photos_model_button_parent_class)->clicked != NULL)
+    GTK_BUTTON_CLASS (photos_model_button_parent_class)->clicked (button);
+}
+
+
+static void
+photos_model_button_init (PhotosModelButton *self)
+{
+  gtk_button_set_relief (GTK_BUTTON (self), GTK_RELIEF_NONE);
+}
+
+
+static void
+photos_model_button_class_init (PhotosModelButtonClass *class)
+{
+  GtkButtonClass *button_class = GTK_BUTTON_CLASS (class);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+
+  button_class->clicked = photos_model_button_clicked;
+
+  gtk_widget_class_set_css_name (widget_class, "modelbutton");
+}
+
+
+GtkWidget *
+photos_model_button_new (void)
+{
+  return g_object_new (PHOTOS_TYPE_MODEL_BUTTON, NULL);
+}
diff --git a/src/photos-model-button.h b/src/photos-model-button.h
new file mode 100644
index 00000000..b0098269
--- /dev/null
+++ b/src/photos-model-button.h
@@ -0,0 +1,33 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2018 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PHOTOS_MODEL_BUTTON_H
+#define PHOTOS_MODEL_BUTTON_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define PHOTOS_TYPE_MODEL_BUTTON (photos_model_button_get_type ())
+G_DECLARE_FINAL_TYPE (PhotosModelButton, photos_model_button, PHOTOS, MODEL_BUTTON, GtkButton);
+
+GtkWidget            *photos_model_button_new               (void);
+
+G_END_DECLS
+
+#endif /* PHOTOS_MODEL_BUTTON_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]