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

Implement the Panel2 interface.

Thu Nov 02 21:27:28 2000  George Lebl <jirka@5z.com>

	* extern.c, panel.gnorba: Implement the Panel2 interface.

	* applet.c, panel-widget.c, panel.c: minor cosmetic cleanup

	* Makefile.am, gnome-panel-add-launcher.c:  Add a proggie to add
	  launchers externally.  Let's not doc this so that that many
	  people don't use it as it could become annoying, but major apps
	  may want to use it to optionally add their launcher to the panel.
	  note here, it should be OPTIONAL! in the installer, otherwise I'm
	  going to go after each and every dumbass who made it install an
	  icon without asking the user with a chainsaw.  If it becomes a
	  bother I'll stick in a confirmation dialog in these funcs.
parent 3f4a5bf3
Thu Nov 02 21:27:28 2000 George Lebl <jirka@5z.com>
* extern.c, panel.gnorba: Implement the Panel2 interface.
* applet.c, panel-widget.c, panel.c: minor cosmetic cleanup
* Makefile.am, gnome-panel-add-launcher.c: Add a proggie to add
launchers externally. Let's not doc this so that that many
people don't use it as it could become annoying, but major apps
may want to use it to optionally add their launcher to the panel.
note here, it should be OPTIONAL! in the installer, otherwise I'm
going to go after each and every dumbass who made it install an
icon without asking the user with a chainsaw. If it becomes a
bother I'll stick in a confirmation dialog in these funcs.
2000-11-02 Kjartan Maraas <kmaraas@gnome.org>
* gnome-panel-properties.desktop: Added "no" translation.
......
Thu Nov 02 21:27:28 2000 George Lebl <jirka@5z.com>
* extern.c, panel.gnorba: Implement the Panel2 interface.
* applet.c, panel-widget.c, panel.c: minor cosmetic cleanup
* Makefile.am, gnome-panel-add-launcher.c: Add a proggie to add
launchers externally. Let's not doc this so that that many
people don't use it as it could become annoying, but major apps
may want to use it to optionally add their launcher to the panel.
note here, it should be OPTIONAL! in the installer, otherwise I'm
going to go after each and every dumbass who made it install an
icon without asking the user with a chainsaw. If it becomes a
bother I'll stick in a confirmation dialog in these funcs.
2000-11-02 Kjartan Maraas <kmaraas@gnome.org>
* gnome-panel-properties.desktop: Added "no" translation.
......
......@@ -19,7 +19,11 @@ INCLUDES = -I. -I$(srcdir) \
gwmh_dir = $(top_srcdir)/applets/desk-guide
bin_PROGRAMS = panel gnome-panel-properties-capplet
bin_PROGRAMS = \
panel \
gnome-panel-properties-capplet \
gnome-panel-add-launcher
noinst_PROGRAMS = bad-applet
libpanel_appletincludedir = $(includedir)
......@@ -27,7 +31,11 @@ libpanel_statusincludedir = $(includedir)
lib_LTLIBRARIES = libpanel_applet.la libpanel_status.la
CORBA_SRCLIST = gnome-panel-stubs.c gnome-panel-skels.c gnome-panel-common.c gnome-panel.h
CORBA_SRCLIST = \
gnome-panel-stubs.c \
gnome-panel-skels.c \
gnome-panel-common.c \
gnome-panel.h
# try to make these get cleaned properly
CLEANFILES += $(CORBA_SRCLIST) my_gnome_panel_idl
......@@ -65,9 +73,11 @@ libpanel_status_la_LIBADD = $(ORB_LIBS) -lm $(DL_LIB)
bad_applet_SOURCES = bad-applet.c
bad_applet_LDADD = libpanel_applet.la \
bad_applet_LDADD = \
libpanel_applet.la \
$(GNOME_LIBDIR) \
$(GNORBA_LIBS) $(INTLLIBS)
$(GNORBA_LIBS) \
$(INTLLIBS)
GWMH_SRCLIST = \
gwmh.c \
......@@ -168,8 +178,14 @@ panel_SOURCES=\
scroll-menu.h \
scroll-menu.c
panel_LDADD = libpanel_applet.la $(GNOME_LIBDIR) $(GNORBA_LIBS) $(ORB_LIBS) \
$(GNOMEUI_LIBS) $(INTLLIBS) @PIXBUF_LIBS@
panel_LDADD = \
libpanel_applet.la \
$(GNOME_LIBDIR) \
$(GNORBA_LIBS) \
$(ORB_LIBS) \
$(GNOMEUI_LIBS) \
$(INTLLIBS) \
@PIXBUF_LIBS@
panel_LDFLAGS=-export-dynamic
......@@ -181,7 +197,20 @@ gnome_panel_properties_capplet_SOURCES = \
gnome_panel_properties_capplet_LDADD = \
$(GNOME_LIBDIR) \
$(GNOME_CAPPLET_LIBS) \
$(INTLLIBS) @PIXBUF_LIBS@
$(INTLLIBS) \
@PIXBUF_LIBS@
gnome_panel_add_launcher_SOURCES = \
gnome-panel-add-launcher.c \
$(CORBA_SRCLIST)
gnome_panel_add_launcher_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(GNORBA_LIBS) \
$(ORB_LIBS) \
$(INTLLIBS) \
@PIXBUF_LIBS@
data_DATA = panelrc
......
......@@ -645,28 +645,28 @@ applet_destroy(GtkWidget *w, AppletInfo *info)
}
gboolean
register_toy(GtkWidget *applet,
gpointer data,
GDestroyNotify data_destroy,
PanelWidget *panel,
int pos,
gboolean exactpos,
AppletType type)
register_toy (GtkWidget *applet,
gpointer data,
GDestroyNotify data_destroy,
PanelWidget *panel,
int pos,
gboolean exactpos,
AppletType type)
{
AppletInfo *info;
int newpos;
gboolean insert_at_pos;
g_return_val_if_fail(applet != NULL, FALSE);
g_return_val_if_fail(panel != NULL, FALSE);
g_return_val_if_fail (applet != NULL, FALSE);
g_return_val_if_fail (panel != NULL, FALSE);
if(!GTK_WIDGET_NO_WINDOW(applet))
gtk_widget_set_events(applet, (gtk_widget_get_events(applet) |
APPLET_EVENT_MASK) &
~( GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK));
if ( ! GTK_WIDGET_NO_WINDOW (applet))
gtk_widget_set_events (applet, (gtk_widget_get_events (applet) |
APPLET_EVENT_MASK) &
~( GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK));
info = g_new0(AppletInfo,1);
info = g_new0 (AppletInfo, 1);
info->applet_id = applet_count;
info->type = type;
info->widget = applet;
......@@ -676,34 +676,25 @@ register_toy(GtkWidget *applet,
info->data_destroy = data_destroy;
info->user_menu = NULL;
/* Since we will be taking care of refcounting by ourselves,
* sink the object.
*/
gtk_object_set_data (GTK_OBJECT (applet), "applet_info", info);
/*
gtk_widget_ref (info->widget);
gtk_object_sink (GTK_OBJECT (info->widget));
*/
gtk_object_set_data(GTK_OBJECT(applet),"applet_info",info);
if(type == APPLET_DRAWER) {
if (type == APPLET_DRAWER) {
Drawer *drawer = data;
PanelWidget *assoc_panel =
PANEL_WIDGET(BASEP_WIDGET(drawer->drawer)->panel);
PANEL_WIDGET (BASEP_WIDGET (drawer->drawer)->panel);
gtk_object_set_data(GTK_OBJECT(applet),
PANEL_APPLET_ASSOC_PANEL_KEY, assoc_panel);
gtk_object_set_data (GTK_OBJECT (applet),
PANEL_APPLET_ASSOC_PANEL_KEY, assoc_panel);
assoc_panel->master_widget = applet;
}
gtk_object_set_data(GTK_OBJECT(applet),
PANEL_APPLET_FORBIDDEN_PANELS, NULL);
gtk_object_set_data (GTK_OBJECT (applet),
PANEL_APPLET_FORBIDDEN_PANELS, NULL);
if (applets == NULL) {
applets_last = applets = g_slist_append(NULL, info);
applets_last = applets = g_slist_append (NULL, info);
} else {
applets_last = g_slist_append(applets_last, info);
applets_last = g_slist_append (applets_last, info);
applets_last = applets_last->next;
}
applet_count++;
......@@ -720,15 +711,15 @@ register_toy(GtkWidget *applet,
insert_at_pos = TRUE;
}
/* if exact pos is on then insert at that precise location */
if(exactpos)
if (exactpos)
insert_at_pos = TRUE;
if(panel_widget_add_full(panel, applet, newpos, TRUE,
insert_at_pos)==-1) {
if (panel_widget_add_full (panel, applet, newpos, TRUE,
insert_at_pos)==-1) {
GSList *list;
for(list = panels; list != NULL; list = g_slist_next(list))
if(panel_widget_add_full(panel, applet, 0,
TRUE, TRUE)!=-1)
if (panel_widget_add_full (panel, applet, 0,
TRUE, TRUE)!=-1)
break;
if(!list) {
/*can't put it anywhere, clean up*/
......
......@@ -15,6 +15,7 @@
#include "panel-include.h"
#include "gnome-panel.h"
#include "gnome-run.h"
#define APPLET_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
......@@ -90,6 +91,41 @@ s_panel_notice_config_changes(PortableServer_Servant servant,
CORBA_Environment *ev);
/** Panel2 additions **/
void s_panel_suggest_sync (PortableServer_Servant _servant,
CORBA_Environment * ev);
void s_panel_add_launcher (PortableServer_Servant _servant,
const CORBA_char * launcher_desktop,
const CORBA_short panel,
const CORBA_short pos,
CORBA_Environment * ev);
void s_panel_ask_about_launcher (PortableServer_Servant _servant,
const CORBA_char * exec_string,
const CORBA_short panel,
const CORBA_short pos,
CORBA_Environment * ev);
void s_panel_add_launcher_from_info (PortableServer_Servant _servant,
const CORBA_char * name,
const CORBA_char * comment,
const CORBA_char * exec,
const CORBA_char * icon,
const CORBA_short panel,
const CORBA_short pos,
CORBA_Environment * ev);
void s_panel_add_launcher_from_info_url (PortableServer_Servant _servant,
const CORBA_char * name,
const CORBA_char * comment,
const CORBA_char * url,
const CORBA_char * icon,
const CORBA_short panel,
const CORBA_short pos,
CORBA_Environment * ev);
void s_panel_run_box (PortableServer_Servant _servant,
const CORBA_char * initial_string,
CORBA_Environment * ev);
void s_panel_main_menu (PortableServer_Servant _servant,
CORBA_Environment * ev);
/*** PanelSpot stuff ***/
static CORBA_char *
......@@ -199,31 +235,41 @@ s_statusspot_remove(POA_GNOME_StatusSpot *servant,
CORBA_Environment *ev);
static PortableServer_ServantBase__epv panel_base_epv = {
NULL, /* _private */
NULL, /* finalize */
NULL, /* use base default_POA function */
NULL, /* _private */
NULL, /* finalize */
NULL /* use base default_POA function */
};
static POA_GNOME_Panel__epv panel_epv = {
NULL, /* private data */
s_panel_add_applet,
s_panel_add_applet_full,
s_panel_quit,
s_panel_get_in_drag,
s_panel_add_status,
s_panel_notice_config_changes
NULL, /* private data */
s_panel_add_applet,
s_panel_add_applet_full,
s_panel_quit,
s_panel_get_in_drag,
s_panel_add_status,
s_panel_notice_config_changes
};
static POA_GNOME_Panel2__epv panel2_epv = {
NULL, /* private data */
s_panel_suggest_sync,
s_panel_add_launcher,
s_panel_ask_about_launcher,
s_panel_add_launcher_from_info,
s_panel_add_launcher_from_info_url,
s_panel_run_box,
s_panel_main_menu
};
static POA_GNOME_Panel__vepv panel_vepv = { &panel_base_epv, &panel_epv };
static POA_GNOME_Panel panel_servant = { NULL, &panel_vepv };
static POA_GNOME_Panel2__vepv panel_vepv = { &panel_base_epv, &panel_epv, &panel2_epv };
static POA_GNOME_Panel2 panel_servant = { NULL, &panel_vepv };
static PortableServer_ServantBase__epv panelspot_base_epv = {
NULL, /* _private */
NULL, /* finalize */
NULL, /* use base default_POA function */
NULL /* use base default_POA function */
};
static POA_GNOME_PanelSpot__epv panelspot_epv = {
......@@ -257,7 +303,7 @@ static POA_GNOME_PanelSpot__vepv panelspot_vepv = { &panelspot_base_epv, &panels
static PortableServer_ServantBase__epv statusspot_base_epv = {
NULL, /* _private */
NULL, /* finalize */
NULL, /* use base default_POA function */
NULL /* use base default_POA function */
};
static POA_GNOME_StatusSpot__epv statusspot_epv = {
......@@ -656,11 +702,8 @@ s_panel_add_applet_full(PortableServer_Servant servant,
CORBA_OBJECT_NIL);
/*select the nth panel*/
if(panel)
li = g_slist_nth(panels, panel);
else
li = NULL;
if(li == NULL)
li = g_slist_nth (panels, panel);
if (li == NULL)
li = panels;
/* There's always at least one */
......@@ -737,6 +780,141 @@ s_panel_notice_config_changes(PortableServer_Servant servant,
load_up_globals();
}
/** Panel2 additions **/
void
s_panel_suggest_sync (PortableServer_Servant _servant,
CORBA_Environment * ev)
{
need_complete_save = TRUE;
panel_config_sync();
}
void
s_panel_add_launcher (PortableServer_Servant _servant,
const CORBA_char * launcher_desktop,
const CORBA_short panel,
const CORBA_short pos,
CORBA_Environment * ev)
{
Launcher *launcher;
PanelWidget *panel_widget;
g_assert (panels != NULL);
panel_widget = g_slist_nth_data (panels, panel);
if (panel_widget == NULL)
panel_widget = panels->data;
launcher = load_launcher_applet (launcher_desktop,
panel_widget, pos, FALSE);
if (launcher != NULL)
launcher_hoard (launcher);
}
void
s_panel_ask_about_launcher (PortableServer_Servant _servant,
const CORBA_char * exec_string,
const CORBA_short panel,
const CORBA_short pos,
CORBA_Environment * ev)
{
PanelWidget *panel_widget;
g_assert (panels != NULL);
panel_widget = g_slist_nth_data (panels, panel);
if (panel_widget == NULL)
panel_widget = panels->data;
ask_about_launcher (exec_string, panel_widget, pos, FALSE);
}
void
s_panel_add_launcher_from_info (PortableServer_Servant _servant,
const CORBA_char * name,
const CORBA_char * comment,
const CORBA_char * exec,
const CORBA_char * icon,
const CORBA_short panel,
const CORBA_short pos,
CORBA_Environment * ev)
{
PanelWidget *panel_widget;
char *exec_argv[2] = { NULL, NULL };
g_assert (panels != NULL);
panel_widget = g_slist_nth_data (panels, panel);
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,
icon, panel_widget, pos, FALSE);
}
void
s_panel_add_launcher_from_info_url (PortableServer_Servant _servant,
const CORBA_char * name,
const CORBA_char * comment,
const CORBA_char * url,
const CORBA_char * icon,
const CORBA_short panel,
const CORBA_short pos,
CORBA_Environment * ev)
{
PanelWidget *panel_widget;
g_assert (panels != NULL);
panel_widget = g_slist_nth_data (panels, panel);
if (panel_widget == NULL)
panel_widget = panels->data;
load_launcher_applet_from_info_url (name, comment, url,
icon, panel_widget, pos, FALSE);
}
void
s_panel_run_box (PortableServer_Servant _servant,
const CORBA_char * initial_string,
CORBA_Environment * ev)
{
if (initial_string != NULL &&
initial_string[0] != '\0')
show_run_dialog_with_text (initial_string);
else
show_run_dialog ();
}
void
s_panel_main_menu (PortableServer_Servant _servant,
CORBA_Environment * ev)
{
PanelWidget *panel;
GtkWidget *menu, *basep;
/* check if anybody else has a grab */
if (gdk_pointer_grab (GDK_ROOT_PARENT(), FALSE,
0, NULL, NULL, GDK_CURRENT_TIME)
!= GrabSuccess) {
return;
} else {
gdk_pointer_ungrab (GDK_CURRENT_TIME);
}
panel = panels->data;
menu = make_popup_panel_menu (panel);
basep = panel->panel_parent;
if (IS_BASEP_WIDGET(basep)) {
BASEP_WIDGET(basep)->autohide_inhibit = TRUE;
basep_widget_autohide (BASEP_WIDGET (basep));
}
gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
NULL, NULL, 0, GDK_CURRENT_TIME);
}
/*** PanelSpot stuff ***/
......@@ -1290,11 +1468,11 @@ panel_corba_gtk_init(CORBA_ORB panel_orb)
orb = panel_orb;
POA_GNOME_Panel__init(&panel_servant, &ev);
pg_return_val_if_fail(&ev, ev._major == CORBA_NO_EXCEPTION, -1);
POA_GNOME_Panel2__init (&panel_servant, &ev);
pg_return_val_if_fail (&ev, ev._major == CORBA_NO_EXCEPTION, -1);
thepoa = (PortableServer_POA)
CORBA_ORB_resolve_initial_references(orb, "RootPOA", &ev);
CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
pg_return_val_if_fail(&ev, ev._major == CORBA_NO_EXCEPTION, -1);
PortableServer_POAManager_activate(PortableServer_POA__get_the_POAManager(thepoa, &ev), &ev);
......
/* gnome-panel-add-launcher: Thingie to add a launcher
*
* Copyright 2000 Eazel, Inc.
* Authors: George Lebl <jirka@5z.com>
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#include <config.h>
#include <gnome.h>
#include <libgnorba/gnorba.h>
#include <libgnomeui/gnome-window-icon.h>
#include <gdk/gdkx.h>
#include "gnome-panel.h"
static int panel = 0;
static int pos = 0;
static gboolean url = FALSE;
static const struct poptOption options[] = {
{ "panel", 0, POPT_ARG_INT, &panel, 0, N_("Panel to add the launcher to"), N_("NUMBER") },
{ "pos", 0, POPT_ARG_INT, &pos, 0, N_("Position to add the launcher to"), N_("NUMBER") },
{ "url", 0, POPT_ARG_NONE, &url, 0, N_("The argument is a url to add, not a .desktop file"), NULL },
{ NULL }
};
int
main (int argc, char **argv)
{
CORBA_Environment ev;
poptContext ctx;
const char **args;
const char *arg;
GNOME_Panel2 panel_client = CORBA_OBJECT_NIL;
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
CORBA_exception_init(&ev);
if (gnome_CORBA_init_with_popt_table ("gnome-panel-add-launcher", VERSION,
&argc, argv,
options, 0, &ctx,
GNORBA_INIT_SERVER_FUNC, &ev) == NULL)
return 1;
args = poptGetArgs (ctx);
if (args == NULL ||
args[0] == NULL ||
args[1] != NULL) {
fprintf (stderr,
_("You must supply a single argument with the "
".desktop file or url to use\n"));
return 1;
}
arg = args[0];
panel_client =
goad_server_activate_with_repo_id (NULL,
"IDL:GNOME/Panel2:1.0",
GOAD_ACTIVATE_EXISTING_ONLY,
NULL);
if (panel_client == NULL) {
fprintf (stderr, _("No panel found\n"));
return 1;
}
if (url)
GNOME_Panel2_add_launcher_from_info_url (panel_client, arg, arg, arg, "", panel, pos, &ev);
else
GNOME_Panel2_add_launcher (panel_client, arg, panel, pos, &ev);
CORBA_exception_free(&ev);
return 0;
}
......@@ -2520,7 +2520,8 @@ panel_widget_add_forbidden(PanelWidget *panel)
}
int
panel_widget_add_full (PanelWidget *panel, GtkWidget *applet, int pos, gboolean bind_lower_events, gboolean insert_at_pos)
panel_widget_add_full (PanelWidget *panel, GtkWidget *applet, int pos,
gboolean bind_lower_events, gboolean insert_at_pos)
{
AppletData *ad = NULL;
......@@ -2532,26 +2533,27 @@ panel_widget_add_full (PanelWidget *panel, GtkWidget *applet, int pos, gboolean
ad = gtk_object_get_data(GTK_OBJECT(applet),PANEL_APPLET_DATA);
if(ad)
if (ad)
pos = ad->pos;
if(pos < 0)
if (pos < 0)
pos = 0;
if(!panel->no_padding_on_ends && pos < pw_applet_padding)
if ( ! panel->no_padding_on_ends &&
pos < pw_applet_padding)
pos = pw_applet_padding;
if(!insert_at_pos) {
if(panel->packed) {
if(get_applet_list_pos(panel,pos))
if ( ! insert_at_pos) {
if (panel->packed) {
if (get_applet_list_pos (panel, pos))
/*this is a slight hack so that this applet
is inserted AFTER an applet with this pos
number*/
pos++;
} else {
int newpos = panel_widget_find_empty_pos(panel,pos);
if(newpos>=0)
int newpos = panel_widget_find_empty_pos (panel, pos);
if (newpos >= 0)
pos = newpos;
else if(get_applet_list_pos(panel,pos))
else if (get_applet_list_pos (panel, pos))
/*this is a slight hack so that this applet
is inserted AFTER an applet with this pos
number*/
......
......@@ -927,8 +927,8 @@ drop_urilist(PanelWidget *panel, int pos, char *urilist,
} else if (S_ISDIR(s.st_mode)) {
drop_menu(panel, pos, filename);
} else if (S_IEXEC & s.st_mode) /*executable?*/
ask_about_launcher(filename,panel,pos,TRUE);
g_free(filename);
ask_about_launcher (filename, panel, pos, TRUE);
g_free (filename);
}
gnome_uri_list_free_strings (files);
......
[gnome_panel]
type=exe
repo_id=IDL:GNOME/Panel:1.0
repo_id=IDL:GNOME/Panel:1.0 IDL:GNOME/Panel2:1.0
description=GNOME Panel
location_info=panel
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment