Commit 10bf3688 authored by Sam Hocevar's avatar Sam Hocevar

* ./modules/gui/gtk2/*: skeletons of Gtk-2.0 and GNOME-2 plugins.

  * ./toolbox: added --update-glade2 flag.
parent db7c69ed
...@@ -42,6 +42,7 @@ EXTRA_DIST = \ ...@@ -42,6 +42,7 @@ EXTRA_DIST = \
gui/beos/Modules.am \ gui/beos/Modules.am \
gui/familiar/Modules.am \ gui/familiar/Modules.am \
gui/gtk/Modules.am \ gui/gtk/Modules.am \
gui/gtk2/Modules.am \
gui/kde/Modules.am \ gui/kde/Modules.am \
gui/macosx/Modules.am \ gui/macosx/Modules.am \
gui/ncurses/Modules.am \ gui/ncurses/Modules.am \
...@@ -67,5 +68,6 @@ EXTRA_DIST = \ ...@@ -67,5 +68,6 @@ EXTRA_DIST = \
video_output/qte/Modules.am \ video_output/qte/Modules.am \
video_output/x11/Modules.am \ video_output/x11/Modules.am \
visualization/scope/Modules.am \ visualization/scope/Modules.am \
visualization/xosd/Modules.am visualization/xosd/Modules.am \
$(NULL)
.deps
.dirstamp
*.dll
*.dylib
*.sl
*.so
COMMON_gtk2 = \
$(NULL)
SOURCES_gtk2 = \
modules/gui/gtk2/gtk2.c \
modules/gui/gtk2/gtk2_callbacks.c \
modules/gui/gtk2/gtk2_callbacks.h \
modules/gui/gtk2/gtk2_interface.c \
modules/gui/gtk2/gtk2_interface.h \
modules/gui/gtk2/gtk2_support.c \
modules/gui/gtk2/gtk2_support.h \
$(COMMON_gtk2)
SOURCES_gnome2 = \
modules/gui/gtk2/gnome2.c \
modules/gui/gtk2/gnome2_callbacks.c \
modules/gui/gtk2/gnome2_callbacks.h \
modules/gui/gtk2/gnome2_interface.c \
modules/gui/gtk2/gnome2_interface.h \
modules/gui/gtk2/gnome2_support.c \
modules/gui/gtk2/gnome2_support.h \
$(COMMON_gtk2)
EXTRA_DIST += \
modules/gui/gtk2/gtk2.glade \
modules/gui/gtk2/gnome2.glade \
$(NULL)
/*****************************************************************************
* gnome2.c : GNOME 2 plugin for vlc
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gnome2.c,v 1.1 2003/03/18 01:26:13 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* 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, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <errno.h> /* ENOMEM */
#include <string.h> /* strerror() */
#include <stdio.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <gnome.h>
#include "gnome2_interface.h"
#include "gnome2_support.h"
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * );
static int Manage ( intf_thread_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
int i = getenv( "DISPLAY" ) == NULL ? 15 : 95;
set_description( _("Gtk2 interface module") );
set_capability( "interface", i );
set_callbacks( Open, Close );
set_program( "gvlc" );
vlc_module_end();
/*****************************************************************************
* intf_sys_t
*****************************************************************************/
struct intf_sys_t
{
module_t *p_gui_helper;
GtkWidget *p_app;
};
/*****************************************************************************
* Open: initialize and create window
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
/* Allocate instance and initialize some members */
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return VLC_ENOMEM;
}
#ifdef NEED_GTK2_MAIN
p_intf->p_sys->p_gui_helper = module_Need( p_this, "gui-helper", "gnome2" );
if( p_intf->p_sys->p_gui_helper == NULL )
{
free( p_intf->p_sys );
return VLC_ENOMOD;
}
#endif
p_intf->pf_run = Run;
return VLC_SUCCESS;
}
/*****************************************************************************
* Close: destroy interface window
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
#ifdef NEED_GTK2_MAIN
module_Unneed( p_intf, p_intf->p_sys->p_gui_helper );
#endif
/* Destroy structure */
free( p_intf->p_sys );
}
/*****************************************************************************
* Run: Gtk+ thread
*****************************************************************************
* this part of the interface is in a separate thread so that we can call
* gtk_main() from within it without annoying the rest of the program.
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
#ifdef NEED_GTK2_MAIN
gdk_threads_enter();
#else
/* gnome_program_init needs to know the command line. We don't care, so
* we give it an empty one */
char *p_args[] = { "", NULL };
int i_args = 1;
int i_dummy;
gtk_set_locale();
gnome_program_init( PACKAGE, VERSION, LIBGNOMEUI_MODULE,
i_args, p_args,
GNOME_PARAM_APP_DATADIR, "",//PACKAGE_DATA_DIR,
NULL );
#endif
/* Create some useful widgets that will certainly be used */
p_intf->p_sys->p_app = create_app1();
/* Set the title of the main window */
//gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_app),
// VOUT_TITLE " (Gtk+ interface)" );
/* Show the control window */
gtk_widget_show( p_intf->p_sys->p_app );
#ifdef NEED_GTK2_MAIN
while( !p_intf->b_die )
{
Manage( p_intf );
/* Sleep to avoid using all CPU - since some interfaces need to
* access keyboard events, a 100ms delay is a good compromise */
gdk_threads_leave();
msleep( INTF_IDLE_SLEEP );
gdk_threads_enter();
}
#else
/* Sleep to avoid using all CPU - since some interfaces needs to access
* keyboard events, a 100ms delay is a good compromise */
i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage,
p_intf );
/* Enter Gtk mode */
gtk_main();
/* Remove the timeout */
gtk_timeout_remove( i_dummy );
#endif
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_app) );
#ifdef NEED_GTK2_MAIN
gdk_threads_leave();
#endif
}
/* following functions are local */
/*****************************************************************************
* Manage: manage main thread messages
*****************************************************************************
* In this function, called approx. 10 times a second, we check what the
* main program wanted to tell us.
*****************************************************************************/
static int Manage( intf_thread_t *p_intf )
{
#ifndef NEED_GTK2_MAIN
if( p_intf->b_die )
{
gtk_main_quit();
return FALSE;
}
#endif
return TRUE;
}
This diff is collapsed.
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>gnome2</name>
<program_name>gnome2</program_name>
<source_directory></source_directory>
<pixmaps_directory></pixmaps_directory>
<output_build_files>FALSE</output_build_files>
<main_source_file>gnome2_interface.c</main_source_file>
<main_header_file>gnome2_interface.h</main_header_file>
<handler_source_file>gnome2_callbacks.c</handler_source_file>
<handler_header_file>gnome2_callbacks.h</handler_header_file>
<support_source_file>gnome2_support.c</support_source_file>
<support_header_file>gnome2_support.h</support_header_file>
</glade-project>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gnome.h>
#include "gnome2_callbacks.h"
#include "gnome2_interface.h"
#include "gnome2_support.h"
void
on_new1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_save1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_save_as1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_quit1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_cut1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_copy1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_paste1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_clear1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_properties1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_preferences1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_about1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
#include <gnome.h>
void
on_new1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_save1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_save_as1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_quit1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_cut1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_copy1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_paste1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_clear1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_properties1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_preferences1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_about1_activate (GtkMenuItem *menuitem,
gpointer user_data);
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <bonobo.h>
#include <gnome.h>
#include "gnome2_callbacks.h"
#include "gnome2_interface.h"
#include "gnome2_support.h"
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
g_object_set_data (G_OBJECT (component), name, widget)
static GnomeUIInfo file1_menu_uiinfo[] =
{
GNOMEUIINFO_MENU_NEW_ITEM (N_("_New"), NULL, on_new1_activate, NULL),
GNOMEUIINFO_MENU_OPEN_ITEM (on_open1_activate, NULL),
GNOMEUIINFO_MENU_SAVE_ITEM (on_save1_activate, NULL),
GNOMEUIINFO_MENU_SAVE_AS_ITEM (on_save_as1_activate, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_EXIT_ITEM (on_quit1_activate, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo edit1_menu_uiinfo[] =
{
GNOMEUIINFO_MENU_CUT_ITEM (on_cut1_activate, NULL),
GNOMEUIINFO_MENU_COPY_ITEM (on_copy1_activate, NULL),
GNOMEUIINFO_MENU_PASTE_ITEM (on_paste1_activate, NULL),
GNOMEUIINFO_MENU_CLEAR_ITEM (on_clear1_activate, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_PROPERTIES_ITEM (on_properties1_activate, NULL),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_MENU_PREFERENCES_ITEM (on_preferences1_activate, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo view1_menu_uiinfo[] =
{
GNOMEUIINFO_END
};
static GnomeUIInfo help1_menu_uiinfo[] =
{
GNOMEUIINFO_MENU_ABOUT_ITEM (on_about1_activate, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo menubar1_uiinfo[] =
{
GNOMEUIINFO_MENU_FILE_TREE (file1_menu_uiinfo),
GNOMEUIINFO_MENU_EDIT_TREE (edit1_menu_uiinfo),
GNOMEUIINFO_MENU_VIEW_TREE (view1_menu_uiinfo),
GNOMEUIINFO_MENU_HELP_TREE (help1_menu_uiinfo),
GNOMEUIINFO_END
};
GtkWidget*
create_app1 (void)
{
GtkWidget *app1;
GtkWidget *bonobodock1;
GtkWidget *toolbar1;
GtkWidget *button2;
GtkWidget *tmp_toolbar_icon;
GtkWidget *button4;
GtkWidget *button3;
GtkWidget *vbox1;
GtkWidget *hscale1;
GtkWidget *appbar1;
app1 = gnome_app_new ("gnome2", _("gnome2"));
bonobodock1 = GNOME_APP (app1)->dock;
gtk_widget_show (bonobodock1);
gnome_app_create_menus (GNOME_APP (app1), menubar1_uiinfo);
toolbar1 = gtk_toolbar_new ();
gtk_widget_show (toolbar1);
gnome_app_add_toolbar (GNOME_APP (app1), GTK_TOOLBAR (toolbar1), "toolbar1",
BONOBO_DOCK_ITEM_BEH_EXCLUSIVE,
BONOBO_DOCK_TOP, 1, 0, 0);
gtk_container_set_border_width (GTK_CONTAINER (toolbar1), 1);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_BOTH);
button2 = gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar1),
"gtk-open",
"gtk-open",
NULL, NULL, NULL, -1);
gtk_widget_show (button2);
tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-cdrom", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1)));
button4 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
GTK_TOOLBAR_CHILD_BUTTON,
NULL,
_("button4"),
_("Open File"), NULL,
tmp_toolbar_icon, NULL, NULL);
gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar1)->children)->data))->label), TRUE);
gtk_widget_show (button4);
tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-refresh", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1)));
button3 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
GTK_TOOLBAR_CHILD_BUTTON,
NULL,
_("button3"),
_("Save File"), NULL,
tmp_toolbar_icon, NULL, NULL);
gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar1)->children)->data))->label), TRUE);
gtk_widget_show (button3);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gnome_app_set_contents (GNOME_APP (app1), vbox1);
hscale1 = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 0, 0, 0, 0)));
gtk_widget_show (hscale1);
gtk_box_pack_start (GTK_BOX (vbox1), hscale1, FALSE, TRUE, 0);
appbar1 = gnome_appbar_new (TRUE, TRUE, GNOME_PREFERENCES_NEVER);
gtk_widget_show (appbar1);
gnome_app_set_statusbar (GNOME_APP (app1), appbar1);
gnome_app_install_menu_hints (GNOME_APP (app1), menubar1_uiinfo);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (app1, app1, "app1");
GLADE_HOOKUP_OBJECT (app1, bonobodock1, "bonobodock1");
GLADE_HOOKUP_OBJECT (app1, menubar1_uiinfo[0].widget, "file1");
GLADE_HOOKUP_OBJECT (app1, file1_menu_uiinfo[0].widget, "new1");
GLADE_HOOKUP_OBJECT (app1, file1_menu_uiinfo[1].widget, "open1");
GLADE_HOOKUP_OBJECT (app1, file1_menu_uiinfo[2].widget, "save1");
GLADE_HOOKUP_OBJECT (app1, file1_menu_uiinfo[3].widget, "save_as1");
GLADE_HOOKUP_OBJECT (app1, file1_menu_uiinfo[4].widget, "separator1");
GLADE_HOOKUP_OBJECT (app1, file1_menu_uiinfo[5].widget, "quit1");
GLADE_HOOKUP_OBJECT (app1, menubar1_uiinfo[1].widget, "edit1");
GLADE_HOOKUP_OBJECT (app1, edit1_menu_uiinfo[0].widget, "cut1");
GLADE_HOOKUP_OBJECT (app1, edit1_menu_uiinfo[1].widget, "copy1");
GLADE_HOOKUP_OBJECT (app1, edit1_menu_uiinfo[2].widget, "paste1");
GLADE_HOOKUP_OBJECT (app1, edit1_menu_uiinfo[3].widget, "clear1");
GLADE_HOOKUP_OBJECT (app1, edit1_menu_uiinfo[4].widget, "separator2");
GLADE_HOOKUP_OBJECT (app1, edit1_menu_uiinfo[5].widget, "properties1");
GLADE_HOOKUP_OBJECT (app1, edit1_menu_uiinfo[6].widget, "separator3");
GLADE_HOOKUP_OBJECT (app1, edit1_menu_uiinfo[7].widget, "preferences1");
GLADE_HOOKUP_OBJECT (app1, menubar1_uiinfo[2].widget, "view1");
GLADE_HOOKUP_OBJECT (app1, menubar1_uiinfo[3].widget, "help1");
GLADE_HOOKUP_OBJECT (app1, help1_menu_uiinfo[0].widget, "about1");
GLADE_HOOKUP_OBJECT (app1, toolbar1, "toolbar1");
GLADE_HOOKUP_OBJECT (app1, button2, "button2");
GLADE_HOOKUP_OBJECT (app1, button4, "button4");
GLADE_HOOKUP_OBJECT (app1, button3, "button3");
GLADE_HOOKUP_OBJECT (app1, vbox1, "vbox1");
GLADE_HOOKUP_OBJECT (app1, hscale1, "hscale1");
GLADE_HOOKUP_OBJECT (app1, appbar1, "appbar1");
return app1;
}
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
GtkWidget* create_app1 (void);
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gnome.h>
#include "gnome2_support.h"
GtkWidget*
lookup_widget (GtkWidget *widget,
const gchar *widget_name)
{
GtkWidget *parent, *found_widget;
for (;;)
{
if (GTK_IS_MENU (widget))
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
else
parent = widget->parent;
if (!parent)
parent = g_object_get_data (G_OBJECT (widget), "GladeParentKey");
if (parent == NULL)
break;
widget = parent;
}
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
widget_name);
if (!found_widget)
g_warning ("Widget not found: %s", widget_name);
return found_widget;
}
/* This is an internally used function to create pixmaps. */
GtkWidget*
create_pixmap (GtkWidget *widget,
const gchar *filename)
{
GtkWidget *pixmap;
gchar *pathname;
if (!filename || !filename[0])
return gtk_image_new ();
pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
filename, TRUE, NULL);
if (!pathname)
{
g_warning (_("Couldn't find pixmap file: %s"), filename);
return gtk_image_new ();
}
pixmap = gtk_image_new_from_file (pathname);
g_free (pathname);
return pixmap;
}
/* This is an internally used function to create pixmaps. */
GdkPixbuf*
create_pixbuf (const gchar *filename)
{
gchar *pathname = NULL;
GdkPixbuf *pixbuf;
GError *error = NULL;
if (!filename || !filename[0])
return NULL;
pathname = gnome_program_locate_file (NULL, GNOME_FILE_DOMAIN_APP_PIXMAP,
filename, TRUE, NULL);
if (!pathname)
{
g_warning (_("Couldn't find pixmap file: %s"), filename);
return NULL;
}
pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
if (!pixbuf)
{
fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
pathname, error->message);
g_error_free (error);
}
g_free (pathname);
return pixbuf;
}
/* This is used to set ATK action descriptions. */
void
glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description)
{
gint n_actions, i;
n_actions = atk_action_get_n_actions (action);
for (i = 0; i < n_actions; i++)
{
if (!strcmp (atk_action_get_name (action, i), action_name))
atk_action_set_description (action, i, description);
}
}
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#include <gnome.h>
/*
* Public Functions.
*/
/*
* This function returns a widget in a component created by Glade.
* Call it with the toplevel widget in the component (i.e. a window/dialog),
* or alternatively any widget in the component, and the name of the widget
* you want returned.
*/
GtkWidget* lookup_widget (GtkWidget *widget,
const gchar *widget_name);
/*
* Private Functions.
*/
/* This is used to create the pixmaps used in the interface. */
GtkWidget* create_pixmap (GtkWidget *widget,
const gchar *filename);
/* This is used to create the pixbufs used in the interface. */
GdkPixbuf* create_pixbuf (const gchar *filename);
/* This is used to set ATK action descriptions. */
void glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description);
/*****************************************************************************
* gtk2.c : Gtk2 plugin for vlc
*****************************************************************************
* Copyright (C) 2003 VideoLAN
* $Id: gtk2.c,v 1.1 2003/03/18 01:26:13 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* 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, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <errno.h> /* ENOMEM */
#include <string.h> /* strerror() */
#include <stdio.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <gtk/gtk.h>
#include "gtk2_callbacks.h"
#include "gtk2_interface.h"
#include "gtk2_support.h"
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * );
static int Manage ( intf_thread_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
int i = getenv( "DISPLAY" ) == NULL ? 15 : 95;
set_description( _("Gtk2 interface module") );
set_capability( "interface", i );
set_callbacks( Open, Close );
set_program( "gvlc" );
vlc_module_end();
/*****************************************************************************
* intf_sys_t
*****************************************************************************/
struct intf_sys_t
{
module_t *p_gui_helper;
GtkWidget *p_window;
};
/*****************************************************************************
* Open: initialize and create window
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
/* Allocate instance and initialize some members */
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return VLC_ENOMEM;
}
#ifdef NEED_GTK2_MAIN
p_intf->p_sys->p_gui_helper = module_Need( p_this, "gui-helper", "gtk2" );
if( p_intf->p_sys->p_gui_helper == NULL )
{
free( p_intf->p_sys );
return VLC_ENOMOD;
}
#endif
p_intf->pf_run = Run;
return VLC_SUCCESS;
}
/*****************************************************************************
* Close: destroy interface window
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
#ifdef NEED_GTK2_MAIN
module_Unneed( p_intf, p_intf->p_sys->p_gui_helper );
#endif
/* Destroy structure */
free( p_intf->p_sys );
}
/*****************************************************************************
* Run: Gtk2 thread
*****************************************************************************
* this part of the interface is in a separate thread so that we can call
* gtk_main() from within it without annoying the rest of the program.
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
#ifdef NEED_GTK2_MAIN
gdk_threads_enter();
#else
/* gtk_init needs to know the command line. We don't care, so we
* give it an empty one */
char *p_args[] = { "", NULL };
char **pp_args = p_args;
int i_args = 1;
int i_dummy;
gtk_set_locale();
gtk_init( &i_args, &pp_args );
#endif
/* Create some useful widgets that will certainly be used */
p_intf->p_sys->p_window = create_window1();
/* Set the title of the main window */
gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
VOUT_TITLE " (Gtk2 interface)");
/* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window );
#ifdef NEED_GTK2_MAIN
while( !p_intf->b_die )
{
Manage( p_intf );
/* Sleep to avoid using all CPU - since some interfaces need to
* access keyboard events, a 100ms delay is a good compromise */
gdk_threads_leave();
msleep( INTF_IDLE_SLEEP );
gdk_threads_enter();
}
#else
/* Sleep to avoid using all CPU - since some interfaces needs to access
* keyboard events, a 100ms delay is a good compromise */
i_dummy = gtk_timeout_add( INTF_IDLE_SLEEP / 1000, (GtkFunction)Manage,
p_intf );
/* Enter Gtk mode */
gtk_main();
/* Remove the timeout */
gtk_timeout_remove( i_dummy );
#endif
gtk_object_destroy( GTK_OBJECT(p_intf->p_sys->p_window) );
#ifdef NEED_GTK2_MAIN
gdk_threads_leave();
#endif
}
/* following functions are local */
/*****************************************************************************
* Manage: manage main thread messages
*****************************************************************************
* In this function, called approx. 10 times a second, we check what the
* main program wanted to tell us.
*****************************************************************************/
static int Manage( intf_thread_t *p_intf )
{
#ifndef NEED_GTK2_MAIN
if( p_intf->b_die )
{
gtk_main_quit();
return FALSE;
}
#endif
return TRUE;
}
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
<child>
<widget class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu1">
<child>
<widget class="GtkImageMenuItem" id="new1">
<property name="visible">True</property>
<property name="label">gtk-new</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_new1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="open1">
<property name="visible">True</property>
<property name="label">gtk-open</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_open1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="save1">
<property name="visible">True</property>
<property name="label">gtk-save</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_save1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="save_as1">
<property name="visible">True</property>
<property name="label">gtk-save-as</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_save_as1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
<child>
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="quit1">
<property name="visible">True</property>
<property name="label">gtk-quit</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_quit1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu2">
<child>
<widget class="GtkImageMenuItem" id="cut1">
<property name="visible">True</property>
<property name="label">gtk-cut</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_cut1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="copy1">
<property name="visible">True</property>
<property name="label">gtk-copy</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_copy1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="paste1">
<property name="visible">True</property>
<property name="label">gtk-paste</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_paste1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="delete1">
<property name="visible">True</property>
<property name="label">gtk-delete</property>
<property name="use_stock">True</property>
<signal name="activate" handler="on_delete1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem3">
<property name="visible">True</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu3">
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu4">
<child>
<widget class="GtkMenuItem" id="about1">
<property name="visible">True</property>
<property name="label" translatable="yes">_About</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_about1_activate" last_modification_time="Thu, 13 Mar 2003 19:52:16 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHandleBox" id="handlebox1">
<property name="visible">True</property>
<property name="shadow_type">GTK_SHADOW_OUT</property>
<property name="handle_position">GTK_POS_LEFT</property>
<property name="snap_edge">GTK_POS_TOP</property>
<child>
<widget class="GtkToolbar" id="toolbar1">
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
<property name="tooltips">True</property>
<child>
<widget class="button" id="button1">
<property name="visible">True</property>
<property name="label" translatable="yes">button1</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-open</property>
</widget>
</child>
<child>
<widget class="button" id="button2">
<property name="visible">True</property>
<property name="label" translatable="yes">button2</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-cdrom</property>
</widget>
</child>
<child>
<widget class="button" id="button3">
<property name="visible">True</property>
<property name="label" translatable="yes">button3</property>
<property name="use_underline">True</property>
<property name="stock_pixmap">gtk-refresh</property>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHScale" id="hscale1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="draw_value">True</property>
<property name="value_pos">GTK_POS_TOP</property>
<property name="digits">1</property>
<property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
<property name="inverted">False</property>
<property name="adjustment">0 0 0 0 0 0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkStatusbar" id="statusbar1">
<property name="visible">True</property>
<property name="has_resize_grip">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>gtk2</name>
<program_name>gtk2</program_name>
<source_directory></source_directory>
<pixmaps_directory></pixmaps_directory>
<gnome_support>FALSE</gnome_support>
<output_build_files>FALSE</output_build_files>
<main_source_file>gtk2_interface.c</main_source_file>
<main_header_file>gtk2_interface.h</main_header_file>
<handler_source_file>gtk2_callbacks.c</handler_source_file>
<handler_header_file>gtk2_callbacks.h</handler_header_file>
<support_source_file>gtk2_support.c</support_source_file>
<support_header_file>gtk2_support.h</support_header_file>
</glade-project>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "gtk2_callbacks.h"
#include "gtk2_interface.h"
#include "gtk2_support.h"
void
on_new1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_save1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_save_as1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_quit1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_cut1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_copy1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_paste1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_delete1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_about1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
#include <gtk/gtk.h>
void
on_new1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_save1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_save_as1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_quit1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_cut1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_copy1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_paste1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_delete1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_about1_activate (GtkMenuItem *menuitem,
gpointer user_data);
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "gtk2_callbacks.h"
#include "gtk2_interface.h"
#include "gtk2_support.h"
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
g_object_set_data (G_OBJECT (component), name, widget)
GtkWidget*
create_window1 (void)
{
GtkWidget *window1;
GtkWidget *vbox1;
GtkWidget *menubar1;
GtkWidget *menuitem1;
GtkWidget *menu1;
GtkWidget *new1;
GtkWidget *open1;
GtkWidget *save1;
GtkWidget *save_as1;
GtkWidget *separatormenuitem1;
GtkWidget *quit1;
GtkWidget *menuitem2;
GtkWidget *menu2;
GtkWidget *cut1;
GtkWidget *copy1;
GtkWidget *paste1;
GtkWidget *delete1;
GtkWidget *menuitem3;
GtkWidget *menu3;
GtkWidget *menuitem4;
GtkWidget *menu4;
GtkWidget *about1;
GtkWidget *handlebox1;
GtkWidget *toolbar1;
GtkWidget *tmp_toolbar_icon;
GtkWidget *button1;
GtkWidget *button2;
GtkWidget *button3;
GtkWidget *hscale1;
GtkWidget *statusbar1;
GtkAccelGroup *accel_group;
accel_group = gtk_accel_group_new ();
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window1), _("window1"));
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox1);
gtk_container_add (GTK_CONTAINER (window1), vbox1);
menubar1 = gtk_menu_bar_new ();
gtk_widget_show (menubar1);
gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0);
menuitem1 = gtk_menu_item_new_with_mnemonic (_("_File"));
gtk_widget_show (menuitem1);
gtk_container_add (GTK_CONTAINER (menubar1), menuitem1);
menu1 = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menu1);
new1 = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group);
gtk_widget_show (new1);
gtk_container_add (GTK_CONTAINER (menu1), new1);
open1 = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
gtk_widget_show (open1);
gtk_container_add (GTK_CONTAINER (menu1), open1);
save1 = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group);
gtk_widget_show (save1);
gtk_container_add (GTK_CONTAINER (menu1), save1);
save_as1 = gtk_image_menu_item_new_from_stock ("gtk-save-as", accel_group);
gtk_widget_show (save_as1);
gtk_container_add (GTK_CONTAINER (menu1), save_as1);
separatormenuitem1 = gtk_separator_menu_item_new ();
gtk_widget_show (separatormenuitem1);
gtk_container_add (GTK_CONTAINER (menu1), separatormenuitem1);
gtk_widget_set_sensitive (separatormenuitem1, FALSE);
quit1 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
gtk_widget_show (quit1);
gtk_container_add (GTK_CONTAINER (menu1), quit1);
menuitem2 = gtk_menu_item_new_with_mnemonic (_("_Edit"));
gtk_widget_show (menuitem2);
gtk_container_add (GTK_CONTAINER (menubar1), menuitem2);
menu2 = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem2), menu2);
cut1 = gtk_image_menu_item_new_from_stock ("gtk-cut", accel_group);
gtk_widget_show (cut1);
gtk_container_add (GTK_CONTAINER (menu2), cut1);
copy1 = gtk_image_menu_item_new_from_stock ("gtk-copy", accel_group);
gtk_widget_show (copy1);
gtk_container_add (GTK_CONTAINER (menu2), copy1);
paste1 = gtk_image_menu_item_new_from_stock ("gtk-paste", accel_group);
gtk_widget_show (paste1);
gtk_container_add (GTK_CONTAINER (menu2), paste1);
delete1 = gtk_image_menu_item_new_from_stock ("gtk-delete", accel_group);
gtk_widget_show (delete1);
gtk_container_add (GTK_CONTAINER (menu2), delete1);
menuitem3 = gtk_menu_item_new_with_mnemonic (_("_View"));
gtk_widget_show (menuitem3);
gtk_container_add (GTK_CONTAINER (menubar1), menuitem3);
menu3 = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem3), menu3);
menuitem4 = gtk_menu_item_new_with_mnemonic (_("_Help"));
gtk_widget_show (menuitem4);
gtk_container_add (GTK_CONTAINER (menubar1), menuitem4);
menu4 = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menu4);
about1 = gtk_menu_item_new_with_mnemonic (_("_About"));
gtk_widget_show (about1);
gtk_container_add (GTK_CONTAINER (menu4), about1);
handlebox1 = gtk_handle_box_new ();
gtk_widget_show (handlebox1);
gtk_box_pack_start (GTK_BOX (vbox1), handlebox1, FALSE, TRUE, 0);
toolbar1 = gtk_toolbar_new ();
gtk_widget_show (toolbar1);
gtk_container_add (GTK_CONTAINER (handlebox1), toolbar1);
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar1), GTK_TOOLBAR_BOTH);
tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-open", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1)));
button1 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
GTK_TOOLBAR_CHILD_BUTTON,
NULL,
_("button1"),
NULL, NULL,
tmp_toolbar_icon, NULL, NULL);
gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar1)->children)->data))->label), TRUE);
gtk_widget_show (button1);
tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-cdrom", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1)));
button2 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
GTK_TOOLBAR_CHILD_BUTTON,
NULL,
_("button2"),
NULL, NULL,
tmp_toolbar_icon, NULL, NULL);
gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar1)->children)->data))->label), TRUE);
gtk_widget_show (button2);
tmp_toolbar_icon = gtk_image_new_from_stock ("gtk-refresh", gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar1)));
button3 = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar1),
GTK_TOOLBAR_CHILD_BUTTON,
NULL,
_("button3"),
NULL, NULL,
tmp_toolbar_icon, NULL, NULL);
gtk_label_set_use_underline (GTK_LABEL (((GtkToolbarChild*) (g_list_last (GTK_TOOLBAR (toolbar1)->children)->data))->label), TRUE);
gtk_widget_show (button3);
hscale1 = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 0, 0, 0, 0)));
gtk_widget_show (hscale1);
gtk_box_pack_start (GTK_BOX (vbox1), hscale1, TRUE, TRUE, 0);
statusbar1 = gtk_statusbar_new ();
gtk_widget_show (statusbar1);
gtk_box_pack_start (GTK_BOX (vbox1), statusbar1, FALSE, FALSE, 0);
g_signal_connect ((gpointer) new1, "activate",
G_CALLBACK (on_new1_activate),
NULL);
g_signal_connect ((gpointer) open1, "activate",
G_CALLBACK (on_open1_activate),
NULL);
g_signal_connect ((gpointer) save1, "activate",
G_CALLBACK (on_save1_activate),
NULL);
g_signal_connect ((gpointer) save_as1, "activate",
G_CALLBACK (on_save_as1_activate),
NULL);
g_signal_connect ((gpointer) quit1, "activate",
G_CALLBACK (on_quit1_activate),
NULL);
g_signal_connect ((gpointer) cut1, "activate",
G_CALLBACK (on_cut1_activate),
NULL);
g_signal_connect ((gpointer) copy1, "activate",
G_CALLBACK (on_copy1_activate),
NULL);
g_signal_connect ((gpointer) paste1, "activate",
G_CALLBACK (on_paste1_activate),
NULL);
g_signal_connect ((gpointer) delete1, "activate",
G_CALLBACK (on_delete1_activate),
NULL);
g_signal_connect ((gpointer) about1, "activate",
G_CALLBACK (on_about1_activate),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (window1, window1, "window1");
GLADE_HOOKUP_OBJECT (window1, vbox1, "vbox1");
GLADE_HOOKUP_OBJECT (window1, menubar1, "menubar1");
GLADE_HOOKUP_OBJECT (window1, menuitem1, "menuitem1");
GLADE_HOOKUP_OBJECT (window1, menu1, "menu1");
GLADE_HOOKUP_OBJECT (window1, new1, "new1");
GLADE_HOOKUP_OBJECT (window1, open1, "open1");
GLADE_HOOKUP_OBJECT (window1, save1, "save1");
GLADE_HOOKUP_OBJECT (window1, save_as1, "save_as1");
GLADE_HOOKUP_OBJECT (window1, separatormenuitem1, "separatormenuitem1");
GLADE_HOOKUP_OBJECT (window1, quit1, "quit1");
GLADE_HOOKUP_OBJECT (window1, menuitem2, "menuitem2");
GLADE_HOOKUP_OBJECT (window1, menu2, "menu2");
GLADE_HOOKUP_OBJECT (window1, cut1, "cut1");
GLADE_HOOKUP_OBJECT (window1, copy1, "copy1");
GLADE_HOOKUP_OBJECT (window1, paste1, "paste1");
GLADE_HOOKUP_OBJECT (window1, delete1, "delete1");
GLADE_HOOKUP_OBJECT (window1, menuitem3, "menuitem3");
GLADE_HOOKUP_OBJECT (window1, menu3, "menu3");
GLADE_HOOKUP_OBJECT (window1, menuitem4, "menuitem4");
GLADE_HOOKUP_OBJECT (window1, menu4, "menu4");
GLADE_HOOKUP_OBJECT (window1, about1, "about1");
GLADE_HOOKUP_OBJECT (window1, handlebox1, "handlebox1");
GLADE_HOOKUP_OBJECT (window1, toolbar1, "toolbar1");
GLADE_HOOKUP_OBJECT (window1, button1, "button1");
GLADE_HOOKUP_OBJECT (window1, button2, "button2");
GLADE_HOOKUP_OBJECT (window1, button3, "button3");
GLADE_HOOKUP_OBJECT (window1, hscale1, "hscale1");
GLADE_HOOKUP_OBJECT (window1, statusbar1, "statusbar1");
gtk_window_add_accel_group (GTK_WINDOW (window1), accel_group);
return window1;
}
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
GtkWidget* create_window1 (void);
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include "gtk2_support.h"
GtkWidget*
lookup_widget (GtkWidget *widget,
const gchar *widget_name)
{
GtkWidget *parent, *found_widget;
for (;;)
{
if (GTK_IS_MENU (widget))
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
else
parent = widget->parent;
if (!parent)
parent = g_object_get_data (G_OBJECT (widget), "GladeParentKey");
if (parent == NULL)
break;
widget = parent;
}
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
widget_name);
if (!found_widget)
g_warning ("Widget not found: %s", widget_name);
return found_widget;
}
static GList *pixmaps_directories = NULL;
/* Use this function to set the directory containing installed pixmaps. */
void
add_pixmap_directory (const gchar *directory)
{
pixmaps_directories = g_list_prepend (pixmaps_directories,
g_strdup (directory));
}
/* This is an internally used function to find pixmap files. */
static gchar*
find_pixmap_file (const gchar *filename)
{
GList *elem;
/* We step through each of the pixmaps directory to find it. */
elem = pixmaps_directories;
while (elem)
{
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
G_DIR_SEPARATOR_S, filename);
if (g_file_test (pathname, G_FILE_TEST_EXISTS))
return pathname;
g_free (pathname);
elem = elem->next;
}
return NULL;
}
/* This is an internally used function to create pixmaps. */
GtkWidget*
create_pixmap (GtkWidget *widget,
const gchar *filename)
{
gchar *pathname = NULL;
GtkWidget *pixmap;
if (!filename || !filename[0])
return gtk_image_new ();
pathname = find_pixmap_file (filename);
if (!pathname)
{
g_warning (_("Couldn't find pixmap file: %s"), filename);
return gtk_image_new ();
}
pixmap = gtk_image_new_from_file (pathname);
g_free (pathname);
return pixmap;
}
/* This is an internally used function to create pixmaps. */
GdkPixbuf*
create_pixbuf (const gchar *filename)
{
gchar *pathname = NULL;
GdkPixbuf *pixbuf;
GError *error = NULL;
if (!filename || !filename[0])
return NULL;
pathname = find_pixmap_file (filename);
if (!pathname)
{
g_warning (_("Couldn't find pixmap file: %s"), filename);
return NULL;
}
pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
if (!pixbuf)
{
fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
pathname, error->message);
g_error_free (error);
}
g_free (pathname);
return pixbuf;
}
/* This is used to set ATK action descriptions. */
void
glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description)
{
gint n_actions, i;
n_actions = atk_action_get_n_actions (action);
for (i = 0; i < n_actions; i++)
{
if (!strcmp (atk_action_get_name (action, i), action_name))
atk_action_set_description (action, i, description);
}
}
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
/*
* Standard gettext macros.
*/
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif
/*
* Public Functions.
*/
/*
* This function returns a widget in a component created by Glade.
* Call it with the toplevel widget in the component (i.e. a window/dialog),
* or alternatively any widget in the component, and the name of the widget
* you want returned.
*/
GtkWidget* lookup_widget (GtkWidget *widget,
const gchar *widget_name);
/* Use this function to set the directory containing installed pixmaps. */
void add_pixmap_directory (const gchar *directory);
/*
* Private Functions.
*/
/* This is used to create the pixmaps used in the interface. */
GtkWidget* create_pixmap (GtkWidget *widget,
const gchar *filename);
/* This is used to create the pixbufs used in the interface. */
GdkPixbuf* create_pixbuf (const gchar *filename);
/* This is used to set ATK action descriptions. */
void glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description);
SOURCES_gtk_main = modules/misc/gtk_main.c SOURCES_gtk_main = modules/misc/gtk_main.c
SOURCES_gnome_main = modules/misc/gtk_main.c SOURCES_gnome_main = modules/misc/gtk_main.c
SOURCES_gtk2_main = modules/misc/gtk_main.c
SOURCES_gnome2_main = modules/misc/gtk_main.c
SOURCES_sap = modules/misc/sap.c SOURCES_sap = modules/misc/sap.c
SOURCES_screensaver = modules/misc/screensaver.c SOURCES_screensaver = modules/misc/screensaver.c
SOURCES_qte_main = modules/misc/qte_main.cpp SOURCES_qte_main = modules/misc/qte_main.cpp
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk_main.c : Gtk+ wrapper for gtk_main * gtk_main.c : Gtk+ wrapper for gtk_main
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: gtk_main.c,v 1.12 2003/03/17 18:02:10 sam Exp $ * $Id: gtk_main.c,v 1.13 2003/03/18 01:26:13 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -175,8 +175,13 @@ static void GtkMain( vlc_object_t *p_this ) ...@@ -175,8 +175,13 @@ static void GtkMain( vlc_object_t *p_this )
/* FIXME: deprecated ? */ /* FIXME: deprecated ? */
/* gdk_threads_init(); */ /* gdk_threads_init(); */
#if defined(MODULE_NAME_IS_gnome_main) || defined(MODULE_NAME_IS_gnome2_main) #if defined(MODULE_NAME_IS_gnome_main)
gnome_init( p_this->p_vlc->psz_object_name, VERSION, i_args, p_args ); gnome_init( p_this->p_vlc->psz_object_name, VERSION, i_args, p_args );
#elif defined(MODULE_NAME_IS_gnome2_main)
gnome_program_init( PACKAGE, VERSION, LIBGNOMEUI_MODULE,
i_args, p_args,
GNOME_PARAM_APP_DATADIR, "",//PACKAGE_DATA_DIR,
NULL );
#else #else
gtk_set_locale(); gtk_set_locale();
gtk_init( &i_args, &pp_args ); gtk_init( &i_args, &pp_args );
......
#! /bin/sh #! /bin/sh
## toolbox for the VLC media player ## toolbox for the VLC media player
## $Id: toolbox,v 1.15 2003/03/17 16:59:46 sam Exp $ ## $Id: toolbox,v 1.16 2003/03/18 01:26:13 sam Exp $
## ##
## Authors: Samuel Hocevar <sam@zoy.org> ## Authors: Samuel Hocevar <sam@zoy.org>
...@@ -25,6 +25,7 @@ recognized flags are: ...@@ -25,6 +25,7 @@ recognized flags are:
--update-po update translation files --update-po update translation files
--update-includes [BUILTINS] generate various include files --update-includes [BUILTINS] generate various include files
--update-glade generate and fix Glade code --update-glade generate and fix Glade code
--update-glade2 generate and fix Glade 2 code
EOF EOF
exit 1 exit 1
} }
...@@ -64,6 +65,9 @@ case "$1" in ...@@ -64,6 +65,9 @@ case "$1" in
--update-glade|--fix-glade) --update-glade|--fix-glade)
action=glade action=glade
;; ;;
--update-glade2|--update-glade-2|--fix-glade2)
action=glade2
;;
--help) --help)
help help
;; ;;
...@@ -453,3 +457,17 @@ EOF ...@@ -453,3 +457,17 @@ EOF
exit 0 exit 0
fi fi
##
## Fix glade2-generated files
##
if test "${action}" = "glade2"
then
for file in modules/gui/gtk2/gnome2.glade modules/gui/gtk2/gtk2.glade
do
echo "generating code from $file"
glade-2 -w $file || exit 1
done
exit 0
fi
......
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