Copied latest libslab

This commit is contained in:
Rodrigo Moya 2009-08-05 12:20:19 +02:00
parent 1cd8bdd9ff
commit 6b76c6a770
24 changed files with 134 additions and 177 deletions

View file

@ -1,16 +1,20 @@
INCLUDES = \
-I$(top_srcdir) \
$(LIBSLAB_CFLAGS) \
$(WARN_CFLAGS)
HEADER_FILES= \
$(BUILT_SOURCES) \
app-resizer.h \
app-shell.h \
app-shell-startup.h \
application-tile.h \
bookmark-agent.h \
directory-tile.h \
document-tile.h \
double-click-detector.h \
gnome-utils.h \
libslab-utils.h \
nameplate-tile.h \
search-bar.h \
search-context-picker.h \
@ -18,33 +22,23 @@ HEADER_FILES= \
shell-window.h \
slab-gnome-util.h \
slab-section.h \
slab.h \
system-tile.h \
tile.h
if ENABLE_DYNAMIC_LIBSLAB
lib_LTLIBRARIES = libslab.la
SOURCE_HEADER_FILES=
else
noinst_LTLIBRARIES = libslab.la
SOURCE_HEADER_FILES=$(HEADER_FILES)
endif
libslab_la_SOURCES = \
$(SOURCE_HEADER_FILES) \
$(MARSHAL_GENERATED) \
app-resizer.c \
app-shell.c \
app-shell-startup.c \
application-tile.c \
bookmark-agent.h \
bookmark-agent.c \
directory-tile.c \
document-tile.c \
double-click-detector.c \
double-click-detector.h \
gnome-utils.c \
libslab-utils.c \
libslab-utils.h \
nameplate-tile.c \
search-bar.c \
search-context-picker.c \
@ -59,20 +53,13 @@ libslab_la_SOURCES = \
tile-action.c \
tile.c
if ENABLE_DYNAMIC_LIBSLAB
libslab_includedir = $(includedir)/slab
libslab_includedir = $(includedir)/libslab
libslab_include_HEADERS = $(HEADER_FILES)
libslab_la_LDFLAGS = \
-version-info $(LT_VERSION)
endif
libslab_la_LDFLAGS = -version-info $(LT_VERSION)
libslab_la_LIBADD = $(LIBSLAB_LIBS)
if ENABLE_DYNAMIC_LIBSLAB
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libslab.pc
endif
search-entry-watermark.h: search-entry-watermark.svg
echo '#define SEARCH_ENTRY_WATERMARK_SVG "\' > $@; \
sed -e 's/"/\\"/g' -e 's/$$/\\/' -e 's/#000000/#%s/g' $< >> $@; \
@ -103,5 +90,3 @@ CLEANFILES = \
EXTRA_DIST= \
search-entry-watermark.svg \
nld-marshal.list
-include $(top_srcdir)/git.mk

View file

