Skip to content

Commit

Permalink
Merge pull request #531 from FreeRDP/nbdnd
Browse files Browse the repository at this point in the history
Fix for notebook tab drag and drop, fixes issues #529 #478
  • Loading branch information
giox069 committed Mar 28, 2015
2 parents b3e339e + 6c1e963 commit 8936036
Showing 1 changed file with 34 additions and 18 deletions.
52 changes: 34 additions & 18 deletions remmina/src/remmina_connection_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ struct _RemminaConnectionHolder
static void remmina_connection_holder_create_scrolled(RemminaConnectionHolder* cnnhld, RemminaConnectionObject* cnnobj);
static void remmina_connection_holder_create_fullscreen(RemminaConnectionHolder* cnnhld, RemminaConnectionObject* cnnobj,
gint view_mode);
static gboolean remmina_connection_window_hostkey_func(RemminaProtocolWidget* gp, guint keyval, gboolean release,
RemminaConnectionHolder* cnnhld);

static void remmina_connection_window_class_init(RemminaConnectionWindowClass* klass)
{
Expand Down Expand Up @@ -1070,7 +1072,7 @@ static void remmina_connection_holder_toolbar_tools(GtkWidget* widget, RemminaCo
menuitem = gtk_menu_item_new_with_label(
g_strdup(keystroke_values[strlen(keystroke_values[0]) ? 0 : 1]));
g_object_set_data(G_OBJECT(menuitem), "keystrokes", g_strdup(keystroke_values[1]));
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
G_CALLBACK(remmina_protocol_widget_send_keystrokes),
REMMINA_PROTOCOL_WIDGET(cnnobj->proto));
gtk_widget_show(menuitem);
Expand Down Expand Up @@ -1813,22 +1815,24 @@ static void remmina_connection_window_initialize_notebook(GtkNotebook* to, GtkNo
else
{
/* View mode changed. Migrate all existing connections to the new notebook */
c = gtk_notebook_get_current_page(from);
n = gtk_notebook_get_n_pages(from);
for (i = 0; i < n; i++)
{
widget = gtk_notebook_get_nth_page(from, i);
cnnobj = (RemminaConnectionObject*) g_object_get_data(G_OBJECT(widget), "cnnobj");
if (from != NULL && GTK_IS_NOTEBOOK(from)) {
c = gtk_notebook_get_current_page(from);
n = gtk_notebook_get_n_pages(from);
for (i = 0; i < n; i++)
{
widget = gtk_notebook_get_nth_page(from, i);
cnnobj = (RemminaConnectionObject*) g_object_get_data(G_OBJECT(widget), "cnnobj");

tab = remmina_connection_object_create_tab(cnnobj);
remmina_connection_object_append_page(cnnobj, to, tab, view_mode);
tab = remmina_connection_object_create_tab(cnnobj);
remmina_connection_object_append_page(cnnobj, to, tab, view_mode);

/* Reparent cnnobj->viewport */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_reparent(cnnobj->viewport, cnnobj->scrolled_container);
G_GNUC_END_IGNORE_DEPRECATIONS
/* Reparent cnnobj->viewport */
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_reparent(cnnobj->viewport, cnnobj->scrolled_container);
G_GNUC_END_IGNORE_DEPRECATIONS
}
gtk_notebook_set_current_page(to, c);
}
gtk_notebook_set_current_page(to, c);
}
}

Expand Down Expand Up @@ -1923,6 +1927,7 @@ remmina_connection_holder_on_notebook_create_window(GtkNotebook* notebook, GtkWi
srccnnwin = REMMINA_CONNECTION_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(notebook)));
dstcnnwin = REMMINA_CONNECTION_WINDOW(remmina_widget_pool_find_by_window(REMMINA_TYPE_CONNECTION_WINDOW, window));


if (srccnnwin == dstcnnwin)
return NULL;

Expand All @@ -1939,12 +1944,23 @@ remmina_connection_holder_on_notebook_create_window(GtkNotebook* notebook, GtkWi
else
{
cnnobj->cnnhld = g_new0(RemminaConnectionHolder, 1);
if (!cnnobj->cnnhld->cnnwin)
{
/* Create a new scrolled window to accomodate the dropped connection */
remmina_connection_holder_create_scrolled(cnnobj->cnnhld, NULL);

/* We must resize the new window here: remmina_connection_holder_check_resize() failed
* to set initial size because it has no notebook page on the window. So, we do resize
* manually here */
gtk_window_resize( GTK_WINDOW(cnnobj->cnnhld->cnnwin),
remmina_file_get_int (cnnobj->remmina_file, "window_width", 640),
remmina_file_get_int (cnnobj->remmina_file, "window_height", 480));
}
}

g_signal_emit_by_name(cnnobj->proto, "connect", cnnobj);
gtk_notebook_remove_page(GTK_NOTEBOOK(srccnnwin->priv->notebook), srcpagenum);

return NULL;
remmina_protocol_widget_set_hostkey_func(REMMINA_PROTOCOL_WIDGET(cnnobj->proto),
(RemminaHostkeyFunc) remmina_connection_window_hostkey_func, cnnobj->cnnhld);
return GTK_NOTEBOOK(cnnobj->cnnhld->cnnwin->priv->notebook);
}

static GtkWidget*
Expand Down

0 comments on commit 8936036

Please sign in to comment.