The GNOME Panel Libraries | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
It is possible to make applets which will not be separate processes, but will be loaded directly into the panel. This saves on memory, but can make the panel less stable if the applet is less stable.
Here is an example, George will comment on stuff unless I sleep:
Example 16. piCommander
#include <config.> #include <applet-widget.h> typedef struct { GtkWidget *applet; GtkWidget *fentry; GtkWidget *gentry; GtkWidget *entry; } PicoData; static void entry_activate (GtkWidget *w, PicoData *pico) { char *s; s = gtk_editable_get_chars (GTK_EDITABLE (pico->entry), 0, -1); gtk_editable_delete_text (GTK_EDITABLE (pico->entry), 0, -1); if (strlen (s) == 0) { g_free (s); return; } gnome_execute_shell (NULL, s); gnome_entry_save_history (GNOME_ENTRY (pico->gentry)); gnome_config_sync (); g_free (s); } static int applet_save_session (GtkWidget *applet, const char *privcfgpath, const char *globcfgpath, PicoData *pico) { gnome_entry_save_history (GNOME_ENTRY (pico->gentry)); gnome_config_sync (); return FALSE; } static void applet_destroy (GtkWidget *applet, PicoData *pico) { g_free (pico); } static CORBA_Object pico_begin (PortableServer_POA poa, const char *goad_id, const char **params, gpointer *impl_ptr, CORBA_Environment *ev) { PicoData *pico = g_new0 (PicoData, 1); pico->applet = applet_widget_new (goad_id); pico->fentry = gnome_file_entry_new ("pico-commander", _("Run...")); pico->gentry = gnome_file_entry_gnome_entry (GNOME_FILE_ENTRY (pico->fentry)); pico->entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (pico->fentry)); gnome_entry_set_max_saved (GNOME_ENTRY (pico->gentry), 50); gnome_entry_prepend_history (GNOME_ENTRY (pico->gentry), FALSE, ""); gtk_combo_set_use_arrows_always (GTK_COMBO (pico->gentry), TRUE); applet_widget_add (APPLET_WIDGET (pico->applet), pico->fentry); gtk_signal_connect (GTK_OBJECT (pico->entry), "activate", GTK_SIGNAL_FUNC (entry_activate), pico); gtk_signal_connect (GTK_OBJECT (pico->applet), "save_session", GTK_SIGNAL_FUNC (applet_save_session), pico); gtk_signal_connect (GTK_OBJECT (pico->applet), "destroy", GTK_SIGNAL_FUNC (applet_destroy), pico); gtk_widget_show_all (pico->applet); return applet_widget_corba_activate (APPLET_WIDGET (pico->applet), poa, goad_id, params, impl_ptr, ev); } static void pico_end (PortableServer_POA poa, const char *goad_id, gpointer impl_ptr, CORBA_Environment *ev) { applet_widget_corba_deactivate (poa, goad_id, impl_ptr, ev); } static const char *repo_id[] = { "IDL:GNOME/Applet:1.0", NULL }; static GnomePluginObject applets_list[] = { { repo_id, "pico-commander_applet", NULL, "50 line launcher", &pico_begin, &pico_end }, { NULL } }; GnomePlugin GNOME_Plugin_info = { applets_list, NULL }; |