Mercurial > pidgin
comparison plugins/musicmessaging/musicmessaging.c @ 11166:268d5c498b64
[gaim-migrate @ 13267]
Tried adding the button and the method to start the score editor.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Muise <christian.muise@gmail.com> |
---|---|
date | Fri, 29 Jul 2005 03:26:59 +0000 |
parents | 641915a13cec |
children | 778d5464a9b8 |
comparison
equal
deleted
inserted
replaced
11165:f20813369fe8 | 11166:268d5c498b64 |
---|---|
1 #include "internal.h" | 1 #include "internal.h" |
2 #include "gtkgaim.h" | 2 #include "gtkgaim.h" |
3 | |
4 #include "conversation.h" | |
3 | 5 |
4 #include "gtkconv.h" | 6 #include "gtkconv.h" |
5 #include "gtkplugin.h" | 7 #include "gtkplugin.h" |
6 #include "gtkutils.h" | 8 #include "gtkutils.h" |
7 | 9 |
8 #include "notify.h" | 10 #include "notify.h" |
9 #include "version.h" | 11 #include "version.h" |
10 | 12 |
11 #define MUSICMESSAGIN_PLUGIN_ID "gtk-hazure-musicmessaging" | 13 #define MUSICMESSAGIN_PLUGIN_ID "gtk-hazure-musicmessaging" |
12 | 14 |
15 static gboolean start_session(void); | |
16 static void run_editor(void); | |
17 static void add_button (GaimConversation *conv); | |
18 | |
19 typedef struct { | |
20 GaimBuddy *buddy; | |
21 GtkWidget *window; | |
22 /* Something for the ly file? */ | |
23 | |
24 /* Anything else needed for a session? */ | |
25 | |
26 } MMSession; | |
27 | |
28 /* List of sessions */ | |
29 GList *sessions; | |
30 | |
31 /* Pointer to this plugin */ | |
32 GaimPlugin *plugin_pointer; | |
33 | |
13 static gboolean | 34 static gboolean |
14 plugin_load(GaimPlugin *plugin) { | 35 plugin_load(GaimPlugin *plugin) { |
15 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Welcome", | 36 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Welcome", |
16 "Welcome to music messaging.", NULL, NULL, NULL); | 37 "Welcome to music messaging.", NULL, NULL, NULL); |
17 | 38 /* Keep the plugin for reference (needed for notify's) */ |
18 return TRUE; | 39 plugin_pointer = plugin; |
40 | |
41 /* Add the button to all the current conversations */ | |
42 gaim_conversation_foreach (add_button); | |
43 | |
44 /* Listen for any new conversations */ | |
45 void *conv_list_handle = gaim_conversations_get_handle(); | |
46 | |
47 gaim_signal_connect(conv_list_handle, "conversation-created", | |
48 plugin, GAIM_CALLBACK(add_button), NULL); | |
49 | |
50 return TRUE; | |
19 } | 51 } |
20 | 52 |
21 static gboolean | 53 static gboolean |
22 plugin_unload(GaimPlugin *plugin) { | 54 plugin_unload(GaimPlugin *plugin) { |
55 | |
23 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Unloaded", | 56 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Unloaded", |
24 "The MM plugin has been unloaded.", NULL, NULL, NULL); | 57 gaim_prefs_get_string ("/plugins/gtk/musicmessaging/editor_path"), NULL, NULL, NULL); |
58 | |
59 | |
25 return TRUE; | 60 return TRUE; |
26 } | 61 } |
27 | 62 |
28 static gboolean | 63 static gboolean |
29 plugin_destroyed(GaimPlugin *plugin) { | 64 start_session(void) |
30 gaim_notify_message(plugin, GAIM_NOTIFY_MSG_INFO, "Destroyed", | 65 { |
31 "The MM plugin has been destroyed.", NULL, NULL, NULL); | 66 run_editor(); |
32 return TRUE; | 67 return TRUE; |
68 } | |
69 | |
70 static void set_editor_path (GtkWidget *button, GtkWidget *text_field) | |
71 { | |
72 const char * path = gtk_entry_get_text((GtkEntry*)text_field); | |
73 gaim_prefs_set_string("/plugins/gtk/musicmessaging/editor_path", path); | |
74 | |
75 /*Testing* | |
76 start_session(); | |
77 */ | |
78 | |
79 } | |
80 | |
81 static void run_editor (void) | |
82 { | |
83 GError *spawn_error = NULL; | |
84 gchar * args[2]; | |
85 args[0] = (gchar *)gaim_prefs_get_string("/plugins/gtk/musicmessaging/editor_path"); | |
86 args[1] = NULL; | |
87 if (!(g_spawn_async (".", args, NULL, 0, NULL, NULL, NULL, &spawn_error))) | |
88 { | |
89 gaim_notify_error(plugin_pointer, "Error Running Editor", | |
90 "The following error has occured:", spawn_error->message); | |
91 } | |
92 } | |
93 | |
94 static void add_button (GaimConversation *conv) | |
95 { | |
96 GtkWidget *button, *image, *bbox; | |
97 | |
98 button = gtk_toggle_button_new(); | |
99 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
100 | |
101 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(start_session), NULL); | |
102 | |
103 bbox = gtk_vbox_new(FALSE, 0); | |
104 | |
105 gtk_container_add (GTK_CONTAINER(button), bbox); | |
106 | |
107 gchar *file_path = g_build_filename (DATADIR, "pixmaps", "gaim", "buttons", "music.png", NULL); | |
108 image = gtk_image_new_from_file(file_path); | |
109 | |
110 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); | |
111 | |
112 gtk_widget_show_all(bbox); | |
113 | |
114 gtk_box_pack_start(GTK_BOX(GAIM_GTK_CONVERSATION(conv)->toolbar), button, FALSE, FALSE, 0); | |
33 } | 115 } |
34 | 116 |
35 static GtkWidget * | 117 static GtkWidget * |
36 get_config_frame(GaimPlugin *plugin) | 118 get_config_frame(GaimPlugin *plugin) |
37 { | 119 { |
38 GtkWidget *ret; | 120 GtkWidget *ret; |
39 GtkWidget *vbox; | 121 GtkWidget *vbox; |
40 | 122 |
123 GtkWidget *editor_path; | |
124 GtkWidget *editor_path_label; | |
125 GtkWidget *editor_path_button; | |
126 | |
41 /* Outside container */ | 127 /* Outside container */ |
42 ret = gtk_vbox_new(FALSE, 18); | 128 ret = gtk_vbox_new(FALSE, 18); |
43 gtk_container_set_border_width(GTK_CONTAINER(ret), 10); | 129 gtk_container_set_border_width(GTK_CONTAINER(ret), 10); |
44 | 130 |
45 /* Configuration frame */ | 131 /* Configuration frame */ |
46 vbox = gaim_gtk_make_frame(ret, _("Music Messaging Configuration")); | 132 vbox = gaim_gtk_make_frame(ret, _("Music Messaging Configuration")); |
133 | |
134 /* Path to the score editor */ | |
135 editor_path = gtk_entry_new(); | |
136 editor_path_label = gtk_label_new("Score Editor Path"); | |
137 editor_path_button = gtk_button_new_with_mnemonic(_("_Apply")); | |
138 | |
139 gtk_entry_set_text((GtkEntry*)editor_path, "/usr/local/bin/gscore"); | |
140 | |
141 g_signal_connect(G_OBJECT(editor_path_button), "clicked", | |
142 G_CALLBACK(set_editor_path), editor_path); | |
143 | |
144 gtk_box_pack_start(GTK_BOX(vbox), editor_path_label, FALSE, FALSE, 0); | |
145 gtk_box_pack_start(GTK_BOX(vbox), editor_path, FALSE, FALSE, 0); | |
146 gtk_box_pack_start(GTK_BOX(vbox), editor_path_button, FALSE, FALSE, 0); | |
47 | 147 |
48 gtk_widget_show_all(ret); | 148 gtk_widget_show_all(ret); |
49 | 149 |
50 return ret; | 150 return ret; |
51 } | 151 } |
72 "The Music Messaging Plugin allows a number of users to simultaniously work on a piece of music by editting a common score in real-time.", | 172 "The Music Messaging Plugin allows a number of users to simultaniously work on a piece of music by editting a common score in real-time.", |
73 "Christian Muise <christian.muise@gmail.com>", | 173 "Christian Muise <christian.muise@gmail.com>", |
74 GAIM_WEBSITE, | 174 GAIM_WEBSITE, |
75 plugin_load, | 175 plugin_load, |
76 plugin_unload, | 176 plugin_unload, |
77 plugin_destroyed, | 177 NULL, |
78 &ui_info, | 178 &ui_info, |
79 NULL, | 179 NULL, |
80 NULL, | 180 NULL, |
81 NULL | 181 NULL |
82 }; | 182 }; |
83 | 183 |
84 static void | 184 static void |
85 init_plugin(GaimPlugin *plugin) { | 185 init_plugin(GaimPlugin *plugin) { |
186 gaim_prefs_add_none("/plugins/gtk/musicmessaging"); | |
187 gaim_prefs_add_string("/plugins/gtk/musicmessaging/editor_path", "/usr/local/bin/gscore"); | |
86 } | 188 } |
87 | 189 |
88 GAIM_INIT_PLUGIN(musicmessaging, init_plugin, info); | 190 GAIM_INIT_PLUGIN(musicmessaging, init_plugin, info); |