@ -24,8 +24,6 @@
#include "app-shell.h"
#include "app-resizer.h"
static GtkLayoutClass *parent_class = NULL;
static void app_resizer_class_init (AppResizerClass *);
static void app_resizer_init (AppResizer *);
static void app_resizer_destroy (GtkObject *);
@ -34,39 +32,14 @@ static void app_resizer_size_allocate (GtkWidget * resizer, GtkAllocation * allo
static gboolean app_resizer_paint_window (GtkWidget * widget, GdkEventExpose * event,
AppShellData * app_data);
GType
app_resizer_get_type (void)
{
static GType object_type = 0;
G_DEFINE_TYPE (AppResizer, app_resizer, GTK_TYPE_LAYOUT);
if (!object_type)
{
static const GTypeInfo object_info = {
sizeof (AppResizerClass),
NULL,
NULL,
(GClassInitFunc) app_resizer_class_init,
NULL,
NULL,
sizeof (AppResizer),
0,
(GInstanceInitFunc) app_resizer_init
};
object_type =
g_type_register_static (GTK_TYPE_LAYOUT, "AppResizer", &object_info, 0);
}
return object_type;
}
static void
app_resizer_class_init (AppResizerClass * klass)
{
GtkWidgetClass *widget_class;
parent_class = g_type_class_peek_parent (klass);
((GtkObjectClass *) klass)->destroy = app_resizer_destroy;
widget_class = GTK_WIDGET_CLASS (klass);
@ -225,8 +198,8 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
if (first_time)
{
/* we are letting the first show be the "natural" size of the child widget so do nothing. */
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
if (GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate) (widget, allocation);
first_time = FALSE;
gtk_layout_set_size (GTK_LAYOUT (resizer), child->allocation.width,
@ -238,8 +211,8 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
{
GtkAllocation child_allocation;
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
if (GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate) (widget, allocation);
/* We want the message to center itself and only scroll if it's bigger than the available real size. */
child_allocation.x = 0;
@ -268,8 +241,8 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
resizer->cur_num_cols = new_num_cols;
}
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
if (GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate) (widget, allocation);
gtk_layout_set_size (GTK_LAYOUT (resizer), child->allocation.width,
child->allocation.height);
}

View file

@ -24,6 +24,8 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <libslab/app-shell.h>
G_BEGIN_DECLS
#define INITIAL_NUM_COLS 3

View file

@ -18,14 +18,11 @@
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#undef GTK_DISABLE_DEPRECATED
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <libgnome/gnome-desktop-item.h>
#include <libgnomeui/libgnomeui.h>
#include <gio/gio.h>
#include <gdk/gdkkeysyms.h>
#include <sys/types.h>
@ -97,47 +94,48 @@ gboolean regenerate_categories (AppShellData * app_data);
void
hide_shell (AppShellData * app_data)
{
gtk_window_get_position (GTK_WINDOW (app_data->main_gnome_app),
&app_data->main_gnome_app_window_x, &app_data->main_gnome_app_window_y);
/* printf("x:%d, y:%d\n", app_data->main_gnome_app_window_x, app_data->main_gnome_app_window_y); */
gtk_window_get_position (GTK_WINDOW (app_data->main_app),
&app_data->main_app_window_x, &app_data->main_app_window_y);
/* printf("x:%d, y:%d\n", app_data->main_app_window_x, app_data->main_app_window_y); */
/* clear the search bar now so reshowing is fast and flicker free - BNC#283186 */
application_launcher_clear_search_bar (app_data);
gtk_widget_hide (app_data->main_gnome_app);
gtk_widget_hide (app_data->main_app);
}
void
show_shell (AppShellData * app_data)
{
gtk_widget_show_all (app_data->main_gnome_app);
gtk_widget_show_all (app_data->main_app);
if (!app_data->static_actions)
gtk_widget_hide_all (app_data->actions_section); /* don't show unless a launcher is selected */
if (app_data->main_gnome_app_window_shown_once)
gtk_window_move (GTK_WINDOW (app_data->main_gnome_app),
app_data->main_gnome_app_window_x, app_data->main_gnome_app_window_y);
if (app_data->main_app_window_shown_once)
gtk_window_move (GTK_WINDOW (app_data->main_app),
app_data->main_app_window_x, app_data->main_app_window_y);
/* if this is the first time shown, need to clear this handler */
else
shell_window_clear_resize_handler (SHELL_WINDOW (app_data->shell));
app_data->main_gnome_app_window_shown_once = TRUE;
app_data->main_app_window_shown_once = TRUE;
}
gboolean
create_main_window (AppShellData * app_data, const gchar * app_name, const gchar * title,
const gchar * window_icon, gint width, gint height, gboolean hidden)
{
GtkWidget *main_app = gnome_app_new (app_name, title);
app_data->main_gnome_app = main_app;
GtkWidget *main_app = gtk_window_new (GTK_WINDOW_TOPLEVEL);
app_data->main_app = main_app;
gtk_widget_set_name (main_app, app_name);
gtk_window_set_title (GTK_WINDOW (main_app), title);
/* gtk_window_set_default_size(GTK_WINDOW(main_app), width, height); */
gtk_window_set_icon_name (GTK_WINDOW (main_app), window_icon);
gnome_app_set_contents (GNOME_APP (main_app), app_data->shell);
gtk_container_add (GTK_CONTAINER (main_app), app_data->shell);
g_signal_connect (main_app, "delete-event", G_CALLBACK (main_delete_callback), app_data);
g_signal_connect (main_app, "key-press-event", G_CALLBACK (main_keypress_callback),
app_data);
gtk_window_set_position (GTK_WINDOW (app_data->main_gnome_app), GTK_WIN_POS_CENTER);
gtk_window_set_position (GTK_WINDOW (app_data->main_app), GTK_WIN_POS_CENTER);
if (!hidden)
show_shell (app_data);
gtk_main ();

View file

@ -25,9 +25,10 @@
#include <gtk/gtk.h>
#define GMENU_I_KNOW_THIS_IS_UNSTABLE
#include <gmenu-tree.h>
#include <libgnome/gnome-desktop-item.h>
#include "slab-section.h"
#include "tile.h"
#include <libslab/slab-section.h>
#include <libslab/tile.h>
G_BEGIN_DECLS
@ -54,10 +55,10 @@ typedef struct
typedef struct _AppShellData
{
GtkWidget *main_gnome_app;
gint main_gnome_app_window_x;
gint main_gnome_app_window_y;
gboolean main_gnome_app_window_shown_once;
GtkWidget *main_app;
gint main_app_window_x;
gint main_app_window_y;
gboolean main_app_window_shown_once;
GtkWidget *shell;
GtkWidget *groups_section;

View file

@ -19,10 +19,11 @@
*/
#include "application-tile.h"
#include "config.h"
#include <string.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
#include <gconf/gconf-client.h>
#include <unistd.h>

View file

@ -21,7 +21,7 @@
#ifndef __APPLICATION_TILE_H__
#define __APPLICATION_TILE_H__
#include "nameplate-tile.h"
#include <libslab/nameplate-tile.h>
#include <libgnome/gnome-desktop-item.h>

View file

@ -30,7 +30,7 @@
#include <string.h>
#include <stdlib.h>
#include <glib/gi18n.h>
#include <glib/gi18n-lib.h>
#include <glib/gstdio.h>
#include <gio/gio.h>

View file

@ -19,8 +19,9 @@
*/
#include "directory-tile.h"
#include "config.h"
#include <glib/gi18n.h>
#include <glib/gi18n-lib.h>
#include <string.h>
#include <gio/gio.h>
#include <gdk/gdk.h>

View file

@ -23,7 +23,7 @@
#include <time.h>
#include "nameplate-tile.h"
#include <libslab/nameplate-tile.h>
G_BEGIN_DECLS

View file

@ -19,8 +19,9 @@
*/
#include "document-tile.h"
#include "config.h"
#include <glib/gi18n.h>
#include <glib/gi18n-lib.h>
#include <string.h>
#include <gio/gio.h>

View file

@ -24,43 +24,11 @@
#include "libslab-utils.h"
static void double_click_detector_class_init (DoubleClickDetectorClass *);
static void double_click_detector_init (DoubleClickDetector *);
static void double_click_detector_dispose (GObject *);
GType
double_click_detector_get_type (void)
{
static GType object_type = 0;
if (!object_type)
{
static const GTypeInfo object_info = {
sizeof (DoubleClickDetectorClass),
NULL,
NULL,
(GClassInitFunc) double_click_detector_class_init,
NULL,
NULL,
sizeof (DoubleClickDetector),
0,
(GInstanceInitFunc) double_click_detector_init
};
object_type =
g_type_register_static (G_TYPE_OBJECT, "DoubleClickDetector", &object_info,
0);
}
return object_type;
}
G_DEFINE_TYPE (DoubleClickDetector, double_click_detector, G_TYPE_OBJECT);
static void
double_click_detector_class_init (DoubleClickDetectorClass * detector_class)
{
GObjectClass *g_obj_class = (GObjectClass *) detector_class;
g_obj_class->dispose = double_click_detector_dispose;
}
static void
@ -83,11 +51,6 @@ double_click_detector_new ()
return g_object_new (DOUBLE_CLICK_DETECTOR_TYPE, NULL);
}
static void
double_click_detector_dispose (GObject * obj)
{
}
gboolean
double_click_detector_is_double_click (DoubleClickDetector *this, guint32 event_time,
gboolean auto_update)

View file

@ -12,6 +12,7 @@
#include <sys/resource.h>
#include <sys/time.h>
#include <gconf/gconf-value.h>
#include <gtk/gtk.h>
#define DESKTOP_ITEM_TERMINAL_EMULATOR_FLAG "TerminalEmulator"
#define ALTERNATE_DOCPATH_KEY "DocPath"
@ -179,6 +180,29 @@ libslab_gnome_desktop_item_get_docpath (GnomeDesktopItem *item)
return path;
}
/* Ugh, here we don't have knowledge of the screen that is being used. So, do
* what we can to find it.
*/
GdkScreen *
libslab_get_current_screen (void)
{
GdkEvent *event;
GdkScreen *screen = NULL;
event = gtk_get_current_event ();
if (event) {
if (event->any.window)
screen = gdk_drawable_get_screen (GDK_DRAWABLE (event->any.window));
gdk_event_free (event);
}
if (!screen)
screen = gdk_screen_get_default ();
return screen;
}
gboolean
libslab_gnome_desktop_item_open_help (GnomeDesktopItem *item)
{
@ -198,9 +222,7 @@ libslab_gnome_desktop_item_open_help (GnomeDesktopItem *item)
if (doc_path) {
help_uri = g_strdup_printf ("ghelp:%s", doc_path);
gtk_show_uri (NULL, help_uri, gtk_get_current_event_time (), &error);
if (error) {
if (!gtk_show_uri (libslab_get_current_screen (), help_uri, gtk_get_current_event_time (), &error)) {
g_warning ("error opening %s [%s]\n", help_uri, error->message);
g_error_free (error);

View file

@ -29,6 +29,8 @@ gboolean libslab_desktop_item_is_lockscreen (const gchar *uri);
gchar *libslab_string_replace_once (const gchar *string, const gchar *key, const gchar *value);
void libslab_spawn_command (const gchar *cmd);
GdkScreen *libslab_get_current_screen (void);
void libslab_thumbnail_factory_preinit (void);
GnomeDesktopThumbnailFactory *libslab_thumbnail_factory_get (void);

View file

@ -122,7 +122,6 @@ static void
nameplate_tile_get_property (GObject * g_object, guint prop_id, GValue * value,
GParamSpec * param_spec)
{
char *tooltip;
NameplateTile *np_tile = NAMEPLATE_TILE (g_object);
switch (prop_id)

View file

@ -21,7 +21,7 @@
#ifndef __NAMEPLATE_TILE_H__
#define __NAMEPLATE_TILE_H__
#include "tile.h"
#include <libslab/tile.h>
#include <gtk/gtk.h>

View file

@ -19,12 +19,13 @@
*/
#include "search-bar.h"
#include "config.h"
#include "search-entry.h"
#include "search-context-picker.h"
#include "nld-marshal.h"
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
typedef struct
{

View file

@ -24,8 +24,6 @@
#include "app-resizer.h"
static GtkWindowClass *parent_class = NULL;
static void shell_window_class_init (ShellWindowClass *);
static void shell_window_init (ShellWindow *);
static void shell_window_destroy (GtkObject *);
@ -36,38 +34,11 @@ gboolean shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event,
#define SHELL_WINDOW_BORDER_WIDTH 6
GType
shell_window_get_type (void)
{
static GType object_type = 0;
if (!object_type)
{
static const GTypeInfo object_info = {
sizeof (ShellWindowClass),
NULL,
NULL,
(GClassInitFunc) shell_window_class_init,
NULL,
NULL,
sizeof (ShellWindow),
0,
(GInstanceInitFunc) shell_window_init
};
object_type = g_type_register_static (
GTK_TYPE_FRAME, "ShellWindow", &object_info, 0);
}
return object_type;
}
G_DEFINE_TYPE (ShellWindow, shell_window, GTK_TYPE_FRAME);
static void
shell_window_class_init (ShellWindowClass * klass)
{
parent_class = g_type_class_peek_parent (klass);
((GtkObjectClass *) klass)->destroy = shell_window_destroy;
}
static void
@ -98,11 +69,6 @@ shell_window_new (AppShellData * app_data)
return GTK_WIDGET (window);
}
static void
shell_window_destroy (GtkObject * obj)
{
}
void
shell_window_clear_resize_handler (ShellWindow * win)
{

View file

@ -24,7 +24,8 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <libgnome/gnome-desktop-item.h>
#include "app-shell.h"
#include <libslab/app-shell.h>
G_BEGIN_DECLS

View file

@ -19,6 +19,7 @@
*/
#include "slab-gnome-util.h"
#include "libslab-utils.h"
#include <gconf/gconf-client.h>
#include <gio/gio.h>
@ -275,10 +276,7 @@ open_desktop_item_help (GnomeDesktopItem * desktop_item)
help_uri = g_strdup_printf ("ghelp:%s", doc_path);
error = NULL;
gtk_show_uri (NULL, help_uri, gtk_get_current_event_time (), &error);
if (error)
if (!gtk_show_uri (libslab_get_current_screen (), help_uri, gtk_get_current_event_time (), &error))
{
g_warning ("error opening %s [%s]\n", help_uri, error->message);

View file

@ -20,8 +20,6 @@
#include "slab-section.h"
#include <gtk/gtk.h>
G_DEFINE_TYPE (SlabSection, slab_section, GTK_TYPE_VBOX)
static void slab_section_finalize (GObject *);

45
libslab/slab.h Normal file
View file

@ -0,0 +1,45 @@
/*
* 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 __SLAB_H__
#define __SLAB_H__
#include <libslab/app-resizer.h>
#include <libslab/app-shell.h>
#include <libslab/application-tile.h>
#include <libslab/bookmark-agent.h>
#include <libslab/directory-tile.h>
#include <libslab/document-tile.h>
#include <libslab/double-click-detector.h>
#include <libslab/gnome-utils.h>
#include <libslab/libslab-utils.h>
#include <libslab/nameplate-tile.h>
#include <libslab/search-bar.h>
#include <libslab/search-context-picker.h>
#include <libslab/search-entry.h>
#include <libslab/shell-window.h>
#include <libslab/slab-gnome-util.h>
#include <libslab/slab-section.h>
#include <libslab/system-tile.h>
#include <libslab/tile.h>
#endif /* __SLAB_H__ */

View file

@ -19,10 +19,10 @@
*/
#include "system-tile.h"
#include "config.h"
#include <string.h>
#include <glib/gi18n.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
#include "bookmark-agent.h"

View file

@ -21,7 +21,7 @@
#ifndef __SYSTEM_TILE_H__
#define __SYSTEM_TILE_H__
#include "nameplate-tile.h"
#include <libslab/nameplate-tile.h>
#include <libgnome/gnome-desktop-item.h>