summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2018-06-08 14:23:52 +0200
committerraveit65 <[email protected]>2018-06-21 08:19:10 +0200
commitd21cbadc64065b72eb6494247bbc6d876d57eb14 (patch)
tree5812414001d2fec81755607b04ea6deace6d243b
parentf6d429e01de132233c5288616e57772e687358bf (diff)
downloadmate-control-center-d21cbadc64065b72eb6494247bbc6d876d57eb14.tar.bz2
mate-control-center-d21cbadc64065b72eb6494247bbc6d876d57eb14.tar.xz
libslab: code clean up
Since we use GtkSearchEntry a lot of code can be dropped. https://github.com/mate-desktop/mate-control-center/commit/afcb324 Eg: GtkSearchEntry has a own menu in result search-context-picker.c does nothing. So other code in searchbar.c isn't used.
-rw-r--r--libslab/Makefile.am2
-rw-r--r--libslab/app-shell.c4
-rw-r--r--libslab/nld-marshal.list2
-rw-r--r--libslab/search-bar.c119
-rw-r--r--libslab/search-bar.h10
-rw-r--r--libslab/search-context-picker.c201
-rw-r--r--libslab/search-context-picker.h62
-rw-r--r--libslab/slab.h1
8 files changed, 6 insertions, 395 deletions
diff --git a/libslab/Makefile.am b/libslab/Makefile.am
index 93a728d0..97deea54 100644
--- a/libslab/Makefile.am
+++ b/libslab/Makefile.am
@@ -17,7 +17,6 @@ HEADER_FILES= \
libslab-utils.h \
nameplate-tile.h \
search-bar.h \
- search-context-picker.h \
shell-window.h \
slab-mate-util.h \
slab-section.h \
@@ -37,7 +36,6 @@ libmate_slab_la_SOURCES = \
libslab-utils.c \
nameplate-tile.c \
search-bar.c \
- search-context-picker.c \
shell-window.c \
slab-mate-util.c \
slab-section.c \
diff --git a/libslab/app-shell.c b/libslab/app-shell.c
index ba13fa4f..05d5617e 100644
--- a/libslab/app-shell.c
+++ b/libslab/app-shell.c
@@ -74,7 +74,7 @@ static void launch_selected_app (AppShellData * app_data);
static void generate_potential_apps (gpointer catdata, gpointer user_data);
static void relayout_shell (AppShellData * app_data);
-static gboolean handle_filter_changed (NldSearchBar * search_bar, int context, const char *text,
+static gboolean handle_filter_changed (NldSearchBar * search_bar, const char *text,
gpointer user_data);
static void handle_group_clicked (Tile * tile, TileEvent * event, gpointer user_data);
static void set_state (AppShellData * app_data, GtkWidget * widget);
@@ -581,7 +581,7 @@ handle_filter_changed_delayed (gpointer user_data)
}
static gboolean
-handle_filter_changed (NldSearchBar * search_bar, int context, const char *text, gpointer data)
+handle_filter_changed (NldSearchBar * search_bar, const char *text, gpointer data)
{
AppShellData *app_data;
diff --git a/libslab/nld-marshal.list b/libslab/nld-marshal.list
index 158cf7a7..30ba5d8d 100644
--- a/libslab/nld-marshal.list
+++ b/libslab/nld-marshal.list
@@ -1 +1 @@
-VOID:INT,STRING
+VOID:STRING
diff --git a/libslab/search-bar.c b/libslab/search-bar.c
index 9a734ec0..157c4ba4 100644
--- a/libslab/search-bar.c
+++ b/libslab/search-bar.c
@@ -21,7 +21,6 @@
#include "search-bar.h"
#include "config.h"
-#include "search-context-picker.h"
#include "nld-marshal.h"
#include <glib/gi18n-lib.h>
@@ -29,7 +28,6 @@
typedef struct
{
GtkWidget *hbox;
- NldSearchContextPicker *context_picker;
GtkEntry *entry;
GtkWidget *button;
@@ -75,8 +73,7 @@ static void nld_search_bar_class_init (NldSearchBarClass * nld_search_bar_class)
signals[SEARCH] =
g_signal_new ("search", G_TYPE_FROM_CLASS (nld_search_bar_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (NldSearchBarClass, search),
- NULL, NULL, nld_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, G_TYPE_INT,
- G_TYPE_STRING);
+ NULL, NULL, nld_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}
static void
@@ -151,8 +148,6 @@ nld_search_bar_clear (NldSearchBar * search_bar)
priv->block_signal = TRUE;
gtk_entry_set_text (priv->entry, "");
- if (priv->context_picker)
- nld_search_context_picker_set_context (priv->context_picker, 0);
priv->block_signal = FALSE;
}
@@ -170,7 +165,7 @@ emit_search (NldSearchBar * search_bar)
priv->timeout_id = 0;
}
- g_signal_emit (search_bar, signals[SEARCH], 0, nld_search_bar_get_context_id (search_bar),
+ g_signal_emit (search_bar, signals[SEARCH], 0,
nld_search_bar_get_text (search_bar));
}
@@ -180,96 +175,6 @@ emit_search_callback (GtkWidget * widget, gpointer search_bar)
emit_search (search_bar);
}
-gboolean
-nld_search_bar_get_show_contexts (NldSearchBar * search_bar)
-{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
-
- return priv->context_picker && gtk_widget_get_visible (GTK_WIDGET (priv->context_picker));
-}
-
-static NldSearchContextPicker *
-build_context_picker (NldSearchBar * search_bar)
-{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
- GtkWidget *picker;
-
- picker = nld_search_context_picker_new ();
- g_signal_connect (picker, "context_changed", G_CALLBACK (emit_search_callback), search_bar);
-
- gtk_box_pack_start (GTK_BOX (priv->hbox), picker, 0, 0, FALSE);
- gtk_box_reorder_child (GTK_BOX (priv->hbox), picker, 0);
-
- return NLD_SEARCH_CONTEXT_PICKER (picker);
-}
-
-void
-nld_search_bar_set_show_contexts (NldSearchBar * search_bar, gboolean show_contexts)
-{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
-
- if (show_contexts)
- {
- if (!priv->context_picker)
- priv->context_picker = build_context_picker (search_bar);
- gtk_widget_show (GTK_WIDGET (priv->context_picker));
- }
- else if (priv->context_picker)
- gtk_widget_hide (GTK_WIDGET (priv->context_picker));
-}
-
-void
-nld_search_bar_add_context (NldSearchBar * search_bar, const char *label, const char *icon_name,
- int context_id)
-{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
-
- if (!priv->context_picker)
- priv->context_picker = build_context_picker (search_bar);
-
- nld_search_context_picker_add_context (priv->context_picker, label, icon_name, context_id);
-}
-
-gboolean
-nld_search_bar_get_show_button (NldSearchBar * search_bar)
-{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
-
- return priv->button != NULL;
-}
-
-void
-nld_search_bar_set_show_button (NldSearchBar * search_bar, gboolean show_button)
-{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
-
- if (show_button)
- {
- GtkWidget *image;
-
- if (priv->button)
- return;
-
- priv->button = gtk_button_new_with_label (_("Find Now"));
- image = gtk_image_new_from_icon_name ("system-search", GTK_ICON_SIZE_MENU);
- gtk_button_set_image (GTK_BUTTON (priv->button), image);
- gtk_widget_show (priv->button);
-
- g_signal_connect (priv->button, "clicked", G_CALLBACK (emit_search_callback),
- search_bar);
-
- gtk_box_pack_end (GTK_BOX (priv->hbox), priv->button, FALSE, FALSE, 0);
- }
- else
- {
- if (!priv->button)
- return;
-
- gtk_widget_destroy (priv->button);
- priv->button = NULL;
- }
-}
-
static gboolean
search_timeout (gpointer search_bar)
{
@@ -337,23 +242,3 @@ nld_search_bar_set_text (NldSearchBar * search_bar, const char *text, gboolean a
emit_search (search_bar);
}
-int
-nld_search_bar_get_context_id (NldSearchBar * search_bar)
-{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
-
- if (priv->context_picker && gtk_widget_get_visible (GTK_WIDGET (priv->context_picker)))
- return nld_search_context_picker_get_context (priv->context_picker);
- else
- return -1;
-}
-
-void
-nld_search_bar_set_context_id (NldSearchBar * search_bar, int context_id)
-{
- NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
-
- g_return_if_fail (priv->context_picker != NULL);
-
- nld_search_context_picker_set_context (priv->context_picker, context_id);
-}
diff --git a/libslab/search-bar.h b/libslab/search-bar.h
index f713b20f..65d0aba7 100644
--- a/libslab/search-bar.h
+++ b/libslab/search-bar.h
@@ -43,7 +43,7 @@ typedef struct
{
GtkBoxClass parent_class;
- void (*search) (NldSearchBar *, int context_id, const char *text);
+ void (*search) (NldSearchBar *, const char *text);
} NldSearchBarClass;
GType nld_search_bar_get_type (void);
@@ -53,11 +53,6 @@ GtkWidget *nld_search_bar_new (void);
void nld_search_bar_clear (NldSearchBar * search_bar);
gboolean nld_search_bar_has_focus (NldSearchBar * search_bar);
-gboolean nld_search_bar_get_show_contexts (NldSearchBar * search_bar);
-void nld_search_bar_set_show_contexts (NldSearchBar * search_bar, gboolean show_contexts);
-void nld_search_bar_add_context (NldSearchBar * search_bar, const char *label,
- const char *icon_name, int context_id);
-
gboolean nld_search_bar_get_show_button (NldSearchBar * search_bar);
void nld_search_bar_set_show_button (NldSearchBar * search_bar, gboolean show_button);
@@ -67,9 +62,6 @@ void nld_search_bar_set_search_timeout (NldSearchBar * search_bar, int search_ti
const char *nld_search_bar_get_text (NldSearchBar * search_bar);
void nld_search_bar_set_text (NldSearchBar * search_bar, const char *text, gboolean activate);
-int nld_search_bar_get_context_id (NldSearchBar * search_bar);
-void nld_search_bar_set_context_id (NldSearchBar * search_bar, int context_id);
-
#ifdef __cplusplus
}
#endif
diff --git a/libslab/search-context-picker.c b/libslab/search-context-picker.c
deleted file mode 100644
index 104955ee..00000000
--- a/libslab/search-context-picker.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * This file is part of libslab.
- *
- * Copyright (c) 2006 Novell, Inc.
- *
- * Libslab 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.
- *
- * Libslab 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 libslab; if not, write to the Free Software Foundation, Inc., 51
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "search-context-picker.h"
-
-#include <gtk/gtk.h>
-
-typedef struct
-{
- GtkImage *cur_icon;
- int cur_context;
- GtkWidget *menu;
-} NldSearchContextPickerPrivate;
-
-#define NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NLD_TYPE_SEARCH_CONTEXT_PICKER, NldSearchContextPickerPrivate))
-
-enum
-{
- CONTEXT_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static void nld_search_context_picker_class_init (NldSearchContextPickerClass *);
-static void nld_search_context_picker_init (NldSearchContextPicker *);
-
-static void nld_search_context_picker_clicked (GtkButton *);
-
-G_DEFINE_TYPE (NldSearchContextPicker, nld_search_context_picker, GTK_TYPE_BUTTON)
-
-static void nld_search_context_picker_class_init (NldSearchContextPickerClass *
- nld_search_context_picker_class)
-{
- GtkButtonClass *button_class = GTK_BUTTON_CLASS (nld_search_context_picker_class);
-
- button_class->clicked = nld_search_context_picker_clicked;
-
- g_type_class_add_private (nld_search_context_picker_class,
- sizeof (NldSearchContextPickerPrivate));
-
- signals[CONTEXT_CHANGED] = g_signal_new ("context-changed",
- G_TYPE_FROM_CLASS (nld_search_context_picker_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (NldSearchContextPickerClass, context_changed),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-}
-
-static void
-nld_search_context_picker_init (NldSearchContextPicker * picker)
-{
- NldSearchContextPickerPrivate *priv = NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE (picker);
- GtkWidget *hbox;
- GtkWidget *separator;
-
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
- gtk_container_add (GTK_CONTAINER (picker), hbox);
-
- priv->cur_icon = GTK_IMAGE (gtk_image_new ());
- gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (priv->cur_icon), FALSE, FALSE, 0);
-
- separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
- gtk_box_pack_start (GTK_BOX (hbox), separator, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), gtk_image_new_from_icon_name ("pan-down-symbolic", GTK_ICON_SIZE_MENU), FALSE, FALSE, 0);
-
- gtk_widget_show_all (hbox);
-
- priv->cur_context = -1;
-
- priv->menu = gtk_menu_new ();
-}
-
-GtkWidget *
-nld_search_context_picker_new (void)
-{
- return g_object_new (NLD_TYPE_SEARCH_CONTEXT_PICKER, NULL);
-}
-
-static void
-menu_position_func (GtkMenu * menu, int *x, int *y, gboolean * push_in, gpointer picker)
-{
- GtkWidget *widget = GTK_WIDGET (picker);
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (widget, &allocation);
- gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
- *x += allocation.x;
- *y += allocation.y + allocation.height;
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- {
- GtkRequisition req;
- gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
- *x += allocation.width - req.width;
- }
-
- *push_in = FALSE;
-}
-
-static void
-nld_search_context_picker_clicked (GtkButton * button)
-{
- NldSearchContextPickerPrivate *priv = NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE (button);
-
- gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL, menu_position_func, button, 1,
- gtk_get_current_event_time ());
-}
-
-static void
-item_activated (GtkMenuItem * item, gpointer picker)
-{
- NldSearchContextPickerPrivate *priv = NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE (picker);
- GtkImage *image;
- const char *icon_name;
- GtkIconSize icon_size;
-
- image = GTK_IMAGE (gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (item)));
- gtk_image_get_icon_name (image, &icon_name, &icon_size);
- gtk_image_set_from_icon_name (priv->cur_icon, icon_name, icon_size);
-
- priv->cur_context =
- GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item),
- "NldSearchContextPicker:context_id"));
- g_signal_emit (picker, signals[CONTEXT_CHANGED], 0);
-}
-
-void
-nld_search_context_picker_add_context (NldSearchContextPicker * picker, const char *label,
- const char *icon_name, int context_id)
-{
- NldSearchContextPickerPrivate *priv = NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE (picker);
- GtkWidget *item = gtk_image_menu_item_new_with_label (label);
- GtkWidget *image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
- GList *children = gtk_container_get_children (GTK_CONTAINER (priv->menu));
- gboolean first = children == NULL;
-
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- g_object_set_data (G_OBJECT (item), "NldSearchContextPicker:context_id",
- GINT_TO_POINTER (context_id));
- g_signal_connect (item, "activate", G_CALLBACK (item_activated), picker);
- gtk_widget_show_all (item);
-
- gtk_container_add (GTK_CONTAINER (priv->menu), item);
- if (first) {
- item_activated (GTK_MENU_ITEM (item), picker);
- g_list_free (children);
- }
-}
-
-int
-nld_search_context_picker_get_context (NldSearchContextPicker * picker)
-{
- NldSearchContextPickerPrivate *priv = NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE (picker);
-
- return priv->cur_context;
-}
-
-void
-nld_search_context_picker_set_context (NldSearchContextPicker * picker, int context_id)
-{
- NldSearchContextPickerPrivate *priv = NLD_SEARCH_CONTEXT_PICKER_GET_PRIVATE (picker);
- GList *children;
-
- children = gtk_container_get_children (GTK_CONTAINER (priv->menu));
- while (children)
- {
- GtkMenuItem *item = children->data;
- int item_id =
- GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item),
- "NldSearchContextPicker:content_id"));
-
- if (item_id == context_id)
- {
- item_activated (item, picker);
- return;
- }
-
- children = children->next;
- }
- g_list_free (children);
-
- priv->cur_context = -1;
- g_signal_emit (picker, signals[CONTEXT_CHANGED], 0);
-}
diff --git a/libslab/search-context-picker.h b/libslab/search-context-picker.h
deleted file mode 100644
index 9480c249..00000000
--- a/libslab/search-context-picker.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * This file is part of libslab.
- *
- * Copyright (c) 2006 Novell, Inc.
- *
- * Libslab 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.
- *
- * Libslab 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 libslab; if not, write to the Free Software Foundation, Inc., 51
- * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __NLD_SEARCH_CONTEXT_PICKER_H__
-#define __NLD_SEARCH_CONTEXT_PICKER_H__
-
-#include <gtk/gtk.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NLD_TYPE_SEARCH_CONTEXT_PICKER (nld_search_context_picker_get_type ())
-#define NLD_SEARCH_CONTEXT_PICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NLD_TYPE_SEARCH_CONTEXT_PICKER, NldSearchContextPicker))
-#define NLD_SEARCH_CONTEXT_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NLD_TYPE_SEARCH_CONTEXT_PICKER, NldSearchContextPickerClass))
-#define NLD_IS_SEARCH_CONTEXT_PICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NLD_TYPE_SEARCH_CONTEXT_PICKER))
-#define NLD_IS_SEARCH_CONTEXT_PICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NLD_TYPE_SEARCH_CONTEXT_PICKER))
-#define NLD_SEARCH_CONTEXT_PICKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NLD_TYPE_SEARCH_CONTEXT_PICKER, NldSearchContextPickerClass))
-
-typedef struct
-{
- GtkButton parent;
-} NldSearchContextPicker;
-
-typedef struct
-{
- GtkButtonClass parent_class;
-
- void (*context_changed) (NldSearchContextPicker *);
-} NldSearchContextPickerClass;
-
-GType nld_search_context_picker_get_type (void);
-
-GtkWidget *nld_search_context_picker_new (void);
-
-void nld_search_context_picker_add_context (NldSearchContextPicker * picker, const char *label,
- const char *icon_name, int context_id);
-
-int nld_search_context_picker_get_context (NldSearchContextPicker * picker);
-void nld_search_context_picker_set_context (NldSearchContextPicker * picker, int context_id);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __NLD_SEARCH_CONTEXT_PICKER_H__ */
diff --git a/libslab/slab.h b/libslab/slab.h
index a50dddf9..721943a0 100644
--- a/libslab/slab.h
+++ b/libslab/slab.h
@@ -31,7 +31,6 @@
#include "libslab-utils.h"
#include "nameplate-tile.h"
#include "search-bar.h"
-#include "search-context-picker.h"
#include "shell-window.h"
#include "slab-mate-util.h"
#include "slab-section.h"