Author: dzzinstant
Date: Sat Jun 21 01:21:17 2014
New Revision: 20

URL: http://svn.gna.org/viewcvs/pidgin-zrtp?rev=20&view=rev
Log:
Small gtk-encrypt reorg

Modified:
    trunk/src/pidgin-plugin/simplezrtp/gtk-encrypt.c

Modified: trunk/src/pidgin-plugin/simplezrtp/gtk-encrypt.c
URL: 
http://svn.gna.org/viewcvs/pidgin-zrtp/trunk/src/pidgin-plugin/simplezrtp/gtk-encrypt.c?rev=20&r1=19&r2=20&view=diff
==============================================================================
--- trunk/src/pidgin-plugin/simplezrtp/gtk-encrypt.c    (original)
+++ trunk/src/pidgin-plugin/simplezrtp/gtk-encrypt.c    Sat Jun 21 01:21:17 2014
@@ -147,7 +147,7 @@
                                "A GtkBox which contains information about all 
calls",
                                "The GtkWindow associated with this media 
object.",
                                GTK_TYPE_WIDGET,
-                               G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+                               G_PARAM_READWRITE));
 
        g_type_class_add_private(klass, sizeof(PidginEncryptPrivate));
 }
@@ -172,25 +172,20 @@
        g_return_if_fail(PIDGIN_IS_ENCRYPT(obj));
 
        purple_debug_info(PLUGIN_ID " UI", "pidgin_encrypt_dispose\n");
+       if (priv->window) {
+               gtk_widget_destroy(priv->window);
+               priv->window = NULL;
+       } else {
+               if (priv->box)
+                       g_object_unref(priv->box);
+       }
+               
        if (priv->encrypt) {
                purple_encrypt_set_ui_data(priv->encrypt, NULL);
                g_object_unref(G_OBJECT(priv->encrypt));
                priv->encrypt = NULL;
        }
 
