Commit 016adb30 authored by Scott Reeves's avatar Scott Reeves

sync from internal svn, clean up formatting issues, fix memory leaks, update po files

parent 7f5bcd7b
2006-09-15 Scott Reeves <sreeves@novell.com>
* *.c, *.h:
clean up formatting issues
fix memory leaks, initial performance work
update po files.
sync from internal svn
2006-09-13 David Lodge <dave@cirt.net>
* configure.in: Added "en_GB" to ALL_LINGUAS.
......
......@@ -8,11 +8,7 @@ INCLUDES = \
bin_PROGRAMS = application-browser
application_browser_SOURCES = \
app-layout.c \
app-layout.h \
application-browser.c \
app-window.c \
app-window.h
application-browser.c
application_browser_LDADD = \
$(APPLICATION_BROWSER_LIBS) \
......
/*
* This file is part of the Control Center.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Control Center is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Control Center 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Control Center; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* This file is part of the Main Menu.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Main Menu is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Main Menu 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Main Menu; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <gtk/gtk.h>
#include "app-layout.h"
static gint aval_table_width = -1;
gint
calculate_launcher_width ()
{
/* FIXME - right now we hard code the width, do we want to
dynamically determine the optimal size */
return 230;
}
void
OLD_remove_container_entries (GtkContainer * widget)
{
GList *children = gtk_container_get_children (widget);
if (children == NULL)
return;
do {
GtkWidget *child = GTK_WIDGET (children->data);
GtkWidget *parent =
gtk_widget_get_parent (GTK_WIDGET (child));
if (parent) {
gtk_container_remove (GTK_CONTAINER (parent),
GTK_WIDGET (child));
}
}
while (NULL != (children = g_list_next (children)));
}
void
set_available_table_width (gint width)
{
aval_table_width = width;
}
gint
get_available_table_width ()
{
/* Make sure we set this before we call to get it */
if (aval_table_width == -1)
g_assert_not_reached ();
return aval_table_width;
}
void
OLD_resize_table (GtkTable * table, GList * launcher_list)
{
static gboolean initial_setup = TRUE;
OLD_remove_container_entries (GTK_CONTAINER (table));
gint launcher_width = calculate_launcher_width ();
gint table_width = -1;
if (initial_setup) { /* should only be true when called before the
window is shown - ie initial setup */
initial_setup = FALSE;
set_available_table_width (launcher_width * INITIAL_NUM_COLS);
printf ("TABLE WIDTH NOT SET YET\n");
}
table_width = get_available_table_width ();
gint columns = table_width / launcher_width;
if (columns < 1) {
printf ("resize_table() - columns less than 1\n");
columns = 1;
}
float rows =
((float) g_list_length (launcher_list)) / (float) columns;
float remainder = rows - ((int) rows);
if (remainder != 0.0)
rows += 1;
gtk_table_resize (table, (int) rows, columns);
}
/*
* This file is part of the Control Center.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Control Center is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Control Center 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Control Center; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* This file is part of the Main Menu.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Main Menu is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Main Menu 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Main Menu; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __APPBROWSER_LAYOUT_H__
#define __APPBROWSER_LAYOUT_H__
#include <glib.h>
#include <gtk/gtktable.h>
G_BEGIN_DECLS
#define INITIAL_NUM_COLS 3
void OLD_remove_container_entries (GtkContainer * widget);
void OLD_resize_table (GtkTable * table, GList * launcher_list);
gint calculate_launcher_width (void);
void set_available_table_width (gint width);
gint get_available_table_width (void);
G_END_DECLS
#endif /* __APPBROWSER_LAYOUT_H__ */
/*
* This file is part of the Control Center.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Control Center is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Control Center 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Control Center; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* This file is part of the Main Menu.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Main Menu is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Main Menu 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Main Menu; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "app-window.h"
#include <gtk/gtkhbox.h>
#include <gtk/gtkalignment.h>
#include <gtk/gtkbin.h>
#include <gtk/gtkframe.h>
#include <gtk/gtklayout.h>
#include <gtk/gtkscrolledwindow.h>
#include "app-layout.h"
static GtkWindowClass *parent_class = NULL;
static void slab_window_class_init (SlabWindowClass *);
static void slab_window_init (SlabWindow *);
static void slab_window_destroy (GtkObject *);
gboolean paint_window (GtkWidget * widget, GdkEventExpose * event,
gpointer data);
#define SLAB_WINDOW_BORDER_WIDTH 6
GType
slab_window_get_type (void)
{
printf ("ENTER - SLAB-slab_window_get_type\n");
static GType object_type = 0;
if (!object_type) {
static const GTypeInfo object_info = {
sizeof (SlabWindowClass),
NULL,
NULL,
(GClassInitFunc) slab_window_class_init,
NULL,
NULL,
sizeof (SlabWindow),
0,
(GInstanceInitFunc) slab_window_init
};
object_type = g_type_register_static (GTK_TYPE_FRAME,
"SlabWindow",
&object_info, 0);
}
return object_type;
}
static void
slab_window_class_init (SlabWindowClass * klass)
{
printf ("AAAAAAAAAAA\n\n");
parent_class = g_type_class_peek_parent (klass);
((GtkObjectClass *) klass)->destroy = slab_window_destroy;
}
static void
slab_window_init (SlabWindow * window)
{
printf ("AAAAAAAAAAA\n\n");
window->_hbox = NULL;
window->_left_pane = NULL;
window->_right_pane = NULL;
}
GtkWidget *
slab_window_new ()
{
printf ("AAAAAAAAAAA\n\n");
SlabWindow *window = g_object_new (SLAB_WINDOW_TYPE, NULL);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
window->_hbox = GTK_BOX (gtk_hbox_new (FALSE, 0));
gtk_container_add (GTK_CONTAINER (window),
GTK_WIDGET (window->_hbox));
g_signal_connect (G_OBJECT (window),
"expose-event", G_CALLBACK (paint_window), NULL);
return GTK_WIDGET (window);
}
static void
slab_window_destroy (GtkObject * obj)
{
printf ("AAAAAAAAAAA\n\n");
}
void
slab_window_reset_contents (SlabWindow * slab, GtkWidget * left_pane,
GtkWidget * right_pane)
{
printf ("AAAAAAAAAAA\n\n");
GList *children =
gtk_container_get_children (GTK_CONTAINER (slab->_left_pane));
gtk_container_remove (GTK_CONTAINER (slab->_left_pane),
GTK_WIDGET (children->data));
children = g_list_next (children); /* should only have one child
in list */
g_assert (children == NULL);
children =
gtk_container_get_children (GTK_CONTAINER
(slab->_right_pane));
gtk_container_remove (GTK_CONTAINER (slab->_right_pane),
GTK_WIDGET (children->data));
children = g_list_next (children); /* should only have one child
in list */
g_assert (children == NULL);
gtk_container_add (GTK_CONTAINER (slab->_left_pane), left_pane);
gtk_container_add (GTK_CONTAINER (slab->_right_pane), right_pane);
}
void
slab_window_set_contents (SlabWindow * slab, GtkWidget * left_pane,
GtkWidget * right_pane)
{
printf ("AAAAAAAAAAA\n\n");
slab->_left_pane = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
slab->_right_pane = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (slab->_left_pane), 15, 15,
15, 15);
gtk_alignment_set_padding (GTK_ALIGNMENT (slab->_right_pane), 0, 0, 2,
0);
gtk_box_pack_start (slab->_hbox, slab->_left_pane, FALSE, FALSE, 0);
gtk_box_pack_start (slab->_hbox, slab->_right_pane, TRUE, TRUE, 0); /* this
one
takes
any
extra
space
*/
gtk_container_add (GTK_CONTAINER (slab->_left_pane), left_pane);
gtk_container_add (GTK_CONTAINER (slab->_right_pane), right_pane);
}
gboolean
paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer data)
{
printf ("ENTER - SLAB-paint_window\n");
GList *child;
GtkWidget *left_pane, *right_pane;
left_pane = SLAB_WINDOW (widget)->_left_pane;
right_pane = SLAB_WINDOW (widget)->_right_pane;
/* draw left pane background */
gdk_draw_rectangle (widget->window,
widget->style->bg_gc [GTK_STATE_ACTIVE],
TRUE,
left_pane->allocation.x, left_pane->allocation.y,
left_pane->allocation.width,
left_pane->allocation.height);
/* draw right pane background */
gdk_draw_rectangle (widget->window,
widget->style->bg_gc [GTK_STATE_ACTIVE],
TRUE,
right_pane->allocation.x,
right_pane->allocation.y,
right_pane->allocation.width,
right_pane->allocation.height);
/* draw pane separator */
gdk_draw_line (widget->window,
widget->style->dark_gc [GTK_STATE_NORMAL],
right_pane->allocation.x, right_pane->allocation.y,
right_pane->allocation.x,
right_pane->allocation.y +
right_pane->allocation.height - 1);
child = gtk_container_get_children (GTK_CONTAINER (widget));
for (; child; child = child->next)
gtk_container_propagate_expose (GTK_CONTAINER (widget),
GTK_WIDGET (child->data),
event);
return FALSE;
}
/*
* This file is part of the Control Center.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Control Center is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Control Center 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Control Center; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* This file is part of the Main Menu.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Main Menu is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Main Menu 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Main Menu; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __APP_WINDOW_H__
#define __APP_WINDOW_H__
#include <glib.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtkbox.h>
G_BEGIN_DECLS
#define SLAB_WINDOW_TYPE (slab_window_get_type ())
#define SLAB_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SLAB_WINDOW_TYPE, SlabWindow))
#define SLAB_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SLAB_WINDOW_TYPE, SlabWindowClass))
#define IS_SLAB_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SLAB_WINDOW_TYPE))
#define IS_SLAB_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SLAB_WINDOW_TYPE))
#define SLAB_WINDOW_GET_CLASS(obj) (G_TYPE_CHECK_GET_CLASS ((obj), SLAB_WINDOW_TYPE, SlabWindowClass))
typedef struct _SlabWindow SlabWindow;
typedef struct _SlabWindowClass SlabWindowClass;
struct _SlabWindow {
GtkWindow window;
GtkBox *_hbox;
GtkWidget *_left_pane;
GtkWidget *_right_pane;
};
struct _SlabWindowClass {
GtkWindowClass parent_class;
};
GType slab_window_get_type (void);
GtkWidget *slab_window_new (void);
void slab_window_set_contents (SlabWindow * window, GtkWidget * left_pane,
GtkWidget * right_pane);
void slab_window_reset_contents (SlabWindow * window, GtkWidget * left_pane,
GtkWidget * right_pane);
G_END_DECLS
#endif /* __APP_WINDOW_H__ */
/*
* This file is part of the Control Center.
* This file is part of the Application Browser.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Control Center is free software; you can redistribute it and/or modify it
* The Application Browser is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Control Center is distributed in the hope that it will be useful, but WITHOUT
* The Application Browser 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 General Public License for
* more details.
......@@ -18,26 +18,6 @@
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* This file is part of the Main Menu.
*
* Copyright (c) 2006 Novell, Inc.
*
* The Main Menu is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* The Main Menu 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 General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* the Main Menu; if not, write to the Free Software Foundation, Inc., 51
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <string.h>
......@@ -60,11 +40,11 @@
#include "app-shell-startup.h"
#include "slab-gnome-util.h"
#define NEW_APPS_MAX_ITEMS "/desktop/gnome/applications/main-menu/ab_new_apps_max_items"
#define APPLICATION_BROWSER_PREFIX "/desktop/gnome/applications/main-menu/ab_"
#define NEW_APPS_MAX_ITEMS (APPLICATION_BROWSER_PREFIX "new_apps_max_items")
int
main (int argc, char *argv [])
main (int argc, char *argv[])
{
BonoboApplication *bonobo_app = NULL;
gboolean hidden = FALSE;
......@@ -74,24 +54,24 @@ main (int argc, char *argv [])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
/* gnome_program_init clears the env variable that we depend on, so
call this first */
if (apss_already_running
(argc, argv, &bonobo_app, "GNOME-NLD-AppBrowser")) {
gnome_program_init ("Gnome Application Browser", "0.1",
LIBGNOMEUI_MODULE, argc, argv, NULL,
NULL);
/* gnome_program_init clears the env variable that we depend on, so call this first */
if (apss_already_running (argc, argv, &bonobo_app, "GNOME-NLD-AppBrowser"))
{
gnome_program_init ("Gnome Application Browser", "0.1", LIBGNOMEUI_MODULE, argc,
argv, NULL, NULL);
gdk_notify_startup_complete ();
bonobo_debug_shutdown ();
exit (1);
}
gnome_program_init ("Gnome Application Browser", "0.1",
LIBGNOMEUI_MODULE, argc, argv, NULL, NULL);
gnome_program_init ("Gnome Application Browser", "0.1", LIBGNOMEUI_MODULE, argc, argv, NULL,
NULL);
if (argc > 1) {
if (argc != 2 || strcmp ("-h", argv [1])) {
printf ("Usage - application-browser [-h]\n");
if (argc > 1)
{
if (argc != 2 || strcmp ("-h", argv[1]))
{
printf ("Usage - application-browser [-h]\n");
printf ("Options: -h : hide on start\n");
printf ("\tUseful if you want to autostart the application-browser singleton so it can get all it's slow loading done\n");
exit (1);
......@@ -100,23 +80,18 @@ main (int argc, char *argv [])
}
NewAppConfig *config = g_new0 (NewAppConfig, 1);
config->max_items = get_slab_gconf_int (NEW_APPS_MAX_ITEMS);
config->name = _("New Applications");
AppShellData *app_data =
appshelldata_new ("applications.menu", config,
APPLICATION_BROWSER_PREFIX,
GTK_ICON_SIZE_DND);
appshelldata_new ("applications.menu", config, APPLICATION_BROWSER_PREFIX,
GTK_ICON_SIZE_DND);
generate_categories (app_data);
layout_shell (app_data, _("Filter"), _("Groups"),
_("Application Actions"), NULL, NULL);
layout_shell (app_data, _("Filter"), _("Groups"), _("Application Actions"), NULL, NULL);
g_signal_connect (bonobo_app, "new-instance",
G_CALLBACK (apss_new_instance_cb), app_data);
create_main_window (app_data, "MyApplicationBrowser",
_("Application Browser"), "gnome-fs-client", 940,
600, hidden);
g_signal_connect (bonobo_app, "new-instance", G_CALLBACK (apss_new_instance_cb), app_data);
create_main_window (app_data, "MyApplicationBrowser", _("Application Browser"),
"gnome-fs-client", 940, 600, hidden);
if (bonobo_app)
bonobo_object_unref (bonobo_app);
......
......@@ -40,13 +40,12 @@
#include "app-shell-startup.h"
#include "slab-gnome-util.h"
void handle_static_action_clicked (Tile * tile, TileEvent * event,
gpointer data);
void handle_static_action_clicked (Tile * tile, TileEvent * event, gpointer data);
static GSList *get_actions_list ();
#define CONTROL_CENTER_ACTIONS_LIST_KEY "/desktop/gnome/applications/main-menu/cc_actions_list"
#define CONTROL_CENTER_ACTIONS_SEPARATOR ";"
#define CONTROL_CENTER_PREFIX "/desktop/gnome/applications/main-menu/cc_"
#define CONTROL_CENTER_ACTIONS_LIST_KEY (CONTROL_CENTER_PREFIX "actions_list")
#define CONTROL_CENTER_ACTIONS_SEPARATOR ";"
#define EXIT_SHELL_ON_STATIC_ACTION "exit_shell_on_static_action"
static GSList *
......@@ -57,53 +56,53 @@ get_actions_list ()
AppAction *action;
key_list = get_slab_gconf_slist (CONTROL_CENTER_ACTIONS_LIST_KEY);
if (!key_list) {
g_warning ("key not found [%s]\n",
CONTROL_CENTER_ACTIONS_LIST_KEY);
if (!key_list)
{
g_warning (_("key not found [%s]\n"), CONTROL_CENTER_ACTIONS_LIST_KEY);
return NULL;
}
for (; key_list; key_list = key_list->next) {
const gchar *entry = (const gchar *) key_list->data;
for (; key_list; key_list = key_list->next)
{
gchar *entry = (gchar *) key_list->data;
action = g_new (AppAction, 1);
gchar **temp =
g_strsplit (entry, CONTROL_CENTER_ACTIONS_SEPARATOR,
2);
action->name = g_strdup (temp [0]);
if ((action->item =
load_desktop_item_from_unknown (temp [1])) == NULL) {
g_warning
("get_actions_list() - PROBLEM - Can't load %s\n",
temp [1]);
g_strfreev (temp);