]> git.sesse.net Git - vlc/commitdiff
Interface neatly exits now.
authorJean-Paul Saman <jpsaman@videolan.org>
Tue, 23 Jul 2002 18:39:29 +0000 (18:39 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Tue, 23 Jul 2002 18:39:29 +0000 (18:39 +0000)
plugins/familiar/familiar.c
plugins/familiar/familiar.glade
plugins/familiar/familiar.h
plugins/familiar/familiar_callbacks.c
plugins/familiar/familiar_callbacks.h
plugins/familiar/familiar_interface.c
plugins/familiar/familiar_support.c

index 753aa1efc02e1751a7c8a457d07d7cae60c9ebc7..c29f53ea1c834f7797d5673a6462d08d1b658688 100644 (file)
@@ -2,7 +2,7 @@
  * familiar.c : familiar plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: familiar.c,v 1.4 2002/07/22 21:04:55 jpsaman Exp $
+ * $Id: familiar.c,v 1.5 2002/07/23 18:39:29 jpsaman Exp $
  *
  * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
  *
@@ -95,11 +95,6 @@ static int  intf_Open         ( intf_thread_t *p_intf );
 static void intf_Close        ( intf_thread_t *p_intf );
 static void intf_Run          ( intf_thread_t *p_intf );
 
-/*****************************************************************************
- * Local variables (mutex-protected).
- *****************************************************************************/
-//static void ** pp_global_data = NULL;
-
 /*****************************************************************************
  * Building configuration tree
  *****************************************************************************/
@@ -179,7 +174,7 @@ static void intf_Run( intf_thread_t *p_intf )
     char  *p_args[] = { "" };
     char **pp_args  = p_args;
     int    i_args   = 1;
-    int    i_dummy;
+    int    i_dummy  = 0;
 
     /* Initialize Gtk+ */
     gtk_set_locale ();
@@ -193,7 +188,7 @@ static void intf_Run( intf_thread_t *p_intf )
 
     /* Create some useful widgets that will certainly be used */
 // FIXME: magic path
-    add_pixmap_directory("/home/jpsaman/vlc/share");
+    add_pixmap_directory("share");
     p_intf->p_sys->p_window = create_familiar();
     if (p_intf->p_sys->p_window == NULL)
     {
index 6a91c5edc4d6c84157417cd62b92ae091689a7ed..5dfebf981d13ef4b4ff83c8d6e2e62b77ddd3744 100644 (file)
@@ -5,8 +5,8 @@
   <name>Familiar</name>
   <program_name>familiar</program_name>
   <directory></directory>
-  <source_directory>src</source_directory>
-  <pixmaps_directory>share</pixmaps_directory>
+  <source_directory></source_directory>
+  <pixmaps_directory>../../share</pixmaps_directory>
   <language>C</language>
   <gnome_support>False</gnome_support>
   <gettext_support>True</gettext_support>
   <name>familiar</name>
   <width>240</width>
   <height>320</height>
+  <signal>
+    <name>destroy_event</name>
+    <handler>on_familiar_destroy_event</handler>
+    <last_modification_time>Tue, 23 Jul 2002 18:16:11 GMT</last_modification_time>
+  </signal>
   <signal>
     <name>destroy</name>
-    <handler>on_familiar_destroy</handler>
-    <last_modification_time>Mon, 22 Jul 2002 18:58:45 GMT</last_modification_time>
+    <handler>gtk_main_quit</handler>
+    <last_modification_time>Tue, 23 Jul 2002 18:17:28 GMT</last_modification_time>
   </signal>
   <title>vlc (familiar)</title>
   <type>GTK_WINDOW_TOPLEVEL</type>
index 7afe150165473ea926d923554627337a7e80dfe1..260d4410ad421c41cfca6623054ccbb26d61fe2e 100644 (file)
@@ -2,7 +2,7 @@
  * familiar.h: private Gtk+ interface description
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: familiar.h,v 1.3 2002/07/22 21:04:55 jpsaman Exp $
+ * $Id: familiar.h,v 1.4 2002/07/23 18:39:29 jpsaman Exp $
  *
  * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
  *
@@ -38,3 +38,9 @@ struct intf_sys_t
     void             ( *pf_callback[MAX_ATEXIT] ) ( void );
 };
 
+/*****************************************************************************
+ * Useful macro
+ ****************************************************************************/
+#define  GtkGetIntf( widget ) __GtkGetIntf( GTK_WIDGET( widget ) )
+void * __GtkGetIntf( GtkWidget * );
+
index eba23b8a101503652afd29bb79e6f59385b9c7c8..4fcef4cd6dc3b4816311d3d831761600e9cc66e8 100644 (file)
@@ -1,3 +1,39 @@
+/*****************************************************************************
+ * familiar_callbacks.c : Callbacks for the Familiar Linux Gtk+ plugin.
+ *****************************************************************************
+ * Copyright (C) 2000, 2001 VideoLAN
+ * $Id: familiar_callbacks.c,v 1.3 2002/07/23 18:39:29 jpsaman Exp $
+ *
+ * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
+ *
+ * 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 <sys/types.h>                                              /* off_t */
+#include <stdlib.h>
+
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+#include <vlc/vout.h>
+
+#include <unistd.h>
+#include <string.h>
+
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
@@ -7,6 +43,59 @@
 #include "familiar_callbacks.h"
 #include "familiar_interface.h"
 #include "familiar_support.h"
+#include "familiar.h"
+
+//#include "netutils.h"
+
+/*****************************************************************************
+ * Useful function to retrieve p_intf
+ ****************************************************************************/
+void * __GtkGetIntf( GtkWidget * widget )
+{
+    void *p_data;
+
+    if( GTK_IS_MENU_ITEM( widget ) )
+    {
+        /* Look for a GTK_MENU */
+        while( widget->parent && !GTK_IS_MENU( widget ) )
+        {
+            widget = widget->parent;
+        }
+
+        /* Maybe this one has the data */
+        p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
+        if( p_data )
+        {
+            return p_data;
+        }
+
+        /* Otherwise, the parent widget has it */
+        widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
+    }
+
+    /* We look for the top widget */
+    widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) );
+
+    p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
+
+    return p_data;
+}
+
+/*
+ * Main interface callbacks
+ */
+
+gboolean GtkExit( GtkWidget       *widget,
+                  gpointer         user_data )
+{
+    intf_thread_t *p_intf = GtkGetIntf( widget );
+
+    vlc_mutex_lock( &p_intf->change_lock );
+    p_intf->p_vlc->b_die = VLC_TRUE;
+    vlc_mutex_unlock( &p_intf->change_lock );
+
+    return TRUE;
+}
 
 gboolean
 on_xpm_open_button_press_event         (GtkWidget       *widget,
@@ -78,10 +167,12 @@ on_xpm_forward_button_press_event      (GtkWidget       *widget,
 }
 
 
-void
-on_familiar_destroy                    (GtkObject       *object,
+gboolean
+on_familiar_destroy_event              (GtkWidget       *widget,
+                                        GdkEvent        *event,
                                         gpointer         user_data)
 {
-  gtk_main_quit();
+  GtkExit( GTK_WIDGET( widget ), user_data );
+  return TRUE;
 }
 
index d76e07f729ff088890c167f24d82dcbe5b09c372..1d22ada178d7f0ab9016123e047c3217bb55943d 100644 (file)
@@ -1,5 +1,8 @@
+
 #include <gtk/gtk.h>
 
+gboolean GtkExit                ( GtkWidget *, gpointer );
+
 gboolean
 on_xpm_open_button_press_event         (GtkWidget       *widget,
                                         GdkEventButton  *event,
@@ -35,6 +38,7 @@ on_xpm_forward_button_press_event      (GtkWidget       *widget,
                                         GdkEventButton  *event,
                                         gpointer         user_data);
 
-void
-on_familiar_destroy                    (GtkObject       *object,
+gboolean
+on_familiar_destroy_event              (GtkWidget       *widget,
+                                        GdkEvent        *event,
                                         gpointer         user_data);
index 479f5f72377dbedc9619f4ebbdd66673ad7b94d2..43b7f5d9bb93998f8618798595e96062ca5dcf6f 100644 (file)
@@ -395,8 +395,11 @@ create_familiar (void)
   gtk_widget_show (about);
   gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 2), about);
 
+  gtk_signal_connect (GTK_OBJECT (familiar), "destroy_event",
+                      GTK_SIGNAL_FUNC (on_familiar_destroy_event),
+                      NULL);
   gtk_signal_connect (GTK_OBJECT (familiar), "destroy",
-                      GTK_SIGNAL_FUNC (on_familiar_destroy),
+                      GTK_SIGNAL_FUNC (gtk_main_quit),
                       NULL);
   gtk_signal_connect (GTK_OBJECT (xpm_open), "button_press_event",
                       GTK_SIGNAL_FUNC (on_xpm_open_button_press_event),
index 3fa4cb4b4f219b5957410482c2df6e11a1687a6d..22ca9310d0fbdf9faf6b6ab63b6e8cfead143257 100644 (file)
@@ -113,7 +113,7 @@ create_pixmap                          (GtkWidget       *widget,
   /* If we haven't found the pixmap, try the source directory. */
   if (!found_filename)
     {
-      found_filename = check_file_exists ("../share", filename);
+      found_filename = check_file_exists ("../../share", filename);
     }
 
   if (!found_filename)