Introduce GtkPopover

Now that the GtkBubbleWindow object has been cleaned up and made
more generic, rename it as GtkPopover and make it public.
This commit is contained in:
Carlos Garnacho 2013-11-12 16:55:23 +01:00
parent 8a661b8786
commit caeb896096
7 changed files with 380 additions and 406 deletions

View File

@ -296,6 +296,7 @@ gtk_public_h_sources = \
gtkpapersize.h \
gtkplacessidebar.h \
gtkplug.h \
gtkpopover.h \
gtkprintcontext.h \
gtkprintoperation.h \
gtkprintoperationpreview.h \
@ -411,7 +412,6 @@ gtk_private_h_sources = \
gtkbookmarksmanager.h \
gtkborderimageprivate.h \
gtkboxprivate.h \
gtkbubblewindowprivate.h \
gtkbuilderprivate.h \
gtkbuttonprivate.h \
gtkcairoblurprivate.h \
@ -629,7 +629,6 @@ gtk_base_c_sources = \
gtkborder.c \
gtkborderimage.c \
gtkbox.c \
gtkbubblewindow.c \
gtkbuildable.c \
gtkbuilder.c \
gtkbuilderparser.c \
@ -801,6 +800,7 @@ gtk_base_c_sources = \
gtkprivatetypebuiltins.c \
gtkprogressbar.c \
gtkpixelcache.c \
gtkpopover.c \
gtkradiobutton.c \
gtkradiomenuitem.c \
gtkradiotoolbutton.c \

View File

@ -144,6 +144,7 @@
#include <gtk/gtkpapersize.h>
#include <gtk/gtkpaned.h>
#include <gtk/gtkplacessidebar.h>
#include <gtk/gtkpopover.h>
#include <gtk/gtkprintcontext.h>
#include <gtk/gtkprintoperation.h>
#include <gtk/gtkprintoperationpreview.h>

View File

@ -1,67 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright © 2013 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_BUBBLE_WINDOW_H__
#define __GTK_BUBBLE_WINDOW_H__
#include <gtk/gtkwindow.h>
G_BEGIN_DECLS
#define GTK_TYPE_BUBBLE_WINDOW (_gtk_bubble_window_get_type ())
#define GTK_BUBBLE_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_BUBBLE_WINDOW, GtkBubbleWindow))
#define GTK_BUBBLE_WINDOW_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_BUBBLE_WINDOW, GtkBubbleWindowClass))
#define GTK_IS_BUBBLE_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_BUBBLE_WINDOW))
#define GTK_IS_BUBBLE_WINDOW_CLASS(o) (G_TYPE_CHECK_CLASS_TYPE ((o), GTK_TYPE_BUBBLE_WINDOW))
#define GTK_BUBBLE_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_BUBBLE_WINDOW, GtkBubbleWindowClass))
typedef struct _GtkBubbleWindow GtkBubbleWindow;
typedef struct _GtkBubbleWindowClass GtkBubbleWindowClass;
struct _GtkBubbleWindow
{
GtkBin parent_instance;
/*< private >*/
gpointer priv;
};
struct _GtkBubbleWindowClass
{
GtkBinClass parent_class;
};
GType _gtk_bubble_window_get_type (void) G_GNUC_CONST;
GtkWidget * _gtk_bubble_window_new (GtkWidget *relative_to);
void _gtk_bubble_window_set_relative_to (GtkBubbleWindow *window,
GtkWidget *relative_to);
GtkWidget * _gtk_bubble_window_get_relative_to (GtkBubbleWindow *window);
void _gtk_bubble_window_set_pointing_to (GtkBubbleWindow *window,
cairo_rectangle_int_t *rect);
gboolean _gtk_bubble_window_get_pointing_to (GtkBubbleWindow *window,
cairo_rectangle_int_t *rect);
void _gtk_bubble_window_set_position (GtkBubbleWindow *window,
GtkPositionType position);
GtkPositionType
_gtk_bubble_window_get_position (GtkBubbleWindow *window);
G_END_DECLS
#endif /* __GTK_BUBBLE_WINDOW_H__ */

View File

