Commit ea6b6d31 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

use GType for types

Fri Sep 21 01:40:50 2001  George Lebl <jirka@5z.com>

	* *.[ch]: use GType for types

	* extern.c, gnome-run.c, launcher.[ch]: do more ditem porting
parent 1e3749d3
Fri Sep 21 01:40:50 2001 George Lebl <jirka@5z.com>
* *.[ch]: use GType for types
* extern.c, gnome-run.c, launcher.[ch]: do more ditem porting
Thu Sep 20 15:17:33 2001 George Lebl <jirka@5z.com>
* launcher.c, swallow.c: Do some DesktopItem porting, remove some
......
......@@ -29,10 +29,10 @@ static void aligned_pos_show_hide_left (BasePWidget *basep);
static void aligned_pos_show_hide_right (BasePWidget *basep);
static BorderPosClass *parent_class;
GtkType
GType
aligned_pos_get_type (void)
{
static GtkType aligned_pos_type = 0;
static GType aligned_pos_type = 0;
if (aligned_pos_type == 0) {
GtkTypeInfo aligned_pos_info = {
......
......@@ -51,7 +51,7 @@ struct _AlignedPosClass {
AlignedAlignment align);
};
GtkType aligned_pos_get_type (void) G_GNUC_CONST;
GType aligned_pos_get_type (void) G_GNUC_CONST;
GtkWidget *aligned_widget_new (int screen,
AlignedAlignment aligned,
BorderEdge edge,
......
......@@ -184,10 +184,10 @@ static GtkTooltips *applet_tooltips = NULL;
#define CD(applet) ((CustomAppletServant *)APPLET_WIDGET(applet)->_priv->corbadat)
guint
GType
applet_widget_get_type (void)
{
static guint applet_widget_type = 0;
static GType applet_widget_type = 0;
if (!applet_widget_type) {
static const GtkTypeInfo applet_widget_info = {
......
......@@ -124,7 +124,7 @@ typedef GtkWidget *(*AppletFactoryActivator)(const char *goad_id, const char **p
/* Returns TRUE if the factory can activate this applet */
typedef gboolean (*AppletFactoryQuerier)(const char *goad_id);
guint applet_widget_get_type (void) G_GNUC_CONST;
GType applet_widget_get_type (void) G_GNUC_CONST;
void applet_factory_new(const char *goad_id,
AppletFactoryQuerier qfunc,
......
......@@ -117,31 +117,34 @@ applet_callback_callback(GtkWidget *widget, gpointer data)
break;
}
case APPLET_LAUNCHER:
if(strcmp(menu->name,"properties")==0)
launcher_properties(menu->info->data);
else if (strcmp (menu->name, "help") == 0)
if (strcmp (menu->name, "properties") == 0) {
launcher_properties (menu->info->data);
} else if (strcmp (menu->name, "help") == 0) {
panel_show_help ("launchers.html");
else if (strcmp (menu->name, "help_on_app") == 0) {
#ifdef FIXME
} else if (strcmp (menu->name, "help_on_app") == 0) {
Launcher * launcher = menu->info->data;
if (launcher->ditem != NULL) {
char *path = panel_gnome_kde_help_path
(launcher->ditem->docpath);
const char *docpath =
gnome_desktop_item_get_string
(launcher->ditem, "DocPath");
char *path =
panel_gnome_kde_help_path (docpath);
if (path != NULL) {
gnome_url_show (path);
gnome_url_show (path, NULL);
/* FIXME: handle errors */
g_free (path);
}
}
#endif
}
break;
case APPLET_DRAWER:
if(strcmp(menu->name,"properties")==0) {
if (strcmp (menu->name, "properties")==0) {
Drawer *drawer = menu->info->data;
g_assert(drawer);
panel_config(drawer->drawer);
} else if (strcmp (menu->name, "help") == 0)
} else if (strcmp (menu->name, "help") == 0) {
panel_show_help ("drawers.html");
}
break;
case APPLET_SWALLOW:
if (strcmp (menu->name, "help") == 0)
......
......@@ -64,10 +64,10 @@ static GtkObjectClass *basep_pos_parent_class = NULL;
widget core
************************/
GtkType
GType
basep_widget_get_type (void)
{
static GtkType basep_widget_type = 0;
static GType basep_widget_type = 0;
if (!basep_widget_type) {
GtkTypeInfo basep_widget_info = {
......@@ -399,10 +399,10 @@ basep_widget_class_init (BasePWidgetClass *klass)
}
/* pos core */
GtkType
GType
basep_pos_get_type (void)
{
static GtkType basep_pos_type = 0;
static GType basep_pos_type = 0;
if (!basep_pos_type) {
GtkTypeInfo basep_pos_info = {
......
......@@ -178,8 +178,8 @@ struct _BasePPosClass {
void (*pre_convert_hook) (BasePWidget *basep);
};
GtkType basep_pos_get_type (void) G_GNUC_CONST;
GtkType basep_widget_get_type (void) G_GNUC_CONST;
GType basep_pos_get_type (void) G_GNUC_CONST;
GType basep_widget_get_type (void) G_GNUC_CONST;
GtkWidget* basep_widget_construct (BasePWidget *basep,
gboolean packed,
gboolean reverse_arrows,
......
......@@ -36,10 +36,10 @@ static void border_pos_pre_convert_hook (BasePWidget *basep);
static BasePPosClass *parent_class;
GtkType
GType
border_pos_get_type (void)
{
static GtkType border_pos_type = 0;
static GType border_pos_type = 0;
if (!border_pos_type) {
GtkTypeInfo border_pos_info = {
......
......@@ -51,7 +51,7 @@ struct _BorderPosClass {
#endif
};
GtkType border_pos_get_type (void) G_GNUC_CONST;
GType border_pos_get_type (void) G_GNUC_CONST;
GtkWidget *border_widget_construct (BorderWidget *border,
int screen,
BorderEdge edge,
......
......@@ -61,10 +61,10 @@ static gboolean always_text[LAST_TILE] = {FALSE,FALSE,FALSE,FALSE}; /*text alway
static GtkWidgetClass *parent_class;
guint
GType
button_widget_get_type (void)
{
static guint button_widget_type = 0;
static GType button_widget_type = 0;
if (!button_widget_type) {
GtkTypeInfo button_widget_info = {
......
......@@ -64,7 +64,7 @@ struct _ButtonWidgetClass
void (* unpressed) (ButtonWidget *button);
};
guint button_widget_get_type (void) G_GNUC_CONST;
GType button_widget_get_type (void) G_GNUC_CONST;
GtkWidget* button_widget_new (const char *pixmap,
int size,
......
......@@ -49,10 +49,10 @@ static void drawer_pos_pre_convert_hook (BasePWidget *basep);
static BasePPosClass *parent_class;
GtkType
GType
drawer_pos_get_type (void)
{
static GtkType drawer_pos_type = 0;
static GType drawer_pos_type = 0;
if (drawer_pos_type == 0) {
GtkTypeInfo drawer_pos_info = {
......
......@@ -49,7 +49,7 @@ struct _DrawerPosClass {
#endif
};
GtkType drawer_pos_get_type (void) G_GNUC_CONST;
GType drawer_pos_get_type (void) G_GNUC_CONST;
GtkWidget *drawer_widget_new (PanelOrientType orient,
BasePMode mode,
BasePState state,
......
......@@ -32,10 +32,10 @@ static void edge_pos_pre_convert_hook (BasePWidget *basep);
static BorderPosClass *parent_class;
GtkType
edge_pos_get_type ()
GType
edge_pos_get_type (void)
{
static GtkType edge_pos_type = 0;
static GType edge_pos_type = 0;
if (edge_pos_type == 0) {
GtkTypeInfo edge_pos_info = {
......
......@@ -44,7 +44,7 @@ struct _EdgePosClass {
BorderPosClass parent_class;
};
GtkType edge_pos_get_type (void) G_GNUC_CONST;
GType edge_pos_get_type (void) G_GNUC_CONST;
GtkWidget *edge_widget_new (int screen,
BorderEdge edge,
BasePMode mode,
......
......@@ -1239,9 +1239,7 @@ s_panel_add_launcher_from_info (PortableServer_Servant _servant,
if (panel_widget == NULL)
panel_widget = panels->data;
/* ugly but works because of the way this actually works */
exec_argv[0] = (char *)exec;
load_launcher_applet_from_info (name, comment, exec_argv, 1,
load_launcher_applet_from_info (name, comment, exec,
icon, panel_widget, pos, FALSE);
}
......
......@@ -57,10 +57,10 @@ static void floating_pos_show_hide_right (BasePWidget *basep);
static BasePPosClass *parent_class;
GtkType
GType
floating_pos_get_type (void)
{
static GtkType floating_pos_type = 0;
static GType floating_pos_type = 0;
if (floating_pos_type == 0) {
GtkTypeInfo floating_pos_info = {
......
......@@ -44,7 +44,7 @@ struct _FloatingPosClass {
gint x, gint y);
};
GtkType floating_pos_get_type (void) G_GNUC_CONST;
GType floating_pos_get_type (void) G_GNUC_CONST;
GtkWidget *floating_widget_new (int screen,
gint16 x,
gint16 y,
......
......@@ -61,10 +61,10 @@ static GtkWindowClass *parent_class = NULL;
GtkType
GType
foobar_widget_get_type (void)
{
static GtkType foobar_widget_type = 0;
static GType foobar_widget_type = 0;
if (!foobar_widget_type) {
GtkTypeInfo foobar_widget_info = {
......
......@@ -61,7 +61,7 @@ struct _FoobarWidgetClass
GtkWindowClass panel_class;
};
GtkType foobar_widget_get_type (void) G_GNUC_CONST;
GType foobar_widget_get_type (void) G_GNUC_CONST;
GtkWidget * foobar_widget_new (int screen);
void foobar_widget_update_winhints (FoobarWidget *foo);
......
......@@ -217,24 +217,38 @@ string_callback (GtkWidget *w, int button_num, gpointer data)
name = gtk_clist_get_row_data (GTK_CLIST (clist),
GPOINTER_TO_INT (GTK_CLIST (clist)->selection->data));
if (name) {
#if FIXME
GnomeDesktopEntry *dentry;
if (name != NULL) {
GError *error = NULL;
GnomeDesktopItem *ditem;
dentry = gnome_desktop_entry_load (name);
if (dentry && dentry->exec) {
ditem = gnome_desktop_item_new_from_file (name,
0 /* flags */,
&error);
if (ditem != NULL) {
/* Honor "run in terminal" button */
dentry->terminal = terminal->active;
gnome_desktop_entry_launch (dentry);
gnome_desktop_entry_free (dentry);
gnome_desktop_item_set_boolean (ditem,
GNOME_DESKTOP_ITEM_TERMINAL,
terminal->active);
}
if (ditem == NULL) {
panel_error_dialog ("failed_to_load_desktop",
_("Failed to load this program!\n%s"),
error->message);
g_error_clear (&error);
} else if ( ! gnome_desktop_item_launch (name, 0, NULL,
&error)) {
panel_error_dialog ("failed_to_load_desktop",
_("Failed to load this program!\n%s"),
error->message);
g_error_clear (&error);
}
if (ditem != NULL) {
if (add_to_favourites)
panel_add_favourite (name);
} else {
panel_error_dialog (_("Failed to load this program!\n"));
}
#endif
gnome_desktop_item_unref (ditem);
}
}
} else {
entry = GTK_ENTRY (gtk_object_get_data(GTK_OBJECT(w), "entry"));
......@@ -478,25 +492,32 @@ sync_list_to_entry (GtkWidget *dialog)
name = gtk_clist_get_row_data (GTK_CLIST (clist),
GPOINTER_TO_INT (GTK_CLIST (clist)->selection->data));
if (name) {
#if FIXME
GnomeDesktopEntry *dentry;
dentry = gnome_desktop_entry_load (name);
if (dentry && dentry->exec) {
char *command;
GnomeDesktopItem *ditem;
ditem = gnome_desktop_item_new_from_file (name,
0 /* flags */,
NULL /* error */);
if (ditem != NULL) {
gboolean terminal;
const char *exec;
exec = gnome_desktop_item_get_string
(ditem, GNOME_DESKTOP_ITEM_EXEC);
if (exec == NULL)
exec = gnome_desktop_item_get_string
(ditem, GNOME_DESKTOP_ITEM_URL);
terminal = gnome_desktop_item_get_boolean
(ditem, GNOME_DESKTOP_ITEM_TERMINAL);
command = g_strjoinv (" ", dentry->exec);
gtk_entry_set_text (GTK_ENTRY (entry),
command);
sure_string (exec));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (terminal_toggle),
dentry->terminal);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (terminal_toggle),
terminal);
gnome_desktop_entry_free (dentry);
g_free (command);
gnome_desktop_item_unref (ditem);
}
#endif
}
}
......@@ -919,34 +940,38 @@ select_row_handler (GtkCList *clist,
row);
if (name) {
#if FIXME
GnomeDesktopEntry *dentry;
GnomeDesktopItem *ditem;
dentry = gnome_desktop_entry_load (name);
if (dentry != NULL) {
ditem = gnome_desktop_item_new_from_file (name,
0 /* flags */,
NULL /* error */);
if (ditem != NULL) {
GdkPixbuf *pixbuf;
const char *name;
const char *comment;
char *icon;
name = gnome_desktop_item_get_string
(ditem, GNOME_DESKTOP_ITEM_NAME);
comment = gnome_desktop_item_get_string
(ditem, GNOME_DESKTOP_ITEM_COMMENT);
if (label != NULL)
gtk_label_set_text (GTK_LABEL (label),
dentry->name);
name);
if (desc_label != NULL)
gtk_label_set_text (GTK_LABEL (desc_label),
dentry->comment);
if (dentry->icon != NULL) {
pixbuf = gdk_pixbuf_new_from_file (dentry->icon);
if (pixbuf == NULL) {
char *file = gnome_pixmap_file (dentry->icon);
if (file != NULL)
pixbuf = gdk_pixbuf_new_from_file (file);
g_free (file);
}
sure_string (comment));
icon = gnome_desktop_item_get_icon (ditem);
if (icon != NULL) {
pixbuf = gdk_pixbuf_new_from_file (icon, NULL);
} else {
pixbuf = NULL;
}
if (pixbuf) {
if (pixbuf != NULL) {
GdkPixmap *pixmap;
GdkBitmap *mask;
......@@ -964,9 +989,8 @@ select_row_handler (GtkCList *clist,
unset_pixmap (gpixmap);
}
gnome_desktop_entry_free (dentry);
gnome_desktop_item_unref (ditem);
}
#endif
}
sync_list_to_entry (dialog);
......
/*
* This is an utter hack
*
* Copyright (C) 2001 Eazel, Inc.
*
* Author: George Lebl <jirka@5z.com>
*/
#include "config.h"
#include "icon-entry-hack.h"
static GtkWidget *
find_iconsel (GtkWidget *box)
{
GList *list, *li;
list = gtk_container_children (GTK_CONTAINER (box));
for (li = list; li != NULL; li = li->next) {
GtkWidget *w = li->data;
if (GNOME_IS_ICON_SELECTION (w)) {
g_list_free (list);
return w;
}
}
g_list_free (list);
return NULL;
}
static void
sync_new_to_orig (GnomeIconEntry *ientry)
{
char *file;
GnomeIconEntry *origientry;
GtkWidget *entry;
origientry = gtk_object_get_data (GTK_OBJECT (ientry),
"IconHackOrigIconEntry");
file = gnome_icon_entry_get_filename (ientry);
if (origientry != NULL) {
gtk_object_set_data (GTK_OBJECT (origientry), "IconHackNoSync",
GINT_TO_POINTER (1));
gnome_icon_entry_set_icon (origientry, file);
entry = gnome_icon_entry_gtk_entry
(GNOME_ICON_ENTRY (origientry));
gtk_signal_emit_by_name (GTK_OBJECT (entry), "changed");
gtk_object_remove_data (GTK_OBJECT (origientry), "IconHackNoSync");
} else {
if (file != NULL)
gtk_object_set_data_full (GTK_OBJECT (ientry),
"IconHackText",
g_strdup (file),
(GtkDestroyNotify) g_free);
else
gtk_object_remove_data (GTK_OBJECT (ientry),
"IconHackText");
entry = gnome_icon_entry_gtk_entry (GNOME_ICON_ENTRY (ientry));
gtk_signal_emit_by_name (GTK_OBJECT (entry), "changed");
}
g_free (file);
}
static void
sync_orig_to_new (GnomeIconEntry *ientry)
{
char *file;
GnomeIconEntry *origientry;
origientry = gtk_object_get_data (GTK_OBJECT (ientry),
"IconHackOrigIconEntry");
if (origientry != NULL) {
file = gnome_icon_entry_get_filename (origientry);
} else {
file = g_strdup (gtk_object_get_data
(GTK_OBJECT (ientry), "IconHackText"));
}
gnome_icon_entry_set_icon (ientry, file);
g_free (file);
}
static void
idle_remove (gpointer data)
{
guint idle = GPOINTER_TO_UINT (data);
gtk_idle_remove (idle);
}
static gboolean
sync_orig_to_new_idle (gpointer data)
{
sync_orig_to_new (data);
gtk_object_remove_data (GTK_OBJECT (data), "IconHackToNewIdle");
return FALSE;
}
static void
add_sync_orig_to_new_idle_for_entry (GnomeIconEntry *ientry)
{
guint idle = GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (ientry),
"IconHackToNewIdle"));
if (idle != 0)
return;
idle = gtk_idle_add (sync_orig_to_new_idle, ientry);
gtk_object_set_data_full (GTK_OBJECT (ientry), "IconHackToNewIdle",
GUINT_TO_POINTER (idle),
(GtkDestroyNotify) idle_remove);
}
static gboolean
sync_new_to_orig_idle (gpointer data)
{
sync_new_to_orig (data);
gtk_object_remove_data (GTK_OBJECT (data), "IconHackToOrigIdle");
return FALSE;
}
static void
add_sync_new_to_orig_idle_for_entry (GnomeIconEntry *ientry)
{
guint idle = GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (ientry),
"IconHackToOrigIdle"));
if (idle != 0)
return;
idle = gtk_idle_add (sync_new_to_orig_idle, ientry);
gtk_object_set_data_full (GTK_OBJECT (ientry), "IconHackToOrigIdle",
GUINT_TO_POINTER (idle),
(GtkDestroyNotify) idle_remove);
}
static void
icon_selected (GtkWidget *w, gint num, GdkEvent *event, gpointer data)
{
if(event &&
event->type == GDK_2BUTTON_PRESS &&
((GdkEventButton *)event)->button == 1) {
sync_new_to_orig (data);
}
}
static gboolean
delete_event (GtkWidget *w, GdkEvent *event, gpointer data)
{
GnomeIconEntry *ientry = data;
gtk_object_set_data (GTK_OBJECT (ientry->pick_dialog),
"IconEntryHackCanceled",
GINT_TO_POINTER (1));
sync_orig_to_new (ientry);
return FALSE;
}
static void
cancel (GtkWidget *w, gpointer data)
{
GnomeIconEntry *ientry = data;
gtk_object_set_data (GTK_OBJECT (ientry->pick_dialog),
"IconEntryHackCanceled",
GINT_TO_POINTER (1));
sync_orig_to_new (ientry);
}
static void
dialog_hide (GtkWidget *w, gpointer data)
{
GnomeIconEntry *ientry = data;
if (gtk_object_get_data (GTK_OBJECT (ientry->pick_dialog),
"IconEntryHackCanceled") == NULL) {
sync_new_to_orig (ientry);
}
}
static void
shown_icon_selection (GtkWidget *w, gpointer data)
{
GnomeIconEntry *ientry = data;
if (ientry->pick_dialog == NULL)
return;
gtk_object_remove_data (GTK_OBJECT (ientry->pick_dialog),
"IconEntryHackCanceled");
if ( ! gtk_object_get_data
(GTK_OBJECT (ientry->pick_dialog), "IconHackDidConnect")) {
GtkWidget *iconsel;
gnome_dialog_button_connect_object
(GNOME_DIALOG (ientry->pick_dialog),
0, /* OK button */
GTK_SIGNAL_FUNC (sync_new_to_orig),
GTK_OBJECT (ientry));
gnome_dialog_button_connect
(GNOME_DIALOG (ientry->pick_dialog),
1, /* Cancel button */
GTK_SIGNAL_FUNC (cancel),
ientry);
iconsel = find_iconsel
(GNOME_DIALOG (ientry->pick_dialog)->vbox);
g_assert (iconsel != NULL);
gtk_signal_connect_after
(GTK_OBJECT (GNOME_ICON_SELECTION (iconsel)->gil),
"select_icon",
GTK_SIGNAL_FUNC (icon_selected),
ientry);
gtk_signal_connect (GTK_OBJECT (ientry->pick_dialog),
"hide",
GTK_SIGNAL_FUNC (dialog_hide),
ientry);
gtk_signal_connect (GTK_OBJECT (ientry->pick_dialog),
"delete_event",
GTK_SIGNAL_FUNC (delete_event),
ientry);
gtk_object_set_data (GTK_OBJECT (ientry->pick_dialog),
"IconHackDidConnect",
GINT_TO_POINTER (1));
}
}
static void
orig_entry_changed (GtkWidget *w, gpointer data)
{
GnomeIconEntry *ientry = data;
GnomeIconEntry *origientry;
origientry = gtk_object_get_data (GTK_OBJECT (ientry),
"IconHackOrigIconEntry");
if ( ! gtk_object_get_data (GTK_OBJECT (origientry), "IconHackNoSync")) {
add_sync_orig_to_new_idle_for_entry (ientry);
}
}
void
hack_dentry_edit (GnomeDEntryEdit *dedit)
{
GtkWidget *ientry;
GtkWidget *parent;
GtkWidget *entry;
g_return_if_fail (GNOME_IS_DENTRY_EDIT (dedit));
ientry = gnome_icon_entry_new ("icon", _