comparison plugins/musicmessaging/musicmessaging.c @ 11169:778d5464a9b8

[gaim-migrate @ 13270] Fixed up the plugin to destroy the buttons proper. committer: Tailor Script <tailor@pidgin.im>
author Christian Muise <christian.muise@gmail.com>
date Fri, 29 Jul 2005 05:05:52 +0000
parents 268d5c498b64
children 4295083cf489
comparison
equal deleted inserted replaced
11168:198bdde7ea63 11169:778d5464a9b8
13 #define MUSICMESSAGIN_PLUGIN_ID "gtk-hazure-musicmessaging" 13 #define MUSICMESSAGIN_PLUGIN_ID "gtk-hazure-musicmessaging"
14 14
15 static gboolean start_session(void); 15 static gboolean start_session(void);
16 static void run_editor(void); 16 static void run_editor(void);
17 static void add_button (GaimConversation *conv); 17 static void add_button (GaimConversation *conv);
18 static void remove_button (GtkWidget *button);
18 19
19 typedef struct { 20 typedef struct {
20 GaimBuddy *buddy; 21 GaimBuddy *buddy;
21 GtkWidget *window; 22 GtkWidget *window;
22 /* Something for the ly file? */ 23 /* Something for the ly file? */
25 26
26 } MMSession; 27 } MMSession;
27 28
28 /* List of sessions */ 29 /* List of sessions */
29 GList *sessions; 30 GList *sessions;
31
32 /* List of created buttons */
33 GList *widgets;
30 34
31 /* Pointer to this plugin */ 35 /* Pointer to this plugin */
32 GaimPlugin *plugin_pointer; 36 GaimPlugin *plugin_pointer;
33 37
34 static gboolean 38 static gboolean
54 plugin_unload(GaimPlugin *plugin) { 58 plugin_unload(GaimPlugin *plugin) {
55 59
56 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Unloaded", 60 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Unloaded",
57 gaim_prefs_get_string ("/plugins/gtk/musicmessaging/editor_path"), NULL, NULL, NULL); 61 gaim_prefs_get_string ("/plugins/gtk/musicmessaging/editor_path"), NULL, NULL, NULL);
58 62
59 63 g_list_foreach(widgets, (GFunc) remove_button, NULL);
60 return TRUE; 64 return TRUE;
61 } 65 }
62 66
63 static gboolean 67 static gboolean
64 start_session(void) 68 start_session(void)
65 { 69 {
66 run_editor(); 70 run_editor();
67 return TRUE; 71 return TRUE;
68 } 72 }
69 73
74 static void music_button_toggled (GtkWidget *widget, gpointer data)
75 {
76 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
77 {
78 start_session();
79 } else {
80
81 /* kill program */
82 }
83 }
84
70 static void set_editor_path (GtkWidget *button, GtkWidget *text_field) 85 static void set_editor_path (GtkWidget *button, GtkWidget *text_field)
71 { 86 {
72 const char * path = gtk_entry_get_text((GtkEntry*)text_field); 87 const char * path = gtk_entry_get_text((GtkEntry*)text_field);
73 gaim_prefs_set_string("/plugins/gtk/musicmessaging/editor_path", path); 88 gaim_prefs_set_string("/plugins/gtk/musicmessaging/editor_path", path);
74
75 /*Testing*
76 start_session();
77 */
78 89
79 } 90 }
80 91
81 static void run_editor (void) 92 static void run_editor (void)
82 { 93 {
91 } 102 }
92 } 103 }
93 104
94 static void add_button (GaimConversation *conv) 105 static void add_button (GaimConversation *conv)
95 { 106 {
96 GtkWidget *button, *image, *bbox; 107 GtkWidget *button, *image, *sep;
97 108
98 button = gtk_toggle_button_new(); 109 button = gtk_toggle_button_new();
99 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); 110 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
100 111
101 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_session), NULL); 112 g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(music_button_toggled), NULL);
102
103 bbox = gtk_vbox_new(FALSE, 0);
104
105 gtk_container_add (GTK_CONTAINER(button), bbox);
106 113
107 gchar *file_path = g_build_filename (DATADIR, "pixmaps", "gaim", "buttons", "music.png", NULL); 114 gchar *file_path = g_build_filename (DATADIR, "pixmaps", "gaim", "buttons", "music.png", NULL);
108 image = gtk_image_new_from_file(file_path); 115 image = gtk_image_new_from_file("/usr/local/share/pixmaps/gaim/buttons/music.png");
109 116
110 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); 117 gtk_container_add((GtkContainer *)button, image);
111 118
112 gtk_widget_show_all(bbox); 119 sep = gtk_vseparator_new();
113 120
121 g_list_append(widgets, sep);
122 g_list_append(widgets, button);
123
124 gtk_widget_show(sep);
125 gtk_widget_show(image);
126 gtk_widget_show(button);
127
128 gtk_box_pack_start(GTK_BOX(GAIM_GTK_CONVERSATION(conv)->toolbar), sep, FALSE, FALSE, 0);
114 gtk_box_pack_start(GTK_BOX(GAIM_GTK_CONVERSATION(conv)->toolbar), button, FALSE, FALSE, 0); 129 gtk_box_pack_start(GTK_BOX(GAIM_GTK_CONVERSATION(conv)->toolbar), button, FALSE, FALSE, 0);
130 }
131
132 static void remove_button (GtkWidget *button)
133 {
134 gtk_widget_hide(button);
135 gtk_widget_destroy(button);
115 } 136 }
116 137
117 static GtkWidget * 138 static GtkWidget *
118 get_config_frame(GaimPlugin *plugin) 139 get_config_frame(GaimPlugin *plugin)
119 { 140 {