@ -63,7 +63,7 @@
#include "gtkwidgetprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtktexthandleprivate.h"
#include "gtkbubblewindowprivate.h"
#include "gtkpopover.h"
#include "gtktoolbar.h"
#include "a11y/gtkentryaccessible.h"
@ -158,7 +158,7 @@ struct _GtkEntryPrivate
gchar *placeholder_text;
GtkBubbleWindow *bubble_window;
GtkWidget *bubble_window;
GtkTextHandle *text_handle;
GtkWidget *selection_bubble;
guint selection_bubble_timeout_id;
@ -9405,9 +9405,9 @@ bubble_targets_received (GtkClipboard *clipboard,
if (priv->selection_bubble)
gtk_widget_destroy (priv->selection_bubble);
priv->selection_bubble = _gtk_bubble_window_new (GTK_WIDGET (entry));
_gtk_bubble_window_set_position (GTK_BUBBLE_WINDOW (priv->selection_bubble),
GTK_POS_TOP);
priv->selection_bubble = gtk_popover_new (GTK_WIDGET (entry));
gtk_popover_set_position (GTK_POPOVER (priv->selection_bubble),
GTK_POS_TOP);
toolbar = GTK_WIDGET (gtk_toolbar_new ());
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_TEXT);
@ -9456,8 +9456,7 @@ bubble_targets_received (GtkClipboard *clipboard,
rect.width = 0;
}
_gtk_bubble_window_set_pointing_to (GTK_BUBBLE_WINDOW (priv->selection_bubble),
&rect);
gtk_popover_set_pointing_to (GTK_POPOVER (priv->selection_bubble), &rect);
gtk_widget_show (priv->selection_bubble);
priv->selection_bubble_timeout_id = 0;

File diff suppressed because it is too large Load Diff

78
gtk/gtkpopover.h Normal file
View File

@ -0,0 +1,78 @@
/* GTK - The GIMP Toolkit
* Copyright © 2013 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_POPOVER_H__
#define __GTK_POPOVER_H__
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkwindow.h>
G_BEGIN_DECLS
#define GTK_TYPE_POPOVER (gtk_popover_get_type ())
#define GTK_POPOVER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_POPOVER, GtkPopover))
#define GTK_POPOVER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_POPOVER, GtkPopoverClass))
#define GTK_IS_POPOVER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_POPOVER))
#define GTK_IS_POPOVER_CLASS(o) (G_TYPE_CHECK_CLASS_TYPE ((o), GTK_TYPE_POPOVER))
#define GTK_POPOVER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_POPOVER, GtkPopoverClass))
typedef struct _GtkPopover GtkPopover;
typedef struct _GtkPopoverClass GtkPopoverClass;
struct _GtkPopover
{
GtkBin parent_instance;
/*< private >*/
gpointer priv;
};
struct _GtkPopoverClass
{
GtkBinClass parent_class;
};
GDK_AVAILABLE_IN_3_12
GType gtk_popover_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_12
GtkWidget * gtk_popover_new (GtkWidget *relative_to);
GDK_AVAILABLE_IN_3_12
void gtk_popover_set_relative_to (GtkPopover *popover,
GtkWidget *relative_to);
GDK_AVAILABLE_IN_3_12
GtkWidget * gtk_popover_get_relative_to (GtkPopover *popover);
GDK_AVAILABLE_IN_3_12
void gtk_popover_set_pointing_to (GtkPopover *popover,
cairo_rectangle_int_t *rect);
GDK_AVAILABLE_IN_3_12
gboolean gtk_popover_get_pointing_to (GtkPopover *popover,
cairo_rectangle_int_t *rect);
GDK_AVAILABLE_IN_3_12
void gtk_popover_set_position (GtkPopover *popover,
GtkPositionType position);
GDK_AVAILABLE_IN_3_12
GtkPositionType gtk_popover_get_position (GtkPopover *popover);
G_END_DECLS
#endif /* __GTK_POPOVER_H__ */

View File

@ -51,7 +51,7 @@
#include "gtktexthandleprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkbubblewindowprivate.h"
#include "gtkpopover.h"
#include "gtktoolbar.h"
#include "gtkpixelcacheprivate.h"
@ -8901,9 +8901,9 @@ bubble_targets_received (GtkClipboard *clipboard,
if (priv->selection_bubble)
gtk_widget_destroy (priv->selection_bubble);
priv->selection_bubble = _gtk_bubble_window_new (GTK_WIDGET (text_view));
_gtk_bubble_window_set_position (GTK_BUBBLE_WINDOW (priv->selection_bubble),
GTK_POS_TOP);
priv->selection_bubble = gtk_popover_new (GTK_WIDGET (text_view));
gtk_popover_set_position (GTK_POPOVER (priv->selection_bubble),
GTK_POS_TOP);
toolbar = GTK_WIDGET (gtk_toolbar_new ());
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_TEXT);
@ -8932,8 +8932,7 @@ bubble_targets_received (GtkClipboard *clipboard,
rect.x -= priv->xoffset;
rect.y -= priv->yoffset;
_gtk_bubble_window_set_pointing_to (GTK_BUBBLE_WINDOW (priv->selection_bubble),
&rect);
gtk_popover_set_pointing_to (GTK_POPOVER (priv->selection_bubble), &rect);
gtk_widget_show (priv->selection_bubble);
priv->selection_bubble_timeout_id = 0;