-       if (priv->box) {
-               if (priv->window)
-                       gtk_widget_destroy(priv->box);
-               else
-                       g_object_unref(priv->box);
-               priv->box = NULL;
-       }
-
-       if (priv->window) {
-               gtk_widget_destroy(priv->window);
-               priv->window = NULL;
-       } 
-
        if (priv->auth_controls) {
                g_hash_table_destroy(priv->auth_controls);
                priv->auth_controls = NULL;
@@ -234,8 +229,7 @@
 remove_call(PidginEncrypt *self, const gchar *participant)
 {
        PidginEncryptPrivate *priv = PIDGIN_ENCRYPT_GET_PRIVATE(self);
-       gpointer call = get_call(self, participant);
-       g_return_if_fail(call);
+       g_return_if_fail(PIDGIN_IS_ENCRYPT(self));
 
        g_hash_table_remove(priv->auth_controls, participant);
        if (g_hash_table_size(priv->auth_controls) == 0)
@@ -248,7 +242,6 @@
 {
        GtkWidget *button;
        GtkWidget *labelbox;
-
        g_return_val_if_fail(call, NULL);
 
        call->controlbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
@@ -269,7 +262,7 @@
        gtk_button_set_relief(GTK_BUTTON(call->authimg), GTK_RELIEF_NONE);
        gtk_box_pack_start(GTK_BOX(call->controlbox), call->authimg, TRUE, 
FALSE, 0);
 
-       purple_debug_info(PLUGIN_ID " UI", "_add controlbox(): authimg=%p(%s) 
image=%p(%s) label=%p(%s)\n", 
+       purple_debug_info(PLUGIN_ID " UI", "add controlbox(): authimg=%p(%s) 
image=%p(%s) label=%p(%s)\n", 
                        call->authimg, gtk_widget_get_name(call->authimg),
                        call->image, gtk_widget_get_name(call->image),
                        call->label, gtk_widget_get_name(call->label));
@@ -298,6 +291,42 @@
        return call->controlbox;
 }
 
+static GtkWidget *
+get_parentbox(PurpleEncrypt *encrypt)
+{
+       PurpleMedia *media;
+       GtkWidget *mediawindow;
+
+       g_object_get(encrypt, "media", &media, NULL);
+       mediawindow = GTK_WIDGET(g_object_get_data(G_OBJECT(media),
+                               "/SimpleZRTP/mediawindow"));
+       g_object_unref(G_OBJECT(media));
+
+       if (!GTK_IS_WINDOW(mediawindow)) {
+               purple_debug_info(PLUGIN_ID " UI", "get_parentbox(): no access 
to PidginMedia window.\n");
+               return NULL;
+       }
+
+       return gtk_bin_get_child(GTK_BIN(mediawindow));
+}
+
+static GtkWidget *
+create_external_box(PidginEncrypt *self)
+{
+       PidginEncryptPrivate *priv = PIDGIN_ENCRYPT_GET_PRIVATE(self);
+       GtkWidget *mainbox;
+
+       priv->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_title(GTK_WINDOW(priv->window), "ZRTP encryption 
control");
+       gtk_window_set_default_size(GTK_WINDOW(priv->window), 500, 0);
+
+       mainbox = gtk_vbox_new(TRUE, 5);
+       gtk_container_add(GTK_CONTAINER(priv->window), mainbox);
+       gtk_widget_show_all(mainbox);
+
+       return mainbox;
+}
+
 /* Creates a new authentication box for this participant. */
 static PidginEncryptCall *
 call_create(PidginEncrypt *self, const gchar *participant)
@@ -356,20 +385,7 @@
 
                case PROP_BOX:
                {
-                       GtkWidget *box = g_value_get_object(value);
-
-                       if (!box) {
-                               priv->window = 
gtk_window_new(GTK_WINDOW_TOPLEVEL);
-                               gtk_window_set_title(GTK_WINDOW(priv->window), 
"ZRTP encryption control");
-                               
gtk_window_set_default_size(GTK_WINDOW(priv->window), 500, 0);
-
-                               priv->box = gtk_vbox_new(TRUE, 5);
-                               gtk_container_add(GTK_CONTAINER(priv->window), 
priv->box);
-                               gtk_widget_show_all(priv->box);
-                       } else {
-                               priv->box = g_object_ref(box);
-                       }
-                       gtk_widget_show_all(gtk_widget_get_parent(priv->box));
+                       priv->box = g_value_get_object(value);
                        break;
                }
                default:
@@ -424,36 +440,23 @@
 /** 
  * Gtk interface to the PurpleEncrypt subcomponent of libpurple 
  */
-static GtkWidget* get_parentbox(PurpleEncrypt *encrypt)
-{
-       PurpleMedia *media;
-       GtkWidget *mediawindow, *parentbox;
-
-       g_object_get(encrypt, "media", &media, NULL);
-       mediawindow = GTK_WIDGET(g_object_get_data(G_OBJECT(media),
-                               "simplezrtp/media-window"));
-       g_object_unref(G_OBJECT(media));
-
-       if (!GTK_IS_WINDOW(mediawindow)) {
-               purple_debug_info(PLUGIN_ID " UI", "get_parentbox(): no access 
to PidginMedia window.\n");
-               return NULL;
-       }
-
-       parentbox = gtk_bin_get_child(GTK_BIN(mediawindow));
-       if (!GTK_IS_BOX(parentbox))
-               return NULL;
-
-       return parentbox;
-}
-
 static void media_new(PurpleEncrypt *encrypt)
 {
-       GtkWidget *parentbox = get_parentbox(encrypt);
-       
-       g_object_new(PIDGIN_TYPE_ENCRYPT,
+       PidginEncrypt *self;
+       GtkWidget *parentbox = NULL;
+
+       self = g_object_new(PIDGIN_TYPE_ENCRYPT,
                        "encrypt", encrypt,
-                       "box", parentbox,
                        NULL);
+
+       parentbox = g_object_ref(G_OBJECT(get_parentbox(encrypt)));
+       if (GTK_BOX(parentbox))
+               gtk_box_pack_start(GTK_BOX(parentbox), gtk_hseparator_new(), 
FALSE, FALSE, 0);
+       else
+               parentbox = create_external_box(self);
+
+       g_object_set(self, "box", parentbox, NULL);
+       gtk_widget_show_all(gtk_widget_get_parent(parentbox));
 
        purple_debug_info(PLUGIN_ID " UI", "media_new(encrypt %p)\n", encrypt);
 }


_______________________________________________
Pidgin-zrtp-commits mailing list
Pidgin-zrtp-commits@gna.org
https://mail.gna.org/listinfo/pidgin-zrtp-commits

Reply via email to