Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/url.c @ 8719:dc27303ae528
correct widget destroy event handler (thank for D J Hawkey Jr <hawkeyd@visi.com>)
author | pontscho |
---|---|
date | Thu, 02 Jan 2003 15:48:29 +0000 |
parents | 5b67aed0fc28 |
children | ad75409ed15e |
rev | line source |
---|---|
6298 | 1 |
2 #include <sys/types.h> | |
3 #include <sys/stat.h> | |
4 #include <unistd.h> | |
5 #include <stdlib.h> | |
6 #include <stdio.h> | |
7 #include <string.h> | |
8 | |
9 #include <gdk/gdkkeysyms.h> | |
10 #include <gtk/gtk.h> | |
11 | |
12 #include "url.h" | |
8299 | 13 #include "common.h" |
6298 | 14 #include "../../interface.h" |
8043 | 15 #include "../../app.h" |
6335
e9bd97d5c5cc
warning & newline fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
6298
diff
changeset
|
16 #include "../widgets.h" |
6651 | 17 #include "../../help_mp.h" |
6298 | 18 |
8299 | 19 GtkWidget * URL = NULL; |
6298 | 20 |
21 static GtkWidget * URLCombo; | |
22 static GtkWidget * URLEntry; | |
23 static GList * URLComboEntrys = NULL; | |
24 | |
25 void ShowURLDialogBox( void ) | |
26 { | |
8299 | 27 if ( URL ) gtkActive( URL ); |
6298 | 28 else URL=create_URL(); |
29 | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
30 if ( URLList ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
31 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
32 URLItem * item = URLList; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
33 g_list_free( URLComboEntrys ); |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
34 URLComboEntrys=NULL; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
35 while( item ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
36 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
37 URLComboEntrys=g_list_append( URLComboEntrys,(gchar *)item->url ); |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
38 item=item->next; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
39 } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
40 } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
41 |
6298 | 42 if ( URLComboEntrys ) |
43 { | |
44 gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data ); | |
45 gtk_combo_set_popdown_strings( GTK_COMBO( URLCombo ),URLComboEntrys ); | |
46 } | |
47 | |
48 gtk_widget_show( URL ); | |
49 } | |
50 | |
51 void HideURLDialogBox( void ) | |
52 { | |
8299 | 53 if ( !URL ) return; |
6298 | 54 gtk_widget_hide( URL ); |
55 gtk_widget_destroy( URL ); | |
8299 | 56 URL=0; |
6298 | 57 } |
58 | |
59 static void on_Button_pressed( GtkButton * button,gpointer user_data ) | |
60 { | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
61 URLItem * item; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
62 |
6298 | 63 if ( (int)user_data ) |
64 { | |
65 gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) ); | |
66 | |
67 if ( str ) | |
68 { | |
7287 | 69 if ( strncmp( str,"http://",7 ) && strncmp( str,"ftp://",6 ) && strncmp( str,"mms://",6 ) ) |
6298 | 70 { |
71 gchar * tmp; | |
72 tmp=malloc( strlen( str ) + 8 ); | |
73 sprintf( tmp,"http://%s",str ); | |
74 free( str ); str=tmp; | |
75 } | |
76 URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str ); | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
77 |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
78 item=calloc( 1,sizeof( URLItem ) ); |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
79 item->url=gstrdup( str ); |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
80 gtkSet( gtkAddURLItem,0,(void *)item ); |
6298 | 81 |
82 guiSetFilename( guiIntfStruct.Filename,str ); guiIntfStruct.FilenameChanged=1; | |
6651 | 83 mplEventHandling( evPlayNetwork,0 ); |
6298 | 84 } |
85 } | |
86 HideURLDialogBox(); | |
87 } | |
88 | |
89 GtkWidget * create_URL( void ) | |
90 { | |
91 GtkWidget * vbox1; | |
92 GtkWidget * hbox1; | |
93 GtkWidget * hbuttonbox1; | |
94 GtkWidget * Ok; | |
95 GtkWidget * Cancel; | |
96 GtkAccelGroup * accel_group; | |
97 | |
98 accel_group=gtk_accel_group_new(); | |
99 | |
8043 | 100 URL=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
6298 | 101 gtk_widget_set_name( URL,"URL" ); |
102 gtk_object_set_data( GTK_OBJECT( URL ),"URL",URL ); | |
6651 | 103 gtk_widget_set_usize( URL,384,70 ); |
6298 | 104 GTK_WIDGET_SET_FLAGS( URL,GTK_CAN_DEFAULT ); |
6651 | 105 gtk_window_set_title( GTK_WINDOW( URL ),MSGTR_Network ); |
6298 | 106 gtk_window_set_position( GTK_WINDOW( URL ),GTK_WIN_POS_CENTER ); |
107 gtk_window_set_policy( GTK_WINDOW( URL ),TRUE,TRUE,FALSE ); | |
8299 | 108 gtk_window_set_wmclass( GTK_WINDOW( URL ),"Network","MPlayer" ); |
6651 | 109 |
110 gtk_widget_realize( URL ); | |
111 gtkAddIcon( URL ); | |
6298 | 112 |
8299 | 113 vbox1=AddVBox( AddDialogFrame( URL ),0 ); |
114 hbox1=AddHBox( vbox1,1 ); | |
115 AddLabel( "URL: ",hbox1 ); | |
6298 | 116 |
8299 | 117 URLCombo=AddComboBox( hbox1 ); |
118 /* | |
119 gtk_combo_new(); | |
6298 | 120 gtk_widget_set_name( URLCombo,"URLCombo" ); |
121 gtk_widget_show( URLCombo ); | |
122 gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 ); | |
8299 | 123 */ |
6298 | 124 URLEntry=GTK_COMBO( URLCombo )->entry; |
125 gtk_widget_set_name( URLEntry,"URLEntry" ); | |
126 gtk_widget_show( URLEntry ); | |
127 | |
8299 | 128 AddHSeparator( vbox1 ); |
6298 | 129 |
8299 | 130 hbuttonbox1=AddHButtonBox( vbox1 ); |
131 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
132 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
6298 | 133 |
8299 | 134 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); |
135 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
6298 | 136 |
8299 | 137 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); |
138 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
6298 | 139 |
8719
dc27303ae528
correct widget destroy event handler (thank for D J Hawkey Jr <hawkeyd@visi.com>)
pontscho
parents:
8299
diff
changeset
|
140 gtk_signal_connect( GTK_OBJECT( URL ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&URL ); |
8299 | 141 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 ); |
142 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL ); | |
6298 | 143 |
6651 | 144 gtk_widget_grab_focus( URLEntry ); |
6298 | 145 gtk_window_add_accel_group( GTK_WINDOW( URL ),accel_group ); |
146 | |
147 return URL; | |
148 } | |
149 |