...
 
Commits (7)
......@@ -8,6 +8,7 @@ Gd-1.0.typelib
gd.gresource.xml
gd-resources.*
test-tagged-entry
test-tagged-entry-2
Makefile
Makefile.in
gd-1.0.vapi
......
......@@ -160,7 +160,11 @@ tagged_entry_sources = \
nodist_libgd_la_SOURCES += $(tagged_entry_sources)
EXTRA_DIST += $(tagged_entry_sources)
noinst_PROGRAMS += test-tagged-entry
noinst_PROGRAMS += \
test-tagged-entry \
test-tagged-entry-2 \
$(null)
test_tagged_entry_SOURCES = \
test-tagged-entry.c \
$(NULL)
......@@ -168,6 +172,14 @@ test_tagged_entry_LDADD = \
$(LIBGD_LIBS) \
libgd.la \
$(NULL)
test_tagged_entry_2_SOURCES = \
test-tagged-entry-2.c \
$(NULL)
test_tagged_entry_2_LDADD = \
$(LIBGD_LIBS) \
libgd.la \
$(NULL)
endif
if LIBGD_GIR
......
......@@ -260,7 +260,6 @@ static void
gd_main_box_class_init (GdMainBoxClass *klass)
{
GObjectClass *oclass = G_OBJECT_CLASS (klass);
GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass);
oclass->get_property = gd_main_box_get_property;
oclass->set_property = gd_main_box_set_property;
......
......@@ -51,6 +51,21 @@ G_DEFINE_TYPE_WITH_CODE (GdMainIconBoxChild, gd_main_icon_box_child, GTK_TYPE_FL
G_ADD_PRIVATE (GdMainIconBoxChild)
G_IMPLEMENT_INTERFACE (GD_TYPE_MAIN_BOX_CHILD, gd_main_box_child_interface_init))
static gboolean
gd_main_icon_box_child_bind_text_to_visible (GBinding *binding,
const GValue *from_value,
GValue *to_value,
gpointer user_data)
{
gboolean to_visible;
const gchar *from_text;
from_text = g_value_get_string (from_value);
to_visible = from_text != NULL && from_text[0] != '\0' ? TRUE : FALSE;
g_value_set_boolean (to_value, to_visible);
return TRUE;
}
static void
gd_main_icon_box_check_button_toggled (GdMainIconBoxChild *self)
{
......@@ -206,9 +221,18 @@ gd_main_icon_box_child_update_layout (GdMainIconBoxChild *self)
GtkWidget *primary_label;
primary_label = gtk_label_new (NULL);
gtk_widget_set_no_show_all (primary_label, TRUE);
gtk_label_set_ellipsize (GTK_LABEL (primary_label), PANGO_ELLIPSIZE_MIDDLE);
gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE);
g_object_bind_property (priv->item, "primary-text", primary_label, "label", G_BINDING_SYNC_CREATE);
g_object_bind_property_full (priv->item,
"primary-text",
primary_label,
"visible",
G_BINDING_SYNC_CREATE,
gd_main_icon_box_child_bind_text_to_visible,
NULL,
NULL,
NULL);
gtk_container_add (GTK_CONTAINER (grid), primary_label);
}
......@@ -218,11 +242,20 @@ gd_main_icon_box_child_update_layout (GdMainIconBoxChild *self)
GtkWidget *secondary_label;
secondary_label = gtk_label_new (NULL);
gtk_widget_set_no_show_all (secondary_label, TRUE);
gtk_label_set_ellipsize (GTK_LABEL (secondary_label), PANGO_ELLIPSIZE_END);
gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE);
context = gtk_widget_get_style_context (secondary_label);
gtk_style_context_add_class (context, "dim-label");
g_object_bind_property (priv->item, "secondary-text", secondary_label, "label", G_BINDING_SYNC_CREATE);
g_object_bind_property_full (priv->item,
"secondary-text",
secondary_label,
"visible",
G_BINDING_SYNC_CREATE,
gd_main_icon_box_child_bind_text_to_visible,
NULL,
NULL,
NULL);
gtk_container_add (GTK_CONTAINER (grid), secondary_label);
}
......
......@@ -172,8 +172,6 @@ gd_main_icon_box_icon_size_allocate (GtkWidget *widget, GtkAllocation *allocatio
gint scale_factor;
gint width_scaled;
gint width_zoomed_scaled;
gint x_scaled;
gint y_scaled;
GTK_WIDGET_CLASS (gd_main_icon_box_icon_parent_class)->size_allocate (widget, allocation);
......
......@@ -386,7 +386,7 @@ gd_main_icon_box_button_release_event (GtkWidget *widget, GdkEventButton *event)
}
if (!priv->selection_mode &&
(event->button == GDK_BUTTON_PRIMARY && (event->state & GDK_CONTROL_MASK) != 0 ||
((event->button == GDK_BUTTON_PRIMARY && (event->state & GDK_CONTROL_MASK) != 0) ||
event->button == GDK_BUTTON_SECONDARY))
{
g_signal_emit_by_name (self, "selection-mode-request");
......@@ -595,7 +595,6 @@ gd_main_icon_box_drag_data_get (GtkWidget *widget,
GdMainIconBox *self = GD_MAIN_ICON_BOX (widget);
GdMainIconBoxPrivate *priv;
GPtrArray *uri_array = NULL;
gchar **uris = NULL;
priv = gd_main_icon_box_get_instance_private (self);
......
......@@ -104,6 +104,7 @@ render_activity (GdTogglePixbufRenderer *self,
x = cell_area->x + (cell_area->width / 2) - (width / 2) - xpad;
y = cell_area->y + (cell_area->height / 2) - (height / 2) - ypad;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_paint_spinner (gtk_widget_get_style (widget),
cr,
GTK_STATE_FLAG_ACTIVE,
......@@ -112,6 +113,7 @@ render_activity (GdTogglePixbufRenderer *self,
(guint) self->priv->pulse - 1,
x, y,
width, height);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
static void
......
......@@ -17,10 +17,6 @@
*
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "gd-types-catalog.h"
#ifdef LIBGD__BOX_COMMON
......
......@@ -20,10 +20,6 @@
#ifndef __GD_H__
#define __GD_H__
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <glib-object.h>
G_BEGIN_DECLS
......
#include <gtk/gtk.h>
#include <libgd/gd-tagged-entry.h>
static GdTaggedEntryTag *toggle_tag;
static void
on_tag_clicked (GdTaggedEntry *entry,
GdTaggedEntryTag *tag,
gpointer useless)
{
g_print ("tag clicked: %s\n", gd_tagged_entry_tag_get_label (tag));
}
static void
on_tag_button_clicked (GdTaggedEntry *entry,
GdTaggedEntryTag *tag,
gpointer useless)
{
g_print ("tag button clicked: %s\n", gd_tagged_entry_tag_get_label (tag));
}
static void
on_toggle_visible (GtkButton *button,
GtkWidget *entry)
{
gboolean active;
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
g_print ("%s tagged entry\n", active ? "show" : "hide");
gtk_widget_set_visible (entry, active);
}
static void
on_toggle_tag (GtkButton *button,
GdTaggedEntry *entry)
{
gboolean active;
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
if (active)
{
g_print ("adding tag 'Toggle Tag'\n");
gd_tagged_entry_insert_tag (entry, toggle_tag, 0);
}
else
{
g_print ("removing tag 'Toggle Tag'\n");
gd_tagged_entry_remove_tag (entry, toggle_tag);
}
}
gint
main (gint argc,
gchar ** argv)
{
GtkWidget *box;
GtkWidget *entry;
GtkWidget *search_bar;
GtkWidget *search_container;
GtkWidget *toggle_tag_button;
GtkWidget *toggle_visible_button;
GtkWidget *revealer;
GtkWidget *window;
GdTaggedEntryTag *tag;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request (window, 640, 600);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
revealer = gtk_revealer_new ();
gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
gtk_container_add (GTK_CONTAINER (box), revealer);
search_bar = gtk_search_bar_new ();
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (search_bar), TRUE);
gtk_container_add (GTK_CONTAINER (revealer), search_bar);
search_container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (search_container, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (search_bar), search_container);
entry = GTK_WIDGET (gd_tagged_entry_new ());
gtk_widget_set_size_request (entry, 500, -1);
g_signal_connect (entry, "tag-clicked",
G_CALLBACK (on_tag_clicked), NULL);
g_signal_connect (entry, "tag-button-clicked",
G_CALLBACK (on_tag_button_clicked), NULL);
gtk_container_add (GTK_CONTAINER (search_container), entry);
tag = gd_tagged_entry_tag_new ("Blah1");
gd_tagged_entry_add_tag (GD_TAGGED_ENTRY (entry), tag);
g_object_unref (tag);
tag = gd_tagged_entry_tag_new ("Blah2");
gd_tagged_entry_tag_set_has_close_button (tag, FALSE);
gd_tagged_entry_insert_tag (GD_TAGGED_ENTRY (entry), tag, -1);
g_object_unref (tag);
tag = gd_tagged_entry_tag_new ("Blah3");
gd_tagged_entry_tag_set_has_close_button (tag, FALSE);
gd_tagged_entry_insert_tag (GD_TAGGED_ENTRY (entry), tag, 0);
g_object_unref (tag);
toggle_visible_button = gtk_toggle_button_new_with_label ("Visible");
gtk_widget_set_vexpand (toggle_visible_button, TRUE);
gtk_widget_set_valign (toggle_visible_button, GTK_ALIGN_END);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle_visible_button), TRUE);
g_signal_connect (toggle_visible_button, "toggled",
G_CALLBACK (on_toggle_visible), entry);
gtk_container_add (GTK_CONTAINER (box), toggle_visible_button);
toggle_tag = gd_tagged_entry_tag_new ("Toggle Tag");
toggle_tag_button = gtk_toggle_button_new_with_label ("Toggle Tag");
g_signal_connect (toggle_tag_button, "toggled",
G_CALLBACK (on_toggle_tag), entry);
gtk_container_add (GTK_CONTAINER (box), toggle_tag_button);
gtk_widget_show_all (window);
gtk_main ();
gtk_widget_destroy (window);
return 0;
}