A new combo box
Add a new, simple combo box. The feature set of this is similar to GtkComboBoxText, but it is using a popover and supports search. https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/theming/widgets/combobox-replacements.png
This commit is contained in:
committed by
Emmanuele Bassi
parent
525732b623
commit
5106f16f9c
@@ -159,6 +159,7 @@ gtk_public_h_sources = \
|
||||
gtkcolorchooserwidget.h \
|
||||
gtkcolorchooserdialog.h \
|
||||
gtkcolorutils.h \
|
||||
gtkcombo.h \
|
||||
gtkcombobox.h \
|
||||
gtkcomboboxtext.h \
|
||||
gtkcontainer.h \
|
||||
@@ -608,6 +609,7 @@ gtk_base_c_sources = \
|
||||
gtkcolorscale.c \
|
||||
gtkcolorswatch.c \
|
||||
gtkcolorutils.c \
|
||||
gtkcombo.c \
|
||||
gtkcombobox.c \
|
||||
gtkcomboboxtext.c \
|
||||
gtkcontainer.c \
|
||||
@@ -1079,8 +1081,10 @@ templates = \
|
||||
ui/gtkassistant.ui \
|
||||
ui/gtkcolorchooserdialog.ui \
|
||||
ui/gtkcoloreditor.ui \
|
||||
ui/gtkcombo.ui \
|
||||
ui/gtkcombobox.ui \
|
||||
ui/gtkdialog.ui \
|
||||
ui/gtkcomborow.ui \
|
||||
ui/gtkdialog.ui \
|
||||
ui/gtkfilechooserbutton.ui \
|
||||
ui/gtkfilechooserwidget.ui \
|
||||
ui/gtkfilechooserdialog.ui \
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
#include <gtk/gtkcolorchooserdialog.h>
|
||||
#include <gtk/gtkcolorchooserwidget.h>
|
||||
#include <gtk/gtkcolorutils.h>
|
||||
#include <gtk/gtkcombo.h>
|
||||
#include <gtk/gtkcombobox.h>
|
||||
#include <gtk/gtkcomboboxtext.h>
|
||||
#include <gtk/gtkcontainer.h>
|
||||
|
||||
1189
gtk/gtkcombo.c
Normal file
1189
gtk/gtkcombo.c
Normal file
File diff suppressed because it is too large
Load Diff
77
gtk/gtkcombo.h
Normal file
77
gtk/gtkcombo.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
*
|
||||
* Copyright (C) 2014 Red Hat, Inc.
|
||||
*
|
||||
* 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.1 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_COMBO_H__
|
||||
#define __GTK_COMBO_H__
|
||||
|
||||
#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
|
||||
#error "Only <gtk/gtk.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <gtk/gtkwidget.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_COMBO (gtk_combo_get_type ())
|
||||
#define GTK_COMBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COMBO, GtkCombo))
|
||||
#define GTK_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_COMBO, GtkComboClass))
|
||||
#define GTK_IS_COMBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COMBO))
|
||||
#define GTK_IS_COMBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COMBO))
|
||||
#define GTK_COMBO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COMBO, GtkComboClass))
|
||||
|
||||
typedef struct _GtkCombo GtkCombo;
|
||||
typedef struct _GtkComboClass GtkComboClass;
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GType gtk_combo_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GtkWidget * gtk_combo_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
const gchar * gtk_combo_get_active (GtkCombo *combo);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_combo_set_active (GtkCombo *combo,
|
||||
const gchar *id);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_combo_add_item (GtkCombo *combo,
|
||||
const gchar *id,
|
||||
const gchar *text,
|
||||
const gchar *sort);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_combo_remove_item (GtkCombo *combo,
|
||||
const gchar *id);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
const gchar * gtk_combo_get_placeholder (GtkCombo *combo);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_combo_set_placeholder (GtkCombo *combo,
|
||||
const gchar *text);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
gboolean gtk_combo_get_allow_custom (GtkCombo *combo);
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gtk_combo_set_allow_custom (GtkCombo *combo,
|
||||
gboolean allow);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_COMBO_H__ */
|
||||
232
gtk/ui/gtkcombo.ui
Normal file
232
gtk/ui/gtkcombo.ui
Normal file
@@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk30">
|
||||
<!-- interface-requires gtk+ 3.10 -->
|
||||
<template class="GtkCombo" parent="GtkBin">
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="button">
|
||||
<property name="visible">True</property>
|
||||
<signal name="key-press-event" handler="button_key_press"/>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="spacing">6</property>
|
||||
<child type="center">
|
||||
<object class="GtkLabel" id="active_label">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="icon-name">pan-down-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<object class="GtkPopover" id="popover">
|
||||
<property name="relative-to">button</property>
|
||||
<property name="position">bottom</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="visible" bind-source="button" bind-property="active" bind-flags="bidirectional"/>
|
||||
<signal name="hide" handler="reset_popover"/>
|
||||
<signal name="key-press-event" handler="popover_key_press"/>
|
||||
<child>
|
||||
<object class="GtkStack" id="stack">
|
||||
<property name="visible">True</property>
|
||||
<property name="vhomogeneous">False</property>
|
||||
<property name="transition-type">slide-left-right</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkRevealer" id="search_revealer">
|
||||
<property name="visible">True</property>
|
||||
<property name="transition-type">slide-down</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="width-chars">15</property>
|
||||
<property name="max-width-chars">15</property>
|
||||
<signal name="search-changed" handler="search_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolled_window">
|
||||
<property name="visible">True</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="vscrollbar-policy">never</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="list">
|
||||
<property name="visible">True</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<property name="width-request">100</property>
|
||||
<signal name="row-activated" handler="list_row_activated"/>
|
||||
<child type="placeholder">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="label" translatable="yes">No match</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="show_more">
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="icon-name">view-more-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="add_custom">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Custom Entry</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="icon-name">pan-end-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">list</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="margin">10</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="custom">
|
||||
<property name="visible">True</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<property name="width-request">100</property>
|
||||
<signal name="row-activated" handler="custom_row_activated"/>
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="back_to_list">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="icon-name">pan-start-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="center">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Custom Entry</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="visible">True</property>
|
||||
<property name="activatable">False</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="custom_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="margin">6</property>
|
||||
<signal name="activate" handler="custom_entry_done"/>
|
||||
<signal name="notify::text" handler="custom_entry_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="visible">True</property>
|
||||
<property name="activatable">False</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="custom_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="label" translatable="yes">Done</property>
|
||||
<signal name="clicked" handler="custom_entry_done"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">custom</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkSizeGroup">
|
||||
<property name="mode">horizontal</property>
|
||||
<property name="ignore-hidden">False</property>
|
||||
<widgets>
|
||||
<widget name="search_entry"/>
|
||||
<widget name="scrolled_window"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkSizeGroup">
|
||||
<property name="mode">horizontal</property>
|
||||
<widgets>
|
||||
<widget name="button"/>
|
||||
<widget name="stack"/>
|
||||
</widgets>
|
||||
</object>
|
||||
</interface>
|
||||
28
gtk/ui/gtkcomborow.ui
Normal file
28
gtk/ui/gtkcomborow.ui
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk30">
|
||||
<!-- interface-requires gtk+ 3.10 -->
|
||||
<template class="GtkComboRow" parent="GtkListBoxRow">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" bind-source="GtkComboRow" bind-property="text"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="check">
|
||||
<property name="icon-name">object-select-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
<property name="visible" bind-source="GtkComboRow" bind-property="active"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
@@ -328,6 +328,8 @@ gtk/ui/gtkapplication-quartz.ui
|
||||
gtk/ui/gtkassistant.ui
|
||||
gtk/ui/gtkcolorchooserdialog.ui
|
||||
gtk/ui/gtkcoloreditor.ui
|
||||
gtk/ui/gtkcombo.ui
|
||||
gtk/ui/gtkcomborow.ui
|
||||
gtk/ui/gtkdialog.ui
|
||||
gtk/ui/gtkfilechooserbutton.ui
|
||||
gtk/ui/gtkfilechooserdialog.ui
|
||||
|
||||
Reference in New Issue
Block a user